Compare commits

..

1 Commits

Author SHA1 Message Date
Andrew Kane
47c7fa715c Updated IndexAmRoutine [skip ci] 2026-06-10 11:50:45 -07:00
8 changed files with 20 additions and 37 deletions

View File

@@ -97,7 +97,7 @@ jobs:
with: with:
postgres-version: ${{ matrix.postgres }} postgres-version: ${{ matrix.postgres }}
- run: | - run: |
call "C:\Program Files\Microsoft Visual Studio\${{ matrix.os == 'windows-2025' && 18 || 2022 }}\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^ call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^
nmake /NOLOGO /F Makefile.win && ^ nmake /NOLOGO /F Makefile.win && ^
nmake /NOLOGO /F Makefile.win install && ^ nmake /NOLOGO /F Makefile.win install && ^
nmake /NOLOGO /F Makefile.win installcheck ${{ matrix.postgres != 17 && 'PG_REGRESS=$(PGROOT)\bin\pg_regress' || '' }} && ^ nmake /NOLOGO /F Makefile.win installcheck ${{ matrix.postgres != 17 && 'PG_REGRESS=$(PGROOT)\bin\pg_regress' || '' }} && ^

View File

@@ -1,7 +1,3 @@
## 0.8.3 (unreleased)
- Fixed performance regression with Hamming distance and Jaccard distance with Postgres 18
## 0.8.2 (2026-02-25) ## 0.8.2 (2026-02-25)
- Fixed buffer overflow with parallel HNSW index build - [more info](https://github.com/pgvector/pgvector/issues/959) - Fixed buffer overflow with parallel HNSW index build - [more info](https://github.com/pgvector/pgvector/issues/959)

View File

@@ -1329,7 +1329,7 @@ make clean && PG_CFLAGS="-DUSE_ASSERT_CHECKING" make && make install
To enable benchmarking: To enable benchmarking:
```sh ```sh
make clean && PG_CFLAGS="-DHNSW_BENCH -DIVFFLAT_BENCH" make && make install make clean && PG_CFLAGS="-DIVFFLAT_BENCH" make && make install
``` ```
To show memory usage: To show memory usage:

View File

@@ -31,12 +31,10 @@
#define BIT_TARGET_CLONES #define BIT_TARGET_CLONES
#endif #endif
/* Use built-ins when possible for Postgres < 19 for inlining */ /* Use built-ins when possible for inlining */
#if PG_VERSION_NUM >= 190000 #if defined(HAVE__BUILTIN_POPCOUNT) && defined(HAVE_LONG_INT_64)
#define popcount64(x) pg_popcount64(x)
#elif defined(HAVE__BUILTIN_POPCOUNT) && (defined(HAVE_LONG_INT_64) || SIZEOF_LONG == 8)
#define popcount64(x) __builtin_popcountl(x) #define popcount64(x) __builtin_popcountl(x)
#elif defined(HAVE__BUILTIN_POPCOUNT) && (defined(HAVE_LONG_LONG_INT_64) || SIZEOF_LONG_LONG == 8) #elif defined(HAVE__BUILTIN_POPCOUNT) && defined(HAVE_LONG_LONG_INT_64)
#define popcount64(x) __builtin_popcountll(x) #define popcount64(x) __builtin_popcountll(x)
#elif !defined(_MSC_VER) #elif !defined(_MSC_VER)
/* Fails to resolve with MSVC */ /* Fails to resolve with MSVC */

View File

@@ -279,6 +279,7 @@ hnswhandler(PG_FUNCTION_ARGS)
.amconsistentequality = false, .amconsistentequality = false,
.amconsistentordering = false, .amconsistentordering = false,
.amcanbackward = false, .amcanbackward = false,
.amcanmarkpos = false,
.amcanunique = false, .amcanunique = false,
.amcanmulticol = false, .amcanmulticol = false,
.amoptionalkey = true, .amoptionalkey = true,
@@ -312,10 +313,13 @@ hnswhandler(PG_FUNCTION_ARGS)
.ambeginscan = hnswbeginscan, .ambeginscan = hnswbeginscan,
.amrescan = hnswrescan, .amrescan = hnswrescan,
.amgettuple = hnswgettuple, .amgettuple = hnswgettuple,
.amgetbatch = NULL,
.amunguardbatch = NULL,
.amkillitemsbatch = NULL,
.amgettransform = NULL,
.amgetbitmap = NULL, .amgetbitmap = NULL,
.amendscan = hnswendscan, .amendscan = hnswendscan,
.ammarkpos = NULL, .amposreset = NULL,
.amrestrpos = NULL,
.amestimateparallelscan = NULL, .amestimateparallelscan = NULL,
.aminitparallelscan = NULL, .aminitparallelscan = NULL,
.amparallelrescan = NULL, .amparallelrescan = NULL,

View File

@@ -18,10 +18,6 @@
#include "utils/sampling.h" #include "utils/sampling.h"
#include "vector.h" #include "vector.h"
#ifdef HNSW_BENCH
#include "portability/instr_time.h"
#endif
#if PG_VERSION_NUM >= 190000 #if PG_VERSION_NUM >= 190000
typedef Pointer Item; typedef Pointer Item;
#endif #endif
@@ -82,21 +78,6 @@ typedef Pointer Item;
#define HnswPageGetOpaque(page) ((HnswPageOpaque) PageGetSpecialPointer(page)) #define HnswPageGetOpaque(page) ((HnswPageOpaque) PageGetSpecialPointer(page))
#define HnswPageGetMeta(page) ((HnswMetaPageData *) PageGetContents(page)) #define HnswPageGetMeta(page) ((HnswMetaPageData *) PageGetContents(page))
#ifdef HNSW_BENCH
#define HnswBench(name, code) \
do { \
instr_time start; \
instr_time duration; \
INSTR_TIME_SET_CURRENT(start); \
(code); \
INSTR_TIME_SET_CURRENT(duration); \
INSTR_TIME_SUBTRACT(duration, start); \
elog(INFO, "%s: %.3f ms", name, INSTR_TIME_GET_MILLISEC(duration)); \
} while (0)
#else
#define HnswBench(name, code) (code)
#endif
#if PG_VERSION_NUM >= 150000 #if PG_VERSION_NUM >= 150000
#define RandomDouble() pg_prng_double(&pg_global_prng_state) #define RandomDouble() pg_prng_double(&pg_global_prng_state)
#define SeedRandom(seed) pg_prng_seed(&pg_global_prng_state, seed) #define SeedRandom(seed) pg_prng_seed(&pg_global_prng_state, seed)

View File

@@ -634,13 +634,13 @@ hnswbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
InitVacuumState(&vacuumstate, info, stats, callback, callback_state); InitVacuumState(&vacuumstate, info, stats, callback, callback_state);
/* Pass 1: Remove heap TIDs */ /* Pass 1: Remove heap TIDs */
HnswBench("RemoveHeapTids", RemoveHeapTids(&vacuumstate)); RemoveHeapTids(&vacuumstate);
/* Pass 2: Repair graph */ /* Pass 2: Repair graph */
HnswBench("RepairGraph", RepairGraph(&vacuumstate)); RepairGraph(&vacuumstate);
/* Pass 3: Mark as deleted */ /* Pass 3: Mark as deleted */
HnswBench("MarkDeleted", MarkDeleted(&vacuumstate)); MarkDeleted(&vacuumstate);
FreeVacuumState(&vacuumstate); FreeVacuumState(&vacuumstate);

View File

@@ -196,6 +196,7 @@ ivfflathandler(PG_FUNCTION_ARGS)
.amconsistentequality = false, .amconsistentequality = false,
.amconsistentordering = false, .amconsistentordering = false,
.amcanbackward = false, .amcanbackward = false,
.amcanmarkpos = false,
.amcanunique = false, .amcanunique = false,
.amcanmulticol = false, .amcanmulticol = false,
.amoptionalkey = true, .amoptionalkey = true,
@@ -229,10 +230,13 @@ ivfflathandler(PG_FUNCTION_ARGS)
.ambeginscan = ivfflatbeginscan, .ambeginscan = ivfflatbeginscan,
.amrescan = ivfflatrescan, .amrescan = ivfflatrescan,
.amgettuple = ivfflatgettuple, .amgettuple = ivfflatgettuple,
.amgetbatch = NULL,
.amunguardbatch = NULL,
.amkillitemsbatch = NULL,
.amgettransform = NULL,
.amgetbitmap = NULL, .amgetbitmap = NULL,
.amendscan = ivfflatendscan, .amendscan = ivfflatendscan,
.ammarkpos = NULL, .amposreset = NULL,
.amrestrpos = NULL,
.amestimateparallelscan = NULL, .amestimateparallelscan = NULL,
.aminitparallelscan = NULL, .aminitparallelscan = NULL,
.amparallelrescan = NULL, .amparallelrescan = NULL,