Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/benchmark/bm_initialization/bm_basics_svs_initialize_fp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ BENCHMARK_REGISTER_F(BM_VecSimSVS, BM_FUNC_NAME(BM_AddVectorsDuringTraining))
{2, 4}})
->ArgNames({"training_threshold", "thread_count"})
->UseRealTime();

// TopK search on the loaded SVS index, using the search window_size and k defined below.
// {window_size, k} (recall that always window_size >= k)
BENCHMARK_TEMPLATE_DEFINE_F(BM_VecSimSVS, BM_FUNC_NAME(BM_TopK), DATA_TYPE_INDEX_T)
(benchmark::State &st) { TopK_SVS(st); }
BENCHMARK_REGISTER_F(BM_VecSimSVS, BM_FUNC_NAME(BM_TopK))
->Unit(benchmark::kMillisecond)
->Iterations(10)
->Args({10, 10})
->Args({200, 10})
->Args({100, 100})
->Args({200, 100})
->Args({500, 500})
->ArgNames({"window_size", "k"});
29 changes: 29 additions & 0 deletions tests/benchmark/bm_vecsim_svs.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class BM_VecSimSVS : public BM_VecSimGeneral {
// Deletes an amount of labels from the index that triggers inplace consolidation.
void RunGC(benchmark::State &st);

// TopK search benchmark. The search window size and k are provided by the benchmark
// registration.
void TopK_SVS(benchmark::State &st);

private:
static const char *svs_index_tar_file;
static std::string base_path;
Expand Down Expand Up @@ -463,6 +467,31 @@ void BM_VecSimSVS<index_type_t>::RunGC(benchmark::State &st) {
ASSERT_EQ(VecSimIndex_IndexSize(tiered_index), N_VECTORS - num_deletions);
}

template <typename index_type_t>
void BM_VecSimSVS<index_type_t>::TopK_SVS(benchmark::State &st) {
// Search window size (Vamana graph accuracy/latency tuning) and number of results, as
// defined by the benchmark registration.
size_t window_size = st.range(0);
size_t k = st.range(1);

// Load the SVS index from file (update_threshold is irrelevant for a search-only benchmark).
auto *index = CreateSVSIndexFromFile(1);

SVSRuntimeParams svs_params = {.windowSize = window_size};

VecSimQueryParams query_params = {.svsRuntimeParams = svs_params};

size_t iter = 0;
for (auto _ : st) {
auto results = VecSimIndex_TopKQuery(index, test_vectors[iter % N_QUERIES].data(), k,
&query_params, BY_SCORE);
VecSimQueryReply_Free(results);
iter++;
}

VecSimIndex_Free(index);
}

#define UNIT_AND_ITERATIONS Unit(benchmark::kMillisecond)->Iterations(2)

#if HAVE_SVS_LVQ
Expand Down
Loading