From bf28ed8176cd19edbe30f7ccbc25fa299a8b0298 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 18 Jun 2025 10:57:18 -0700 Subject: [PATCH] Set random seed for IVFFLAT_BENCH [skip ci] --- src/ivfbuild.c | 4 ++++ src/ivfflat.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 944f07b..c51f408 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -1023,6 +1023,10 @@ ivfflatbuild(Relation heap, Relation index, IndexInfo *indexInfo) IndexBuildResult *result; IvfflatBuildState buildstate; +#ifdef IVFFLAT_BENCH + SeedRandom(42); +#endif + BuildIndex(heap, index, indexInfo, &buildstate, MAIN_FORKNUM); result = (IndexBuildResult *) palloc(sizeof(IndexBuildResult)); diff --git a/src/ivfflat.h b/src/ivfflat.h index c296b66..76608f3 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -73,9 +73,11 @@ #if PG_VERSION_NUM >= 150000 #define RandomDouble() pg_prng_double(&pg_global_prng_state) #define RandomInt() pg_prng_uint32(&pg_global_prng_state) +#define SeedRandom(seed) pg_prng_seed(&pg_global_prng_state, seed) #else #define RandomDouble() (((double) random()) / MAX_RANDOM_VALUE) #define RandomInt() random() +#define SeedRandom(seed) srandom(seed) #endif /* Variables */