Skip to content
Closed
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
48 changes: 48 additions & 0 deletions .github/workflows/filtered-vector-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Filtered vector artifact tests

on:
pull_request:
paths:
- 'tests/benchmark/filtered/**'
- 'CMakeLists.txt'
- 'cmake/**'
- 'src/VecSim/**'
- '.github/workflows/filtered-vector-artifacts.yml'
push:
branches: [main]
paths:
- 'tests/benchmark/filtered/**'
- 'CMakeLists.txt'
- 'cmake/**'
- 'src/VecSim/**'
- '.github/workflows/filtered-vector-artifacts.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
filtered-vector-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
persist-credentials: false
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: '3.12'
cache: pip
cache-dependency-path: tests/benchmark/filtered/requirements.txt
- run: |
python -m pip install --only-binary=:all: --require-hashes -r tests/benchmark/filtered/requirements.txt
- name: Build native filtered runner
run: |
cmake -S . -B "$RUNNER_TEMP/vecsim-filtered-build" -DCMAKE_BUILD_TYPE=Release \
-DUSE_SVS=OFF -DVECSIM_BUILD_TESTS=OFF -DVECSIM_BUILD_FILTERED_BENCHMARK=ON
cmake --build "$RUNNER_TEMP/vecsim-filtered-build" --target native_filtered_bench native_filtered_bench_tests --parallel 2
ctest --test-dir "$RUNNER_TEMP/vecsim-filtered-build" -R native_filtered_bench_tests --output-on-failure
- name: Artifact, wrapper, and native integration tests
env:
VECSIM_FILTERED_BINARY: ${{ runner.temp }}/vecsim-filtered-build/filtered_benchmark/native_filtered_bench
run: python -m unittest discover -s tests/benchmark/filtered -v
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ option(VECSIM_BUILD_TEST_HELPERS "Build test helper methods (fitMemory, serializ
# When ON, test helpers are also built even if VECSIM_BUILD_TEST_HELPERS is OFF.
option(VECSIM_BUILD_TESTS "Build VectorSimilarity test executables" ON)

option(VECSIM_BUILD_FILTERED_BENCHMARK "Build the standalone filtered vector benchmark" OFF)
if(VECSIM_BUILD_FILTERED_BENCHMARK)
set(VECSIM_BUILD_TEST_HELPERS ON)
endif()

get_filename_component(root ${CMAKE_CURRENT_LIST_DIR} ABSOLUTE)
message("# VectorSimilarity root: " ${root})
get_filename_component(binroot ${CMAKE_CURRENT_BINARY_DIR} ABSOLUTE)
Expand Down Expand Up @@ -89,6 +94,11 @@ endif()

add_subdirectory(src/VecSim)

if(VECSIM_BUILD_FILTERED_BENCHMARK)
enable_testing()
add_subdirectory(tests/benchmark/filtered filtered_benchmark)
endif()

# Needed for build as ExternalProject (like RediSearch does)
install(TARGETS VectorSimilarity DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS VectorSimilaritySpaces DESTINATION ${CMAKE_INSTALL_PREFIX})
Expand Down
2 changes: 2 additions & 0 deletions src/VecSim/index_factories/tiered_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include "VecSim/memory/vecsim_malloc.h"
#include "VecSim/vec_sim_index.h"
#include "VecSim/algorithms/hnsw/hnsw_tiered.h"
#if HAVE_SVS
#include "VecSim/algorithms/svs/svs_tiered.h"
#endif
#include "VecSim/algorithms/brute_force/brute_force.h"
#include "VecSim/index_factories/factory_utils.h"

Expand Down
8 changes: 8 additions & 0 deletions src/VecSim/vec_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include "VecSim/vec_sim_index.h"
#include "VecSim/vec_sim_adhoc_bf_ctx.h"
#include "VecSim/types/bfloat16.h"
#if HAVE_SVS
#include "VecSim/algorithms/svs/svs_utils.h"
#endif
#include <cassert>
#include <cstdarg>
#include <cstdio>
Expand Down Expand Up @@ -43,10 +45,12 @@ extern "C" void VecSim_UpdateThreadPoolSize(size_t new_size) {
} else {
VecSimIndex::setWriteMode(VecSim_WriteAsync);
}
#if HAVE_SVS
// Resize the shared SVS pool. Clamped to a minimum of 1. OS threads are spawned
// lazily on first SVS index creation; once an index exists this resizes the
// shared pool immediately (cooperating with the deferred-shrink protocol).
VecSimSVSThreadPool::resize(new_size);
#endif
}

