@@ -44,6 +44,12 @@ class PomaiOptions(ctypes.Structure):
4444 ("fsync_policy" , ctypes .c_uint32 ),
4545 ("memory_budget_bytes" , ctypes .c_uint64 ),
4646 ("deadline_ms" , ctypes .c_uint32 ),
47+ ("index_type" , ctypes .c_uint8 ),
48+ ("hnsw_m" , ctypes .c_uint32 ),
49+ ("hnsw_ef_construction" , ctypes .c_uint32 ),
50+ ("hnsw_ef_search" , ctypes .c_uint32 ),
51+ ("adaptive_threshold" , ctypes .c_uint32 ),
52+ ("metric" , ctypes .c_uint8 ),
4753 ]
4854
4955
@@ -93,7 +99,7 @@ class PomaiSearchResults(ctypes.Structure):
9399 ]
94100
95101
96- def run_pomai (base , queries , gt , lib_path : Path , repeats : int ):
102+ def run_pomai (base , queries , gt , lib_path : Path , repeats : int , metric : str ):
97103 lib = ctypes .CDLL (str (lib_path ))
98104 lib .pomai_options_init .argtypes = [ctypes .POINTER (PomaiOptions )]
99105 lib .pomai_open .argtypes = [ctypes .POINTER (PomaiOptions ), ctypes .POINTER (ctypes .c_void_p )]
@@ -122,6 +128,12 @@ def check(st):
122128 opts .path = str (tmpdir / "db" ).encode ()
123129 opts .shards = 4
124130 opts .dim = base .shape [1 ]
131+ opts .index_type = 1 # HNSW
132+ opts .hnsw_m = 32
133+ opts .hnsw_ef_construction = 200
134+ opts .hnsw_ef_search = 64
135+ opts .adaptive_threshold = 0
136+ opts .metric = 1 if metric == "ip" else 0
125137 check (lib .pomai_open (ctypes .byref (opts ), ctypes .byref (db )))
126138
127139 ids = np .arange (base .shape [0 ], dtype = np .uint64 )
@@ -142,6 +154,7 @@ def check(st):
142154 batch [i ].metadata = None
143155 batch [i ].metadata_len = 0
144156 check (lib .pomai_put_batch (db , batch , n ))
157+ holder .clear () # Fix memory leak: allow GC of ctypes arrays
145158 ingestion_s = time .perf_counter () - ingest_start
146159
147160 build_start = time .perf_counter ()
@@ -192,8 +205,8 @@ def check(st):
192205 pred_ids = np .array (pred , dtype = np .int64 )
193206 rec = recall_at_k (pred_ids , gt , 10 )
194207 return {
195- "engine" : "PomaiDB" ,
196- "params" : {"shards" : 4 , "topk" : 10 , "durability " : "default (WAL enabled by default)" },
208+ "engine" : "PomaiDB HNSW " ,
209+ "params" : {"shards" : 4 , "topk" : 10 , "M " : 32 , "efConstruction" : 200 , "efSearch" : 64 },
197210 "ingestion_time_s" : ingestion_s ,
198211 "index_build_time_s" : build_s ,
199212 "query_throughput_qps" : float (np .mean (qps )),
@@ -346,7 +359,7 @@ def main():
346359 gt = np .load (args .ground_truth )
347360
348361 if args .engine == "pomai" :
349- result = run_pomai (base , queries , gt , Path (args .libpomai ), args .repeats )
362+ result = run_pomai (base , queries , gt , Path (args .libpomai ), args .repeats , args . metric )
350363 elif args .engine == "hnswlib" :
351364 result = run_hnswlib (base , queries , gt , args .repeats , args .metric )
352365 elif args .engine == "faiss_flat" :
0 commit comments