mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-22 12:07:34 +08:00
Compare commits
6 Commits
amgettuple
...
hnsw-bench
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02fba79a28 | ||
|
|
32284ba28a | ||
|
|
1f68c73c96 | ||
|
|
f15bc0904f | ||
|
|
2b7ad083dc | ||
|
|
421a35fcdc |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -97,7 +97,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
postgres-version: ${{ matrix.postgres }}
|
postgres-version: ${{ matrix.postgres }}
|
||||||
- run: |
|
- run: |
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^
|
call "C:\Program Files\Microsoft Visual Studio\${{ matrix.os == 'windows-2025' && 18 || 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' || '' }} && ^
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
## 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)
|
||||||
|
|||||||
@@ -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="-DIVFFLAT_BENCH" make && make install
|
make clean && PG_CFLAGS="-DHNSW_BENCH -DIVFFLAT_BENCH" make && make install
|
||||||
```
|
```
|
||||||
|
|
||||||
To show memory usage:
|
To show memory usage:
|
||||||
|
|||||||
@@ -31,10 +31,12 @@
|
|||||||
#define BIT_TARGET_CLONES
|
#define BIT_TARGET_CLONES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Use built-ins when possible for inlining */
|
/* Use built-ins when possible for Postgres < 19 for inlining */
|
||||||
#if defined(HAVE__BUILTIN_POPCOUNT) && defined(HAVE_LONG_INT_64)
|
#if PG_VERSION_NUM >= 190000
|
||||||
|
#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)
|
#elif defined(HAVE__BUILTIN_POPCOUNT) && (defined(HAVE_LONG_LONG_INT_64) || SIZEOF_LONG_LONG == 8)
|
||||||
#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 */
|
||||||
|
|||||||
@@ -279,7 +279,6 @@ 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,
|
||||||
@@ -313,13 +312,10 @@ 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,
|
||||||
.amposreset = NULL,
|
.ammarkpos = NULL,
|
||||||
|
.amrestrpos = NULL,
|
||||||
.amestimateparallelscan = NULL,
|
.amestimateparallelscan = NULL,
|
||||||
.aminitparallelscan = NULL,
|
.aminitparallelscan = NULL,
|
||||||
.amparallelrescan = NULL,
|
.amparallelrescan = NULL,
|
||||||
|
|||||||
19
src/hnsw.h
19
src/hnsw.h
@@ -18,6 +18,10 @@
|
|||||||
#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
|
||||||
@@ -78,6 +82,21 @@ 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)
|
||||||
|
|||||||
@@ -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 */
|
||||||
RemoveHeapTids(&vacuumstate);
|
HnswBench("RemoveHeapTids", RemoveHeapTids(&vacuumstate));
|
||||||
|
|
||||||
/* Pass 2: Repair graph */
|
/* Pass 2: Repair graph */
|
||||||
RepairGraph(&vacuumstate);
|
HnswBench("RepairGraph", RepairGraph(&vacuumstate));
|
||||||
|
|
||||||
/* Pass 3: Mark as deleted */
|
/* Pass 3: Mark as deleted */
|
||||||
MarkDeleted(&vacuumstate);
|
HnswBench("MarkDeleted", MarkDeleted(&vacuumstate));
|
||||||
|
|
||||||
FreeVacuumState(&vacuumstate);
|
FreeVacuumState(&vacuumstate);
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,6 @@ 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,
|
||||||
@@ -230,13 +229,10 @@ 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,
|
||||||
.amposreset = NULL,
|
.ammarkpos = NULL,
|
||||||
|
.amrestrpos = NULL,
|
||||||
.amestimateparallelscan = NULL,
|
.amestimateparallelscan = NULL,
|
||||||
.aminitparallelscan = NULL,
|
.aminitparallelscan = NULL,
|
||||||
.amparallelrescan = NULL,
|
.amparallelrescan = NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user