namespace {
Expand Down Expand Up @@ -492,7 +496,11 @@ extern "C" VecSimDebugInfoIterator *VecSimIndex_DebugInfoIterator(VecSimIndex *i
}

extern "C" size_t VecSim_GetSharedMemory(void) {
#if HAVE_SVS
return VecSimSVSThreadPool::getSharedAllocationSize();
#else
return 0;
#endif
}

extern "C" VecSimIndexBasicInfo VecSimIndex_BasicInfo(VecSimIndex *index) {
Expand Down
22 changes: 22 additions & 0 deletions tests/benchmark/filtered/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
add_executable(native_filtered_bench native_main.cpp native_candidates.cpp)
target_link_libraries(native_filtered_bench PRIVATE VectorSimilarity)

add_executable(native_filtered_bench_tests native_test.cpp native_candidates.cpp)
target_link_libraries(native_filtered_bench_tests PRIVATE VectorSimilarity)
add_test(NAME native_filtered_bench_tests COMMAND native_filtered_bench_tests)

execute_process(COMMAND git rev-parse HEAD WORKING_DIRECTORY "${root}"
OUTPUT_VARIABLE FILTERED_SOURCE_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
execute_process(COMMAND git status --porcelain --untracked-files=normal WORKING_DIRECTORY "${root}"
OUTPUT_VARIABLE FILTERED_SOURCE_STATUS OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if(FILTERED_SOURCE_STATUS)
set(FILTERED_SOURCE_DIRTY true)
else()
set(FILTERED_SOURCE_DIRTY false)
endif()
target_compile_definitions(native_filtered_bench PRIVATE
FILTERED_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
FILTERED_SOURCE_REVISION="${FILTERED_SOURCE_REVISION}"
FILTERED_SOURCE_DIRTY="${FILTERED_SOURCE_DIRTY}")
136 changes: 136 additions & 0 deletions tests/benchmark/filtered/POC-GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Using the benchmark base for algorithm POCs

Start algorithm selection in VecSim, then validate the surviving candidates through
Redis and the customer application. Keep the benchmark tooling and frozen inputs
identical across candidates. NaviX and ACORN implementations are not included.

## Artifacts and ownership

| Artifact | Repository / draft | What it measures |
| --- | --- | --- |
| Frozen FP32 vectors, queries, filter memberships, exact oracle, scorer, native runner | [VectorSimilarity draft](https://github.com/RedisAI/VectorSimilarity/pull/1093), `tests/benchmark/filtered/` | Algorithm recall and C++ search latency with precomputed eligibility |
| Redis command runner | [RediSearch draft](https://github.com/RediSearch/RediSearch/pull/12157), `tests/benchmarks/filtered-vector/` | Actual `FT.SEARCH` round trips, including filtering, with AUTO / BATCHES / ADHOC_BF |
| Redis Flex wrapper | [Enterprise draft](https://github.com/redislabsdev/RediSearchEnterprise/pull/1372), `benchmarks/filtered-vector/` | Disk command execution, reranking, memory/configuration observations and explicit cache protocols |
| Seeded customer replay and frozen RESP inputs | [Private customer-workload draft](https://github.com/RediSearch/search-workload-repro/pull/1), `docs/BENCHMARK-BASE.md` | One production-derived workload: read-only KNN, updates, and application fan-out |

The common branch name is `omer-filtered-vector-bench-base`. Resolve and record
its exact commit in each repository before branching; a moving branch name is
not a reproducible version. Benchmark tooling paths can point to separate
checkouts using `--shared-root` and `--redisearch-root`. No engine dependency
upgrade is required merely to use the scripts.

## First native comparison

From the VectorSimilarity benchmark branch, using Python 3.12 or newer:

```sh
cmake -S . -B /tmp/vecsim-filtered-build -DCMAKE_BUILD_TYPE=Release \
-DUSE_SVS=OFF -DVECSIM_BUILD_TESTS=OFF -DVECSIM_BUILD_FILTERED_BENCHMARK=ON
cmake --build /tmp/vecsim-filtered-build --target native_filtered_bench -j 4
python3 -m venv /tmp/filtered-bench-venv
/tmp/filtered-bench-venv/bin/pip install --only-binary=:all: --require-hashes -r tests/benchmark/filtered/requirements.txt
PYTHON=/tmp/filtered-bench-venv/bin/python
BENCH=tests/benchmark/filtered
BINARY=/tmp/vecsim-filtered-build/filtered_benchmark/native_filtered_bench

$PYTHON "$BENCH/filtered_bench.py" prepare --output /tmp/filtered-smoke \
--documents 10000 --dimensions 128 --queries 32 --seed 20221 --metric cosine
$PYTHON "$BENCH/filtered_bench.py" oracle /tmp/filtered-smoke
$PYTHON "$BENCH/native_run.py" build --bundle /tmp/filtered-smoke \
--binary "$BINARY" --output /tmp/native-graph --m 16 --ef-construction 200
$PYTHON "$BENCH/native_run.py" run --bundle /tmp/filtered-smoke \
--binary "$BINARY" --graph /tmp/native-graph --output /tmp/native-ef200 \
--policies NATIVE_SCAN NATIVE_BATCHES --repeats 3 \
--ef-runtime 200 --batch-size 100 --timeout-ms 10000
$PYTHON "$BENCH/filtered_bench.py" score /tmp/filtered-smoke \
/tmp/native-ef200/results.jsonl --policies NATIVE_SCAN NATIVE_BATCHES \
--repeats 3 --target-recall .95 --output /tmp/native-ef200/report.json
```

`NATIVE_SCAN` scans eligible documents. `NATIVE_BATCHES` requests neighbors from
the actual HNSW batch iterator and intersects them with the eligible set. Neither
is Redis AUTO or a measurement of Redis's filter iterator costs. The oracle
remains independent: float64 arithmetic over the original FP32 inputs.

Use new output directories for every run. Examine per-query and per-cohort
recall, failures, incomplete results and latency before comparing speed. Add
`--fail-below-target` when requiring **every nonempty query** to reach the target;
the default scorer still fails on errors, invalid/missing or incomplete results.
The strict per-query gate is stronger than a mean-recall target.

## Move from smoke to selection

Use the DBpedia downloader and import commands in the [README](README.md) to
freeze a 100K-document, 32-query development bundle. Retain download provenance,
bundle manifest, oracle and their checksums. Compute the oracle once, then build
the baseline graph once. The generated files stay outside Git.

Run EF_RUNTIME 10, 50, 100 and 200 in separate output directories, with three
repetitions each and `--batch-size 10`. HNSW batch search uses a search-width floor
of the batch size; a larger batch would hide the lower EF settings. Keep batch size and construction parameters fixed unless that
parameter is the experiment. Compare latency at matched recall **within each
selectivity/correlation/k cohort**; a faster run that loses recall is not a win.
Record each repetition, including failures. These native runs are single-threaded
search measurements, not concurrent service throughput tests.

For stronger candidates expand to DBpedia 1M with the fixed development query
split, then use held-out query rows `[2000, 10000)` for final evaluation. For disk
pressure add Deep 1M/10M. Do not choose the algorithm from synthetic vectors or
from one small development run on an uncontrolled workstation.

## Plug in NaviX

1. Branch from the pinned VectorSimilarity benchmark commit. Keep the artifact
loader, oracle, scorer and baseline implementations unchanged.
2. Add the implementation behind the C++ candidate adapter documented in the
[native runner section](README.md). Register an explicit candidate label such
as `NAVIX`; the unmodified runner must reject that label until an adapter exists.
3. Build the candidate executable in a separate build directory. Run it against
the **same bundle and saved graph directory**, requesting its actual candidate
label. Score those rows using that same label and oracle. Keep the baseline
and candidate binary hashes, source revisions and build settings with results.
4. Sweep relevant search parameters and compare matched-recall curves. Report
actual counters only; returned candidates are not graph visits or distance
computations. Eligibility generation is excluded from native search timing.
5. If the candidate changes graph construction or cannot load the baseline graph,
run it as a separate construction experiment. Record build time, memory and
graph size; do not describe it as a traversal-only comparison.

## Validate inside Redis

After native selection, wire the implementation into the real Redis query path.
RQE currently produces filter eligibility; the public VecSim batch iterator does
not take that filter. An algorithm that uses eligibility during traversal needs
an actual interface and engine integration. Adding `NAVIX` to a Python argument
list alone cannot exercise it.

Expose an explicit strategy route and an observable marker/counter proving the
candidate ran. Then extend the command runner to request and verify it. AUTO may
otherwise choose ADHOC and bypass the implementation. Use the RediSearch README
for module provenance, loading, readiness, graph reuse and scoring commands.

For Flex, follow the Enterprise README: the supported policies are BATCHES and
ADHOC_BF; disk AUTO is unavailable. Use a fixed total memory budget, explicit
rerank setting and documented warm/cold-start preparation. The wrapper records
cache evidence but does not evict caches. Native RAM HNSW measurements do not
establish disk performance.

Finally run the private customer profiles on the supported RAM setup. There is
one workload with three entity types, using synthetic documents and vectors.
Its grouped/business-ranked output is an application regression gate, not the
filtered top-k oracle. Customer replay on Flex and vector-stage recall extraction
need additional adapters. Restore the pristine snapshot before every churn run.

## Keep with each comparison

- Exact tooling and engine revisions; executable/module hashes and build settings.
- Download provenance, frozen bundle ID, oracle checksum and graph/snapshot hash.
- Query split, policies, construction/search parameters, repetitions and timeouts.
- Raw `results.jsonl`, `run.json`, scored reports and unmodified error records.
- Hardware, thread/client counts, memory limits, cache procedure and concurrent
system activity. Do not benchmark while building or running another benchmark.

The initial suite covers static single-value FP32 eligibility and command-level
RAM/disk execution. Rich numeric/text predicates, multi-value vectors, automated
cache restoration, instrumented disk I/O, concurrent throughput and mutation-aware
recall remain separate extensions. Keep those distinctions in any selection report.
Loading
Loading