Compare commits

..

12 Commits

Author SHA1 Message Date
Andrew Kane
88ba5da6a7 Version bump to 0.1.2 [skip ci] 2021-04-26 19:37:26 -07:00
Andrew Kane
6a550c8b52 Added Mac to CI 2021-04-26 15:36:58 -07:00
Andrew Kane
5748cb6b43 Vectorized distance calculations 2021-04-26 15:33:11 -07:00
Andrew Kane
60814b8f39 Use write location for Postgres 9.6 2021-04-26 03:50:01 -07:00
Andrew Kane
773a63bed1 Use replay location instead of write location for test 2021-04-26 03:42:34 -07:00
Andrew Kane
955a5a6082 Removed completed todo [skip ci] 2021-04-26 01:09:05 -07:00
Andrew Kane
8863920fdc Improved cost estimation 2021-04-26 01:04:01 -07:00
Andrew Kane
6d9653d763 Show diff on failure 2021-04-25 22:24:45 -07:00
Andrew Kane
3a488c9f2f Fixed warning 2021-04-25 20:39:16 -07:00
Andrew Kane
fe133bfe5d Updated readme [skip ci] 2021-04-25 20:00:53 -07:00
Andrew Kane
e279bb3d7e Revert "Use INFINITY instead of DBL_MAX for comparisons"
This reverts commit 0aa39a8c0c.
2021-04-25 19:51:35 -07:00
Andrew Kane
0aa39a8c0c Use INFINITY instead of DBL_MAX for comparisons 2021-04-25 19:16:29 -07:00
7 changed files with 57 additions and 12 deletions

View File

@@ -3,20 +3,37 @@ on: [push, pull_request]
jobs:
build:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
postgres: [13, 12, 11, 10, 9.6]
include:
- os: macos-latest
postgres: 13
steps:
- uses: actions/checkout@v2
- uses: ankane/setup-postgres@v1
with:
postgres-version: ${{ matrix.postgres }}
- run: sudo apt-get update && sudo apt-get install postgresql-server-dev-${{ matrix.postgres }} libipc-run-perl
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: sudo apt-get update && sudo apt-get install postgresql-server-dev-${{ matrix.postgres }} libipc-run-perl
- run: make
- run: |
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
export PG_CONFIG=`which pg_config`
sudo --preserve-env=PG_CONFIG make install
- if: ${{ startsWith(matrix.os, 'macos') }}
run: make install
- run: make installcheck
- run: make prove_installcheck
- if: ${{ failure() }}
run: cat regression.diffs
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: make prove_installcheck
- if: ${{ startsWith(matrix.os, 'macos') }}
run: |
brew install cpanm && cpanm IPC::Run
wget -q https://github.com/postgres/postgres/archive/refs/tags/REL_13_2.tar.gz
tar xf REL_13_2.tar.gz
make prove_installcheck PROVE=prove PERL5LIB=postgres-REL_13_2/src/test/perl

View File

@@ -1,3 +1,8 @@
## 0.1.2 (2021-04-26)
- Vectorized distance calculations
- Improved cost estimation
## 0.1.1 (2021-04-25)
- Added binary representation for `COPY`

View File

@@ -7,6 +7,17 @@ TESTS = $(wildcard sql/*.sql)
REGRESS = btree cast copy functions ivfflat_cosine ivfflat_ip ivfflat_l2 ivfflat_unlogged vector
# For auto-vectorization:
# - GCC (needs -ftree-vectorize OR -O3) - https://gcc.gnu.org/projects/tree-ssa/vectorization.html
# - Clang (could use pragma instead) - https://llvm.org/docs/Vectorizers.html
PG_CFLAGS = -march=native -ftree-vectorize -fassociative-math -fno-signed-zeros -fno-trapping-math
# Debug GCC auto-vectorization
# PG_CFLAGS += -fopt-info-vec
# Debug Clang auto-vectorization
# PG_CFLAGS += -Rpass=loop-vectorize -Rpass-analysis=loop-vectorize
PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

View File

@@ -17,7 +17,7 @@ Supports L2 distance, inner product, and cosine distance
Compile and install the extension (supports Postgres 9.6+)
```sh
git clone --branch v0.1.1 https://github.com/ankane/pgvector.git
git clone --branch v0.1.2 https://github.com/ankane/pgvector.git
cd pgvector
make
make install # may need sudo
@@ -140,7 +140,7 @@ Libraries that use pgvector:
### 0.1.1
Follow the [installation instructions](#installation) and run:
Compile and install the latest version and run:
```sql
ALTER EXTENSION vector UPDATE TO '0.1.1';

View File

@@ -29,8 +29,6 @@ _PG_init(void)
/*
* Estimate the cost of an index scan
*
* TODO Improve cost estimation
*/
static void
ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
@@ -42,6 +40,9 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
)
{
GenericCosts costs;
int lists;
double ratio;
Relation indexRel;
#if PG_VERSION_NUM < 120000
List *qinfos;
@@ -57,7 +58,18 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
genericcostestimate(root, path, loop_count, qinfos, &costs);
#endif
*indexStartupCost = costs.indexStartupCost;
indexRel = index_open(path->indexinfo->indexoid, NoLock);
lists = IvfflatGetLists(indexRel);
index_close(indexRel, NoLock);
ratio = ((double) ivfflat_probes) / lists;
if (ratio > 1)
ratio = 1;
costs.indexTotalCost *= ratio;
/* Startup cost and total cost are same */
*indexStartupCost = costs.indexTotalCost;
*indexTotalCost = costs.indexTotalCost;
*indexSelectivity = costs.indexSelectivity;
*indexCorrelation = costs.indexCorrelation;

View File

@@ -244,11 +244,10 @@ vector_recv(PG_FUNCTION_ARGS)
int32 typmod = PG_GETARG_INT32(2);
Vector *result;
int16 dim;
int16 unused;
int i;
dim = pq_getmsgint(buf, sizeof(int16));
unused = pq_getmsgint(buf, sizeof(int16));
pq_getmsgint(buf, sizeof(int16)); /* unused */
CheckDim(dim);
CheckExpectedDim(typmod, dim);

View File

@@ -21,8 +21,9 @@ sub test_index_replay
my $caughtup_query;
my $server_version_num = $node_primary->safe_psql("postgres", "SHOW server_version_num");
if ($server_version_num >= 100000) {
$caughtup_query = "SELECT pg_current_wal_lsn() <= write_lsn FROM pg_stat_replication WHERE application_name = '$applname';";
$caughtup_query = "SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$applname';";
} else {
# TODO figure out why replay location doesn't work
$caughtup_query = "SELECT pg_current_xlog_location() <= write_location FROM pg_stat_replication WHERE application_name = '$applname';";
}