diff --git a/.github/workflows/filtered-vector-artifacts.yml b/.github/workflows/filtered-vector-artifacts.yml new file mode 100644 index 000000000..87a9baa39 --- /dev/null +++ b/.github/workflows/filtered-vector-artifacts.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3661cf7a1..067efb2ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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}) diff --git a/src/VecSim/index_factories/tiered_factory.h b/src/VecSim/index_factories/tiered_factory.h index 9d51c93dd..49861dcfc 100644 --- a/src/VecSim/index_factories/tiered_factory.h +++ b/src/VecSim/index_factories/tiered_factory.h @@ -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" diff --git a/src/VecSim/vec_sim.cpp b/src/VecSim/vec_sim.cpp index a9aeb6b7a..11d8872f7 100644 --- a/src/VecSim/vec_sim.cpp +++ b/src/VecSim/vec_sim.cpp @@ -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 #include #include @@ -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 { @@ -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) { diff --git a/tests/benchmark/filtered/CMakeLists.txt b/tests/benchmark/filtered/CMakeLists.txt new file mode 100644 index 000000000..84fd5f8ff --- /dev/null +++ b/tests/benchmark/filtered/CMakeLists.txt @@ -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}") diff --git a/tests/benchmark/filtered/POC-GUIDE.md b/tests/benchmark/filtered/POC-GUIDE.md new file mode 100644 index 000000000..135d35b84 --- /dev/null +++ b/tests/benchmark/filtered/POC-GUIDE.md @@ -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. diff --git a/tests/benchmark/filtered/README.md b/tests/benchmark/filtered/README.md new file mode 100644 index 000000000..087b2cbe0 --- /dev/null +++ b/tests/benchmark/filtered/README.md @@ -0,0 +1,261 @@ +# Filtered vector benchmark foundation + +This directory owns the dataset format, fixed filter bank, exact filtered oracle, +scorer, and native VecSim runner shared by algorithm POCs. The native baselines +measure C++ search with precomputed eligibility. Use the RediSearch and Enterprise +runners for actual Redis filtering and command execution. The +[POC guide](POC-GUIDE.md) connects all four repositories and shows how to compare a +new candidate. + +## Quick start + +Use Python 3.12 or newer; the dependency versions and wheel hashes are pinned. + +```sh +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/filtered_bench.py +$PYTHON "$BENCH" prepare --output /tmp/filtered-smoke \ + --documents 10000 --dimensions 128 --queries 32 --seed 20221 +$PYTHON "$BENCH" oracle /tmp/filtered-smoke +$PYTHON -m unittest discover -s tests/benchmark/filtered -v +``` + +Build and run the native baselines against the frozen bundle: + +```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 +BINARY=/tmp/vecsim-filtered-build/filtered_benchmark/native_filtered_bench +NATIVE=tests/benchmark/filtered/native_run.py +$PYTHON "$NATIVE" build --bundle /tmp/filtered-smoke --binary "$BINARY" \ + --output /tmp/filtered-graph --m 16 --ef-construction 200 +$PYTHON "$NATIVE" run --bundle /tmp/filtered-smoke --binary "$BINARY" \ + --graph /tmp/filtered-graph --output /tmp/native-ef200 \ + --policies NATIVE_SCAN NATIVE_BATCHES --repeats 3 \ + --ef-runtime 200 --batch-size 100 --timeout-ms 10000 +$PYTHON "$BENCH" score /tmp/filtered-smoke /tmp/native-ef200/results.jsonl \ + --policies NATIVE_SCAN NATIVE_BATCHES --repeats 3 \ + --target-recall 0.95 --output /tmp/native-ef200/report.json +VECSIM_FILTERED_BINARY="$BINARY" $PYTHON -m unittest discover \ + -s tests/benchmark/filtered -v +``` + +The native runner builds without SVS, Google Test, or Google Benchmark downloads. +Adding `--fail-below-target` to scoring requires every nonempty query to reach the +target; the default still fails on missing, invalid, incomplete or failed results. +The native tests exercise both L2 and cosine through actual graph save/reload and +the shared oracle when `VECSIM_FILTERED_BINARY` is set. Without it, only native +integration tests are skipped; artifact and wrapper tests still run. + +Build the `native_filtered_bench_tests` target and run +`ctest --test-dir /tmp/vecsim-filtered-build -R native_filtered_bench_tests --output-on-failure` +for deterministic C++ deadline/callback and post-timeout reuse checks. +The recorded [development baseline](baselines/README.md) includes a 10K smoke +and DBpedia 100K EF sweep, with pinned input/graph/binary hashes and cohort results. + +Bundle, graph, run, oracle, and report outputs refuse to overwrite existing files. Keep large +arrays, generated oracles, and run outputs outside Git. Preparation depends on the +NumPy version, which is recorded; distribute the frozen bundle rather than +regenerating it on each candidate branch. Consumers verify every file checksum. + +## Datasets + +`datasets.json` records raw dataset references, shapes, and intended roles. +`download_dbpedia.py` retrieves exact row ranges from the DBpedia assets and +records source object identity, byte ranges, and downloaded-file SHA-256 hashes. +The 100K-document/32-query development subset has been fetched for the initial +native baseline; Deep and larger variants remain follow-up runs. Source URLs can +change: pin and distribute the downloaded hashes and provenance with the +benchmark release. Existing HNSW snapshots and unfiltered ground truth are not +a filtered-search oracle. + +Use the synthetic 10K fixture for pipeline checks, DBpedia 100K/1M × 768 cosine +for selection, and Deep 1M/10M × 96 squared L2 for disk scale. Start with 32–128 +development queries for inexpensive iteration, then the fixed 2K development +split. Reserve source query rows `[2000, 10000)` for the final comparison; do not +tune using that split. Source query arrays must contain genuine separate queries; +the importer checks file identity and shape, not the dataset publisher's split +provenance or semantic independence. + +Download the small development subset first: + +```sh +$PYTHON tests/benchmark/filtered/download_dbpedia.py \ + --output /data/dbpedia-100k-source --documents 100000 --query-count 32 +``` + +The downloader prints the exact import command. Run that command, retain its +`provenance.json` alongside the imported bundle, and calculate the oracle once. +The files contain only the requested rows, so the import's source counts are +100,000 documents and 32 queries. The provenance records their original source +row ranges. The downloader reserves query rows `[2000, 10000)` for held-out use +with `--query-start 2000`; it rejects a request that crosses the split boundary. + +Alternatively, after downloading the complete DBpedia base and query arrays: + +```sh +$PYTHON "$BENCH" import --output /tmp/dbpedia-100k-dev \ + --vectors /data/dbpedia-cosine-dim768-1M-vectors.raw \ + --queries /data/dbpedia-cosine-dim768-test_vectors.raw \ + --format raw --documents 1000000 --query-count 10000 --dimensions 768 \ + --limit-documents 100000 --limit-queries 128 --metric cosine \ + --source dbpedia-1m-fp32 --seed 20221 +``` + +For Deep, use `--format fbin --documents 10000000 --query-count 10000 +--dimensions 96 --metric l2`, with `--limit-documents 1000000` for the small +variant. The importer requires an exact little-endian `(count, dimensions)` fbin +header and exact payload length. For a held-out bundle, select +`--query-start 2000 --limit-queries 8000`. The source row interval is recorded. + +## Native runner and candidate interface + +`NATIVE_SCAN` computes the distance to every eligible document in the loaded +VecSim index and keeps the closest `k`. `NATIVE_BATCHES` consumes the actual HNSW +batch iterator, intersects returned IDs with the eligible set, and stops when it +has `k` eligible results or exhausts the iterator. It is an approximate baseline; +its recall must be measured. Neither policy is Redis AUTO or Redis's ADHOC +implementation. + +HNSW batch search uses at least `max(ef_runtime, batch_size)` as its search width. +For an EF_RUNTIME sweep of 10/50/100/200, use `--batch-size 10` throughout; +with a batch size of 100, the first three requested settings share a floor of 100. + +Both run in one process and use the same loaded graph. Policy order rotates by +repeat. Search timing includes query preprocessing, iterator creation/destruction, +distance computation, result selection and membership checks. Building an +eligibility membership mask from the frozen IDs happens outside each query's timer. Input +loading, graph construction/serialization, graph loading, checksum verification, +and JSON output are also outside search timing and have separate metadata where +applicable. These are serial native search timings, not service throughput or +Redis filter-evaluation timings. No warmup or cache eviction is implicit. + +`build` writes `graph.hnsw`, its checksum/corpus/construction sidecar `graph.json`, +and `build.json`. `run` verifies that sidecar before loading the graph and writes +`results.jsonl`, `run.json`, native stdout/stderr, the raw native rows, and the +translated `filters.u64`/`cases.tsv` inputs. The native graph is an existing +test-helper serialization format: load only trusted snapshots and keep compatible +VecSim versions. The checksum detects changes; it does not authenticate a file. +The graph is bound to vector content, shape and metric, allowing held-out queries +to reuse the same graph when their bundle contains identical corpus vectors. + +Each run records the executable SHA-256, graph SHA-256, corpus and bundle identity, +construction/runtime parameters, native compiler/build information, host details, +and wrapper checkout revision/dirty state. The binary's source revision is captured +when CMake configures; reconfigure after changing the candidate. Its executable +hash is the authoritative identity. Record external CPU affinity, frequency, +memory constraints, and machine contention with the result set before interpreting +small timing differences. + +Implement a new adapter using `CandidateAdapter`/`SearchFunction` in `native_candidates.h` and register it +in `native_candidates.cpp`. The adapter receives the index, original query, +eligible IDs/membership mask, `k`, runtime parameters and deadline; it returns IDs, distances, +status and supported counters. `describe` exposes the registered labels, so the +Python wrapper accepts a new label without changes. There is no `NAVIX` adapter +until the algorithm is implemented and registered. Do not rename an existing +baseline as a candidate. + +Per-query deadlines produce timeout rows that remain in the scoring matrix. +`--process-timeout-seconds` is a separate watchdog (default 3,600 seconds) for a +failed or stalled process. Fatal process/protocol failures retain logs and failed +metadata but do not produce a complete `results.jsonl`; they are not successful +benchmark runs. Counters are adapter-specific; unsupported counters remain null, +and returned candidates are not a count of graph visits or distance evaluations. + +## Fixed workload + +The default matrix contains independent, exact-cardinality filters at 100%, 10%, +1%, 0.1%, and 0.01%, with `k=10`. At 10% and 1%, `k=100` is also included when +at least 200 documents qualify. Counts round down, with a minimum of one; semantic +cases explicitly cover zero, one, `k-1`, `k`, and `k+1` eligible documents. + +Up to eight query anchors each receive fixed near/far filters at 10%, 1%, and +0.1%. Their memberships are determined once using the exact distance to the +anchor, producing deliberately enriched/depleted neighborhoods. Each anchor is +queried against its own filters; these are controlled extremes, not a claim about +natural customer predicates. All filters coexist as static metadata during a +run. No index or filter is rebuilt between policies. The oracle records each +case's matching rate among the nearest 1,000 unfiltered documents (or the whole +corpus when smaller), making the realized correlation visible. + +Real TAG/NUMERIC/TEXT predicates and customer application replay belong in the +engine adapters. Customer-specific schemas and query definitions stay in their +private source repository. Updates/churn need separately versioned document +snapshots and oracles; this static oracle is invalid after changing vectors or +filter membership. + +## Artifact and result contract + +`load_bundle(path)` returns `Bundle` with `manifest`, NumPy `vectors` and +`queries`, `filters`, `cases`, and `bundle_id` (the manifest SHA-256). Inputs are: + +| File | Content | +| --- | --- | +| `manifest.json` | Version, metric (`cosine`/`l2`), dimensions, document/query counts, seed, provenance, four file checksums | +| `vectors.f32`, `queries.f32` | Row-major little-endian FP32; external document/query IDs are zero-based rows | +| `filters.json` | Filter name to sorted, unique eligible document IDs | +| `cases.json` | Objects with `case_id`, `query_id`, `filter_id`, `k`, `cohort` | + +The oracle uses float64 arithmetic over original FP32 inputs, independently of +index quantization or returned engine scores. It calculates the corpus distance +array once per query in bounded blocks, then selects the requested top-k for each +filter. Memory is one float64 corpus-distance array plus a 4,096-vector block, +filter metadata, and selection temporaries; it never allocates a Q×N matrix. +L2 means squared Euclidean distance. Cosine rejects zero vectors. + +`ground_truth.jsonl` is bound to the bundle and has a checksum sidecar. It records +eligible count, target count `min(k, eligible_count)`, canonical IDs/distances, +strictly closer IDs, and IDs tied with the kth neighbor. Ties use absolute and +relative tolerances of `1e-7`. Any boundary-tied document can fill a boundary slot; +returning extra tied documents cannot compensate for a missing strictly closer +document. Each document counts once. Empty truth has null recall and separately +requires a successful empty response. + +Each runner writes one JSONL record per case, policy, and repeat: + +```json +{"bundle_id":"manifest-sha256","case_id":"q0:independent_1:k10","repeat":0,"requested_policy":"AUTO","effective_policy":null,"status":"ok","ids":[4,9],"distances":[0.1,0.2],"latency_ms":0.7} +``` + +`status` is `ok`, `error`, or `timeout`. Errors still need empty `ids`/`distances` +and a measured finite nonnegative latency. Repeat IDs are zero-based. +`effective_policy` stays null unless actually observed; requesting AUTO does not +prove which policy ran. An optional `error` describes failures. Candidate scores +are checked for finiteness but recall is computed from IDs, since a quantized +backend's scores need not equal full-precision distances. + +The scorer requires the complete expected policy/repeat matrix. It rejects mixed +bundles and duplicate rows, marks duplicate/ineligible document IDs as invalid, +and keeps missing responses, errors, and timeouts in the recall denominator. +Reports include every query plus policy/repeat/cohort summaries, incomplete result +counts, recall, and successful-query latency percentiles. Missing/error latency +is never presented as successful latency. Exit status is nonzero for invalid, +missing, incomplete, error, or timeout results; `--fail-below-target` also enforces +the chosen recall target. + +## Comparing POCs + +Create the benchmark base before branching algorithms. Pin the exact +VectorSimilarity, RediSearch, and Enterprise commits together; an Enterprise +checkout's nested dependencies must agree with the benchmark branches. Record the +bundle hash, candidate SHAs and dirty state, compiler/build mode, CPU, RAM limit, +storage, thread/client counts, index parameters, graph/snapshot hash, efRuntime, +policy, and timing scope in each runner's `run.json`. + +For traversal-only candidates, load the same serialized graph and keep insertion +order fixed. If a candidate changes construction, report build cost and graph +differences separately. Run each candidate at least three times and compare +latency at the same recall target per selectivity/correlation cohort, including +failures and variance. Sweeping efRuntime must produce separate run directories. +Do not select on an average that hides failure in a selective cohort. + +RAM and disk need separate timing labels. Disk comparisons additionally record +the total process/memory budget, block-cache size, warmup, and whether OS/device +caches were actually controlled. A restarted process alone does not establish a +cold disk cache. Benchmark timings are invalid when run alongside builds, tests, +or other benchmark jobs. Additional algorithm adapters, concurrency/churn workloads, +and application-level business ranking remain separate additions; this foundation +provides static filtered-vector recall and a shared comparison format. diff --git a/tests/benchmark/filtered/baselines/README.md b/tests/benchmark/filtered/baselines/README.md new file mode 100644 index 000000000..0c865747e --- /dev/null +++ b/tests/benchmark/filtered/baselines/README.md @@ -0,0 +1,57 @@ +# Initial native development baseline + +Recorded on 2026-11-02 using source `2de821bd185805000e871181737bd3be90a58d77`, +GCC 13.3.0, Release, SVS disabled. This is a development baseline on an +uncontrolled workstation, useful for verifying the comparison pipeline. It is +not an algorithm-selection verdict or a Redis service latency measurement. + +The [manifest](native-development-manifest.json) pins source, executable, graph, +bundle, download and result hashes, CPU details and construction measurements. +The [cohort CSV](native-development-cohorts.csv) preserves each repetition's +summary, including failures, completeness, recall and p50/p95 search latency. +Large input/graph files and raw run outputs are outside Git; their local paths +and hashes are recorded in the manifest. Download/import/build/run commands are +in the [POC guide](../POC-GUIDE.md) and [README](../README.md). + +## Executed matrix + +- Synthetic 10K × 128 cosine, 32 queries, 245 cases, 2 policies × 3 repetitions: + 1,470 searches, no failures or incomplete results. +- DBpedia fixed 100K × 768 cosine, development query rows `[0,32)`, 277 cases, + 2 policies × 3 repetitions × EF_RUNTIME 10/50/100/200: 6,648 searches, no + failures or incomplete results. +- Each dataset uses one saved HNSW graph across all policies/settings, M=16, + EF_CONSTRUCTION=200, ascending insertion order. Batch size is 10 throughout. +- A separate DBpedia scan run with a 1 ms deadline retained 112 timeout rows out + of 277 cases. Both runner and scorer returned nonzero status as expected. + +DBpedia graph construction took 54.218 seconds, followed by 0.166 seconds of +serialization; VecSim reported 339,133,536 index bytes. That allocation statistic +is not peak process RSS. No CPU pinning, frequency control, cache eviction or +dedicated memory limit was applied. Policies rotate by repetition; there is no +implicit warmup. Builds and other benchmark jobs were not run concurrently. + +## DBpedia overview + +These values combine heterogeneous filter cohorts. Use the CSV to compare +within the same cohort; the overall percentiles below are descriptive only. +Latency intervals are the minimum and maximum of the three repetitions' +percentiles, not confidence intervals. Recall was identical across repetitions. + +| Native policy | EF | Mean recall | Minimum recall | p50 ms across repetitions | p95 ms across repetitions | +| --- | ---: | ---: | ---: | ---: | ---: | +| Scan | all | 1.00000 | 1.00 | 0.537–0.585 | 15.697–16.368 | +| HNSW batches | 10 | 0.98467 | 0.70 | 3.034–3.290 | 66.940–67.440 | +| HNSW batches | 50 | 0.99384 | 0.90 | 3.230–3.251 | 79.043–79.649 | +| HNSW batches | 100 | 0.99645 | 0.90 | 3.449–3.683 | 103.680–104.707 | +| HNSW batches | 200 | 0.99851 | 0.90 | 4.427–4.625 | 166.767–179.544 | + +The 95% **per-query** gate fails for every batch setting, despite their high +mean recalls. This is why the scorer reports the worst queries and separate +cohorts. Do not infer an AUTO-policy recommendation from these native loops: +they exclude Redis filter generation and policy switching, and the batch +baseline never switches to an eligible-document scan. + +For the next POC, load the same graph and bundle with the implemented adapter, +capture its rows, and compare latency at matched cohort recall. Expand the +development query count and dataset size before evaluating the held-out split. diff --git a/tests/benchmark/filtered/baselines/native-development-cohorts.csv b/tests/benchmark/filtered/baselines/native-development-cohorts.csv new file mode 100644 index 000000000..b3462de63 --- /dev/null +++ b/tests/benchmark/filtered/baselines/native-development-cohorts.csv @@ -0,0 +1,565 @@ +dataset,ef_runtime,all_queries_reach_target,cases,cohort,failures,incomplete,latency_p50_ms,latency_p95_ms,mean_recall,min_recall,repeat,requested_policy +smoke,200,True,245,ALL,0,0,0.01472,0.28837339999999856,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.001/k10,0,0,0.002601,0.0031408499999999997,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.01/k10,0,0,0.019854499999999997,0.026336199999999997,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.1/k10,0,0,0.06838,0.08281419999999999,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.001/k10,0,0,0.003158,0.0041148,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.01/k10,0,0,0.019216999999999998,0.030012699999999996,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.1/k10,0,0,0.088367,0.12269169999999997,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,32,independent/0.0001/k10,0,0,0.0008495,0.0016422499999999998,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,32,independent/0.001/k10,0,0,0.0035645,0.007826899999999998,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,32,independent/0.01/k10,0,0,0.008206,0.01068655,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,32,independent/0.1/k10,0,0,0.041108,0.05938424999999999,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,32,independent/0.1/k100,0,0,0.0586415,0.0713321,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,32,independent/1/k10,0,0,0.2087965,0.44371599999999983,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,1,semantic/0/k10,0,0,3.7e-05,3.7e-05,,,0,NATIVE_SCAN +smoke,200,True,1,semantic/1/k10,0,0,0.001206,0.001206,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,1,semantic/10/k10,0,0,0.002494,0.002494,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,1,semantic/11/k10,0,0,0.004237,0.004237,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,1,semantic/9/k10,0,0,0.003189,0.003189,1.0,1.0,0,NATIVE_SCAN +smoke,200,True,245,ALL,0,0,0.012545,0.18142259999999996,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.001/k10,0,0,0.0034755000000000003,0.0040240499999999995,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.01/k10,0,0,0.016399,0.026527049999999996,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.1/k10,0,0,0.0827165,0.12006589999999999,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.001/k10,0,0,0.002163,0.00295825,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.01/k10,0,0,0.009104999999999999,0.017837699999999998,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.1/k10,0,0,0.07807,0.11553904999999999,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,32,independent/0.0001/k10,0,0,0.0008675,0.00166725,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,32,independent/0.001/k10,0,0,0.002706,0.0043913,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,32,independent/0.01/k10,0,0,0.0083575,0.013907599999999999,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,32,independent/0.1/k10,0,0,0.0401325,0.04633285,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,32,independent/0.1/k100,0,0,0.065347,0.0817935,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,32,independent/1/k10,0,0,0.1788805,0.2015584,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,1,semantic/0/k10,0,0,3.9e-05,3.9e-05,,,1,NATIVE_SCAN +smoke,200,True,1,semantic/1/k10,0,0,0.001251,0.001251,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,1,semantic/10/k10,0,0,0.003339,0.003339,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,1,semantic/11/k10,0,0,0.003339,0.003339,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,1,semantic/9/k10,0,0,0.004401,0.004401,1.0,1.0,1,NATIVE_SCAN +smoke,200,True,245,ALL,0,0,0.011633,0.18348599999999998,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.001/k10,0,0,0.0027205,0.00352455,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.01/k10,0,0,0.012639000000000001,0.02080055,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,8,anchor_far/0.1/k10,0,0,0.088566,0.09937359999999999,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.001/k10,0,0,0.0040345,0.00541485,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.01/k10,0,0,0.0147055,0.026223999999999997,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,8,anchor_near/0.1/k10,0,0,0.116236,0.1316146,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,32,independent/0.0001/k10,0,0,0.0009335,0.00200455,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,32,independent/0.001/k10,0,0,0.0030865,0.0058057,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,32,independent/0.01/k10,0,0,0.0080515,0.0108319,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,32,independent/0.1/k10,0,0,0.041884500000000005,0.055512149999999996,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,32,independent/0.1/k100,0,0,0.058776999999999996,0.0623948,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,32,independent/1/k10,0,0,0.18184450000000002,0.2052354,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,1,semantic/0/k10,0,0,6.6e-05,6.6e-05,,,2,NATIVE_SCAN +smoke,200,True,1,semantic/1/k10,0,0,0.001489,0.001489,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,1,semantic/10/k10,0,0,0.002996,0.002996,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,1,semantic/11/k10,0,0,0.003797,0.003797,1.0,1.0,2,NATIVE_SCAN +smoke,200,True,1,semantic/9/k10,0,0,0.002797,0.002797,1.0,1.0,2,NATIVE_SCAN +smoke,200,False,245,ALL,0,0,1.848585,11.8576066,0.9768852459016394,0.5,0,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.001/k10,0,0,11.718625,12.033400550000001,1.0,1.0,0,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.01/k10,0,0,11.767875,12.2006529,1.0,1.0,0,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.1/k10,0,0,10.7760205,10.9618194,1.0,1.0,0,NATIVE_BATCHES +smoke,200,True,8,anchor_near/0.001/k10,0,0,0.3524755,1.0035001499999998,1.0,1.0,0,NATIVE_BATCHES +smoke,200,False,8,anchor_near/0.01/k10,0,0,0.34609,0.44925485,0.9375,0.8,0,NATIVE_BATCHES +smoke,200,False,8,anchor_near/0.1/k10,0,0,0.2529445,0.2977335,0.9375,0.8,0,NATIVE_BATCHES +smoke,200,True,32,independent/0.0001/k10,0,0,7.4361695,10.894509699999999,1.0,1.0,0,NATIVE_BATCHES +smoke,200,True,32,independent/0.001/k10,0,0,11.454801,13.10209485,1.0,1.0,0,NATIVE_BATCHES +smoke,200,False,32,independent/0.01/k10,0,0,1.9699025,2.6618250499999996,0.996875,0.9,0,NATIVE_BATCHES +smoke,200,False,32,independent/0.1/k10,0,0,0.4184575,0.50891235,0.9375,0.8,0,NATIVE_BATCHES +smoke,200,True,32,independent/0.1/k100,0,0,1.814102,2.1266607,0.995625,0.98,0,NATIVE_BATCHES +smoke,200,False,32,independent/1/k10,0,0,0.204034,0.34150325,0.925,0.5,0,NATIVE_BATCHES +smoke,200,True,1,semantic/0/k10,0,0,5.5e-05,5.5e-05,,,0,NATIVE_BATCHES +smoke,200,True,1,semantic/1/k10,0,0,11.114196,11.114196,1.0,1.0,0,NATIVE_BATCHES +smoke,200,True,1,semantic/10/k10,0,0,10.963749,10.963749,1.0,1.0,0,NATIVE_BATCHES +smoke,200,True,1,semantic/11/k10,0,0,10.141333,10.141333,1.0,1.0,0,NATIVE_BATCHES +smoke,200,True,1,semantic/9/k10,0,0,10.974633,10.974633,1.0,1.0,0,NATIVE_BATCHES +smoke,200,False,245,ALL,0,0,1.842594,11.6731316,0.9768852459016394,0.5,1,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.001/k10,0,0,11.9229325,12.19956655,1.0,1.0,1,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.01/k10,0,0,11.749012,13.997883499999999,1.0,1.0,1,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.1/k10,0,0,10.802831,10.99916995,1.0,1.0,1,NATIVE_BATCHES +smoke,200,True,8,anchor_near/0.001/k10,0,0,0.3960285,0.8049836999999999,1.0,1.0,1,NATIVE_BATCHES +smoke,200,False,8,anchor_near/0.01/k10,0,0,0.2625055,0.4080346999999999,0.9375,0.8,1,NATIVE_BATCHES +smoke,200,False,8,anchor_near/0.1/k10,0,0,0.30489,0.3432941,0.9375,0.8,1,NATIVE_BATCHES +smoke,200,True,32,independent/0.0001/k10,0,0,7.635682,11.12942505,1.0,1.0,1,NATIVE_BATCHES +smoke,200,True,32,independent/0.001/k10,0,0,11.111504,11.75641485,1.0,1.0,1,NATIVE_BATCHES +smoke,200,False,32,independent/0.01/k10,0,0,1.8530825,2.4441568499999997,0.996875,0.9,1,NATIVE_BATCHES +smoke,200,False,32,independent/0.1/k10,0,0,0.41391100000000003,0.5161797,0.9375,0.8,1,NATIVE_BATCHES +smoke,200,True,32,independent/0.1/k100,0,0,1.8249635,2.0906332499999998,0.995625,0.98,1,NATIVE_BATCHES +smoke,200,False,32,independent/1/k10,0,0,0.1885985,0.20186345,0.925,0.5,1,NATIVE_BATCHES +smoke,200,True,1,semantic/0/k10,0,0,0.000157,0.000157,,,1,NATIVE_BATCHES +smoke,200,True,1,semantic/1/k10,0,0,11.471319,11.471319,1.0,1.0,1,NATIVE_BATCHES +smoke,200,True,1,semantic/10/k10,0,0,11.220439,11.220439,1.0,1.0,1,NATIVE_BATCHES +smoke,200,True,1,semantic/11/k10,0,0,10.053338,10.053338,1.0,1.0,1,NATIVE_BATCHES +smoke,200,True,1,semantic/9/k10,0,0,11.245908,11.245908,1.0,1.0,1,NATIVE_BATCHES +smoke,200,False,245,ALL,0,0,1.832301,11.944554399999998,0.9768852459016394,0.5,2,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.001/k10,0,0,12.054971,12.7019847,1.0,1.0,2,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.01/k10,0,0,12.062227,12.55992955,1.0,1.0,2,NATIVE_BATCHES +smoke,200,True,8,anchor_far/0.1/k10,0,0,10.848015,11.461293600000001,1.0,1.0,2,NATIVE_BATCHES +smoke,200,True,8,anchor_near/0.001/k10,0,0,0.40627349999999995,0.9235003499999997,1.0,1.0,2,NATIVE_BATCHES +smoke,200,False,8,anchor_near/0.01/k10,0,0,0.2774365,0.39497245,0.9375,0.8,2,NATIVE_BATCHES +smoke,200,False,8,anchor_near/0.1/k10,0,0,0.32634050000000003,0.36402049999999997,0.9375,0.8,2,NATIVE_BATCHES +smoke,200,True,32,independent/0.0001/k10,0,0,7.4306055,10.79149335,1.0,1.0,2,NATIVE_BATCHES +smoke,200,True,32,independent/0.001/k10,0,0,11.071873499999999,12.1553194,1.0,1.0,2,NATIVE_BATCHES +smoke,200,False,32,independent/0.01/k10,0,0,1.8980394999999999,2.4140356,0.996875,0.9,2,NATIVE_BATCHES +smoke,200,False,32,independent/0.1/k10,0,0,0.40574699999999997,0.49235139999999994,0.9375,0.8,2,NATIVE_BATCHES +smoke,200,True,32,independent/0.1/k100,0,0,1.777086,2.0352805,0.995625,0.98,2,NATIVE_BATCHES +smoke,200,False,32,independent/1/k10,0,0,0.194829,0.21167675,0.925,0.5,2,NATIVE_BATCHES +smoke,200,True,1,semantic/0/k10,0,0,3.6e-05,3.6e-05,,,2,NATIVE_BATCHES +smoke,200,True,1,semantic/1/k10,0,0,11.066874,11.066874,1.0,1.0,2,NATIVE_BATCHES +smoke,200,True,1,semantic/10/k10,0,0,11.04481,11.04481,1.0,1.0,2,NATIVE_BATCHES +smoke,200,True,1,semantic/11/k10,0,0,10.155345,10.155345,1.0,1.0,2,NATIVE_BATCHES +smoke,200,True,1,semantic/9/k10,0,0,10.939437,10.939437,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,True,277,ALL,0,0,0.541719,15.7191302,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.001/k10,0,0,0.06439500000000001,0.08838669999999998,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.01/k10,0,0,0.4622775,0.50692705,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.1/k10,0,0,2.9831085,3.11604695,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.001/k10,0,0,0.060282,0.10532654999999996,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.01/k10,0,0,0.47864700000000004,0.5277535,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.1/k10,0,0,3.0622115,3.21112885,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,32,independent/0.0001/k10,0,0,0.01073,0.012043449999999999,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,32,independent/0.001/k10,0,0,0.062443,0.06825215,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,32,independent/0.01/k10,0,0,0.5325955,0.5764199,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,32,independent/0.01/k100,0,0,0.543317,0.55525775,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,32,independent/0.1/k10,0,0,3.189991,3.26751725,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,32,independent/0.1/k100,0,0,3.2056880000000003,3.2623504000000003,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,32,independent/1/k10,0,0,15.7128525,16.40363,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,1,semantic/0/k10,0,0,0.000177,0.000177,,,0,NATIVE_SCAN +dbpedia,10,True,1,semantic/1/k10,0,0,0.003732,0.003732,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,1,semantic/10/k10,0,0,0.010403,0.010403,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,1,semantic/11/k10,0,0,0.01065,0.01065,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,1,semantic/9/k10,0,0,0.014152,0.014152,1.0,1.0,0,NATIVE_SCAN +dbpedia,10,True,277,ALL,0,0,0.538824,15.752515599999999,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.001/k10,0,0,0.060954,0.0658282,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.01/k10,0,0,0.4724085,0.49504865,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.1/k10,0,0,2.971597,3.3524355999999997,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.001/k10,0,0,0.047325500000000006,0.05091695,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.01/k10,0,0,0.4635975,0.49996575,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.1/k10,0,0,3.0476155,3.31182025,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,32,independent/0.0001/k10,0,0,0.011089499999999999,0.01272035,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,32,independent/0.001/k10,0,0,0.062298,0.06860595,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,32,independent/0.01/k10,0,0,0.5277255000000001,0.58993945,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,32,independent/0.01/k100,0,0,0.5443359999999999,0.6259253,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,32,independent/0.1/k10,0,0,3.1600425,5.025597099999999,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,32,independent/0.1/k100,0,0,3.178464,5.9557939,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,32,independent/1/k10,0,0,15.731421000000001,16.14631175,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,1,semantic/0/k10,0,0,3.4e-05,3.4e-05,,,1,NATIVE_SCAN +dbpedia,10,True,1,semantic/1/k10,0,0,0.003657,0.003657,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,1,semantic/10/k10,0,0,0.010769,0.010769,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,1,semantic/11/k10,0,0,0.01267,0.01267,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,1,semantic/9/k10,0,0,0.010435,0.010435,1.0,1.0,1,NATIVE_SCAN +dbpedia,10,True,277,ALL,0,0,0.537212,15.7169842,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.001/k10,0,0,0.058605000000000004,0.06092575,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.01/k10,0,0,0.462435,0.4757017,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,8,anchor_far/0.1/k10,0,0,2.9438655000000002,2.97840145,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.001/k10,0,0,0.059470499999999996,0.0618611,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.01/k10,0,0,0.479332,0.50984385,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,8,anchor_near/0.1/k10,0,0,3.057963,3.11180235,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,32,independent/0.0001/k10,0,0,0.0103765,0.011388299999999999,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,32,independent/0.001/k10,0,0,0.062699,0.06732155,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,32,independent/0.01/k10,0,0,0.5295525000000001,0.54128215,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,32,independent/0.01/k100,0,0,0.5405629999999999,0.5518018,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,32,independent/0.1/k10,0,0,3.1753039999999997,3.3619768,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,32,independent/0.1/k100,0,0,3.1913590000000003,3.3662481,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,32,independent/1/k10,0,0,15.688418500000001,16.1549612,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,1,semantic/0/k10,0,0,4e-05,4e-05,,,2,NATIVE_SCAN +dbpedia,10,True,1,semantic/1/k10,0,0,0.002472,0.002472,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,1,semantic/10/k10,0,0,0.011827,0.011827,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,1,semantic/11/k10,0,0,0.011486,0.011486,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,True,1,semantic/9/k10,0,0,0.011776,0.011776,1.0,1.0,2,NATIVE_SCAN +dbpedia,10,False,277,ALL,0,0,3.203177,67.440127,0.9846739130434782,0.7,0,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.001/k10,0,0,67.2158245,83.04859814999999,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.01/k10,0,0,67.62269950000001,109.26724244999997,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.1/k10,0,0,63.904863999999996,70.74909465,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.001/k10,0,0,0.0820395,0.18878779999999995,0.925,0.7,0,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.01/k10,0,0,0.082044,0.12415649999999999,0.925,0.7,0,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.1/k10,0,0,0.100107,0.13399679999999997,0.925,0.7,0,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.0001/k10,0,0,65.041528,68.28987415,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.001/k10,0,0,16.9365825,18.8191618,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,False,32,independent/0.01/k10,0,0,1.952671,3.6899553,0.99375,0.9,0,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.01/k100,0,0,16.491827,19.756272300000003,0.9975,0.98,0,NATIVE_BATCHES +dbpedia,10,False,32,independent/0.1/k10,0,0,0.3977565,0.63406275,0.975,0.8,0,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.1/k100,0,0,2.566147,3.56707785,0.9921875,0.97,0,NATIVE_BATCHES +dbpedia,10,False,32,independent/1/k10,0,0,0.1031335,0.13250875,0.965625,0.7,0,NATIVE_BATCHES +dbpedia,10,True,1,semantic/0/k10,0,0,0.000164,0.000164,,,0,NATIVE_BATCHES +dbpedia,10,True,1,semantic/1/k10,0,0,72.300347,72.300347,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,True,1,semantic/10/k10,0,0,64.478612,64.478612,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,True,1,semantic/11/k10,0,0,62.07771,62.07771,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,True,1,semantic/9/k10,0,0,62.93564,62.93564,1.0,1.0,0,NATIVE_BATCHES +dbpedia,10,False,277,ALL,0,0,3.289766,67.4250146,0.9846739130434782,0.7,1,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.001/k10,0,0,66.6956245,68.05009315000001,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.01/k10,0,0,67.068153,71.24437195,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.1/k10,0,0,63.8545225,69.97346005,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.001/k10,0,0,0.09638849999999999,0.11872934999999998,0.925,0.7,1,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.01/k10,0,0,0.108208,0.12788345,0.925,0.7,1,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.1/k10,0,0,0.090382,0.11688625,0.925,0.7,1,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.0001/k10,0,0,64.629952,74.0259777,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.001/k10,0,0,16.690251,18.83772405,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,False,32,independent/0.01/k10,0,0,2.0452775,3.71544125,0.99375,0.9,1,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.01/k100,0,0,16.007941,20.8011978,0.9975,0.98,1,NATIVE_BATCHES +dbpedia,10,False,32,independent/0.1/k10,0,0,0.41203,0.8020122000000001,0.975,0.8,1,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.1/k100,0,0,2.694207,3.8275497,0.9921875,0.97,1,NATIVE_BATCHES +dbpedia,10,False,32,independent/1/k10,0,0,0.0976825,0.12568635,0.965625,0.7,1,NATIVE_BATCHES +dbpedia,10,True,1,semantic/0/k10,0,0,0.000205,0.000205,,,1,NATIVE_BATCHES +dbpedia,10,True,1,semantic/1/k10,0,0,63.45905,63.45905,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,True,1,semantic/10/k10,0,0,65.084648,65.084648,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,True,1,semantic/11/k10,0,0,61.768549,61.768549,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,True,1,semantic/9/k10,0,0,63.987896,63.987896,1.0,1.0,1,NATIVE_BATCHES +dbpedia,10,False,277,ALL,0,0,3.034279,66.940247,0.9846739130434782,0.7,2,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.001/k10,0,0,66.8358725,67.46128215,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.01/k10,0,0,66.9451685,67.304418,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,True,8,anchor_far/0.1/k10,0,0,63.7975565,65.334644,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.001/k10,0,0,0.082094,0.11694829999999999,0.925,0.7,2,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.01/k10,0,0,0.080803,0.11331569999999999,0.925,0.7,2,NATIVE_BATCHES +dbpedia,10,False,8,anchor_near/0.1/k10,0,0,0.1003745,0.12030954999999999,0.925,0.7,2,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.0001/k10,0,0,65.1594515,67.7621266,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.001/k10,0,0,17.0674085,18.749152,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,False,32,independent/0.01/k10,0,0,1.951105,3.5605236,0.99375,0.9,2,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.01/k100,0,0,16.0871285,17.79616725,0.9975,0.98,2,NATIVE_BATCHES +dbpedia,10,False,32,independent/0.1/k10,0,0,0.3965875,0.6332437999999999,0.975,0.8,2,NATIVE_BATCHES +dbpedia,10,True,32,independent/0.1/k100,0,0,2.5467104999999997,3.81789205,0.9921875,0.97,2,NATIVE_BATCHES +dbpedia,10,False,32,independent/1/k10,0,0,0.1013085,0.1292776,0.965625,0.7,2,NATIVE_BATCHES +dbpedia,10,True,1,semantic/0/k10,0,0,3.7e-05,3.7e-05,,,2,NATIVE_BATCHES +dbpedia,10,True,1,semantic/1/k10,0,0,62.435356,62.435356,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,True,1,semantic/10/k10,0,0,64.979972,64.979972,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,True,1,semantic/11/k10,0,0,59.848687,59.848687,1.0,1.0,2,NATIVE_BATCHES +dbpedia,10,True,1,semantic/9/k10,0,0,63.241897,63.241897,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,True,277,ALL,0,0,0.540417,15.696790400000001,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.001/k10,0,0,0.058754,0.06550689999999999,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.01/k10,0,0,0.461233,0.47409025,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.1/k10,0,0,2.976969,3.03322485,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.001/k10,0,0,0.059749,0.06388405,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.01/k10,0,0,0.4861665,0.52305145,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.1/k10,0,0,3.0793790000000003,3.1193887,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,32,independent/0.0001/k10,0,0,0.010542,0.01219855,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,32,independent/0.001/k10,0,0,0.0626815,0.0657986,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,32,independent/0.01/k10,0,0,0.5369330000000001,0.5653583,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,32,independent/0.01/k100,0,0,0.5423640000000001,0.5619154999999999,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,32,independent/0.1/k10,0,0,3.1947265,3.24452955,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,32,independent/0.1/k100,0,0,3.1983385,3.261914,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,32,independent/1/k10,0,0,15.6838525,16.222217949999997,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,1,semantic/0/k10,0,0,0.000357,0.000357,,,0,NATIVE_SCAN +dbpedia,50,True,1,semantic/1/k10,0,0,0.002952,0.002952,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,1,semantic/10/k10,0,0,0.014138,0.014138,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,1,semantic/11/k10,0,0,0.011994,0.011994,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,1,semantic/9/k10,0,0,0.014026,0.014026,1.0,1.0,0,NATIVE_SCAN +dbpedia,50,True,277,ALL,0,0,0.544079,15.7037796,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.001/k10,0,0,0.0589065,0.060729950000000005,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.01/k10,0,0,0.4760545,0.48784530000000004,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.1/k10,0,0,2.959533,3.04195325,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.001/k10,0,0,0.044205499999999995,0.057364399999999996,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.01/k10,0,0,0.438141,0.45846055,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.1/k10,0,0,3.0646,3.09007565,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,32,independent/0.0001/k10,0,0,0.0107925,0.01228425,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,32,independent/0.001/k10,0,0,0.0630095,0.06941085,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,32,independent/0.01/k10,0,0,0.5265545,0.5441196500000001,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,32,independent/0.01/k100,0,0,0.5479845000000001,0.57289025,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,32,independent/0.1/k10,0,0,3.1611625,3.22846845,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,32,independent/0.1/k100,0,0,3.197018,3.24533615,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,32,independent/1/k10,0,0,15.695564000000001,16.04558985,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,1,semantic/0/k10,0,0,5.1e-05,5.1e-05,,,1,NATIVE_SCAN +dbpedia,50,True,1,semantic/1/k10,0,0,0.00324,0.00324,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,1,semantic/10/k10,0,0,0.01018,0.01018,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,1,semantic/11/k10,0,0,0.011263,0.011263,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,1,semantic/9/k10,0,0,0.009165,0.009165,1.0,1.0,1,NATIVE_SCAN +dbpedia,50,True,277,ALL,0,0,0.541951,15.7563194,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.001/k10,0,0,0.058625,0.062241649999999996,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.01/k10,0,0,0.473228,0.48875985,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,8,anchor_far/0.1/k10,0,0,2.959084,3.18236375,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.001/k10,0,0,0.0604735,0.06182595,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.01/k10,0,0,0.48616649999999995,0.5698189,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,8,anchor_near/0.1/k10,0,0,3.0756005,3.24739765,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,32,independent/0.0001/k10,0,0,0.0107235,0.015925449999999997,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,32,independent/0.001/k10,0,0,0.062587,0.0673092,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,32,independent/0.01/k10,0,0,0.536349,0.5477227,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,32,independent/0.01/k100,0,0,0.5436155,0.5563681500000001,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,32,independent/0.1/k10,0,0,3.1789905000000003,3.24787985,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,32,independent/0.1/k100,0,0,3.189711,3.2525464499999996,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,32,independent/1/k10,0,0,15.7529135,15.89943555,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,1,semantic/0/k10,0,0,0.000178,0.000178,,,2,NATIVE_SCAN +dbpedia,50,True,1,semantic/1/k10,0,0,0.002942,0.002942,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,1,semantic/10/k10,0,0,0.010356,0.010356,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,1,semantic/11/k10,0,0,0.011661,0.011661,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,True,1,semantic/9/k10,0,0,0.010544,0.010544,1.0,1.0,2,NATIVE_SCAN +dbpedia,50,False,277,ALL,0,0,3.235608,79.094649,0.993840579710145,0.9,0,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.001/k10,0,0,78.9242525,79.81429204999999,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.01/k10,0,0,78.569186,80.66265615,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.1/k10,0,0,74.674162,75.34415485,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.001/k10,0,0,0.23787550000000002,0.29941945000000003,0.975,0.9,0,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.01/k10,0,0,0.22668850000000001,0.281541,0.975,0.9,0,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.1/k10,0,0,0.250232,0.30459629999999993,0.975,0.9,0,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.0001/k10,0,0,76.53183250000001,80.3252265,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.001/k10,0,0,18.176652500000003,20.3261861,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,False,32,independent/0.01/k10,0,0,2.161633,3.9791739500000003,0.99375,0.9,0,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.01/k100,0,0,17.228918,19.23699245,0.9975,0.98,0,NATIVE_BATCHES +dbpedia,50,False,32,independent/0.1/k10,0,0,0.5329005,0.76056505,0.9875,0.9,0,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.1/k100,0,0,2.714967,3.77934525,0.9931249999999999,0.97,0,NATIVE_BATCHES +dbpedia,50,False,32,independent/1/k10,0,0,0.26594249999999997,0.3622119,0.99375,0.9,0,NATIVE_BATCHES +dbpedia,50,True,1,semantic/0/k10,0,0,0.000281,0.000281,,,0,NATIVE_BATCHES +dbpedia,50,True,1,semantic/1/k10,0,0,72.892349,72.892349,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,True,1,semantic/10/k10,0,0,76.486567,76.486567,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,True,1,semantic/11/k10,0,0,72.479169,72.479169,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,True,1,semantic/9/k10,0,0,77.168196,77.168196,1.0,1.0,0,NATIVE_BATCHES +dbpedia,50,False,277,ALL,0,0,3.230264,79.0430036,0.993840579710145,0.9,1,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.001/k10,0,0,79.10569749999999,79.8262166,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.01/k10,0,0,79.15760850000001,79.82634415,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.1/k10,0,0,74.852712,75.82625625,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.001/k10,0,0,0.2552485,0.3032638,0.975,0.9,1,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.01/k10,0,0,0.25674600000000003,0.3111715,0.975,0.9,1,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.1/k10,0,0,0.248504,0.33380374999999995,0.975,0.9,1,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.0001/k10,0,0,76.4650115,79.53266175,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.001/k10,0,0,18.3767425,20.3303398,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,False,32,independent/0.01/k10,0,0,2.089195,3.8584942499999997,0.99375,0.9,1,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.01/k100,0,0,17.176688,19.19770895,0.9975,0.98,1,NATIVE_BATCHES +dbpedia,50,False,32,independent/0.1/k10,0,0,0.5202845,0.8196292999999999,0.9875,0.9,1,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.1/k100,0,0,2.6801484999999996,3.7176875,0.9931249999999999,0.97,1,NATIVE_BATCHES +dbpedia,50,False,32,independent/1/k10,0,0,0.26873349999999996,0.3251078,0.99375,0.9,1,NATIVE_BATCHES +dbpedia,50,True,1,semantic/0/k10,0,0,4.6e-05,4.6e-05,,,1,NATIVE_BATCHES +dbpedia,50,True,1,semantic/1/k10,0,0,72.182446,72.182446,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,True,1,semantic/10/k10,0,0,76.60038,76.60038,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,True,1,semantic/11/k10,0,0,70.951371,70.951371,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,True,1,semantic/9/k10,0,0,76.488296,76.488296,1.0,1.0,1,NATIVE_BATCHES +dbpedia,50,False,277,ALL,0,0,3.250554,79.649222,0.993840579710145,0.9,2,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.001/k10,0,0,80.1375725,84.39470589999999,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.01/k10,0,0,78.8102985,84.0337797,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,True,8,anchor_far/0.1/k10,0,0,76.17406700000001,88.95970109999999,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.001/k10,0,0,0.2413815,0.3074647,0.975,0.9,2,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.01/k10,0,0,0.24012250000000002,0.29609434999999995,0.975,0.9,2,NATIVE_BATCHES +dbpedia,50,False,8,anchor_near/0.1/k10,0,0,0.252071,0.30531169999999996,0.975,0.9,2,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.0001/k10,0,0,75.74524,85.2367066,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.001/k10,0,0,17.9800325,20.3054971,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,False,32,independent/0.01/k10,0,0,2.1390085,3.8583866,0.99375,0.9,2,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.01/k100,0,0,17.158810000000003,19.23281505,0.9975,0.98,2,NATIVE_BATCHES +dbpedia,50,False,32,independent/0.1/k10,0,0,0.5378315,0.75173115,0.9875,0.9,2,NATIVE_BATCHES +dbpedia,50,True,32,independent/0.1/k100,0,0,2.713371,3.7062024,0.9931249999999999,0.97,2,NATIVE_BATCHES +dbpedia,50,False,32,independent/1/k10,0,0,0.26473,0.3262799,0.99375,0.9,2,NATIVE_BATCHES +dbpedia,50,True,1,semantic/0/k10,0,0,0.000343,0.000343,,,2,NATIVE_BATCHES +dbpedia,50,True,1,semantic/1/k10,0,0,72.264616,72.264616,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,True,1,semantic/10/k10,0,0,74.299557,74.299557,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,True,1,semantic/11/k10,0,0,71.207606,71.207606,1.0,1.0,2,NATIVE_BATCHES +dbpedia,50,True,1,semantic/9/k10,0,0,73.746295,73.746295,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,True,277,ALL,0,0,0.542949,15.9118262,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.001/k10,0,0,0.059951500000000005,0.06322135,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.01/k10,0,0,0.464809,0.4912749,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.1/k10,0,0,2.943849,3.05011875,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.001/k10,0,0,0.06331,0.07332219999999999,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.01/k10,0,0,0.49149750000000003,0.5057438000000001,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.1/k10,0,0,3.1033355,3.13434555,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,32,independent/0.0001/k10,0,0,0.010548499999999999,0.0117494,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,32,independent/0.001/k10,0,0,0.063275,0.0677119,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,32,independent/0.01/k10,0,0,0.5398285,0.58138795,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,32,independent/0.01/k100,0,0,0.542413,0.5890663,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,32,independent/0.1/k10,0,0,3.201498,3.28921025,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,32,independent/0.1/k100,0,0,3.1933335,3.26895085,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,32,independent/1/k10,0,0,15.8965405,17.93967765,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,1,semantic/0/k10,0,0,0.000216,0.000216,,,0,NATIVE_SCAN +dbpedia,100,True,1,semantic/1/k10,0,0,0.002733,0.002733,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,1,semantic/10/k10,0,0,0.010549,0.010549,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,1,semantic/11/k10,0,0,0.013941,0.013941,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,1,semantic/9/k10,0,0,0.011798,0.011798,1.0,1.0,0,NATIVE_SCAN +dbpedia,100,True,277,ALL,0,0,0.548517,15.800989999999999,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.001/k10,0,0,0.059333,0.06225795,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.01/k10,0,0,0.484843,0.5545278,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.1/k10,0,0,2.9885695,3.29250695,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.001/k10,0,0,0.049531500000000006,0.0569086,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.01/k10,0,0,0.4413585,0.45903015,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.1/k10,0,0,3.0737604999999997,3.21559905,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,32,independent/0.0001/k10,0,0,0.010845500000000001,0.0152817,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,32,independent/0.001/k10,0,0,0.06421650000000001,0.0742392,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,32,independent/0.01/k10,0,0,0.5294775,0.58557355,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,32,independent/0.01/k100,0,0,0.551488,0.59634975,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,32,independent/0.1/k10,0,0,3.181483,3.2950984500000002,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,32,independent/0.1/k100,0,0,3.2085155,3.2869639,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,32,independent/1/k10,0,0,15.785725,17.1280653,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,1,semantic/0/k10,0,0,4.3e-05,4.3e-05,,,1,NATIVE_SCAN +dbpedia,100,True,1,semantic/1/k10,0,0,0.003232,0.003232,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,1,semantic/10/k10,0,0,0.010201,0.010201,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,1,semantic/11/k10,0,0,0.011651,0.011651,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,1,semantic/9/k10,0,0,0.009662,0.009662,1.0,1.0,1,NATIVE_SCAN +dbpedia,100,True,277,ALL,0,0,0.538792,15.7963712,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.001/k10,0,0,0.059496999999999994,0.07430434999999999,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.01/k10,0,0,0.47409599999999996,0.48239175,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,8,anchor_far/0.1/k10,0,0,2.974262,3.15671895,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.001/k10,0,0,0.061254,0.06589205,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.01/k10,0,0,0.485433,0.4937707,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,8,anchor_near/0.1/k10,0,0,3.098667,3.3835927499999996,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,32,independent/0.0001/k10,0,0,0.0105545,0.01166585,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,32,independent/0.001/k10,0,0,0.062669,0.06620374999999999,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,32,independent/0.01/k10,0,0,0.5349935,0.54642115,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,32,independent/0.01/k100,0,0,0.5391005,0.5510622000000001,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,32,independent/0.1/k10,0,0,3.1922535,3.26919715,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,32,independent/0.1/k100,0,0,3.1942269999999997,3.35127095,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,32,independent/1/k10,0,0,15.793247,16.0498441,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,1,semantic/0/k10,0,0,0.000187,0.000187,,,2,NATIVE_SCAN +dbpedia,100,True,1,semantic/1/k10,0,0,0.002686,0.002686,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,1,semantic/10/k10,0,0,0.010908,0.010908,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,1,semantic/11/k10,0,0,0.0103,0.0103,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,True,1,semantic/9/k10,0,0,0.017253,0.017253,1.0,1.0,2,NATIVE_SCAN +dbpedia,100,False,277,ALL,0,0,3.682786,103.8111722,0.9964492753623188,0.9,0,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.001/k10,0,0,103.45655049999999,105.3767078,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.01/k10,0,0,103.5084565,111.84584785,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.1/k10,0,0,97.45888500000001,100.5520574,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.001/k10,0,0,0.4148715,0.52357685,0.9875,0.9,0,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.01/k10,0,0,0.387524,0.46141139999999997,0.9875,0.9,0,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.1/k10,0,0,0.413104,0.48970654999999996,0.9875,0.9,0,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.0001/k10,0,0,100.551435,104.36940225,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.001/k10,0,0,21.255091,23.8285022,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,False,32,independent/0.01/k10,0,0,2.446882,4.54433405,0.99375,0.9,0,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.01/k100,0,0,19.9887445,23.39046505,0.9975,0.98,0,NATIVE_BATCHES +dbpedia,100,False,32,independent/0.1/k10,0,0,0.693327,0.9935695999999999,0.996875,0.9,0,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.1/k100,0,0,3.103251,4.1870753999999994,0.99375,0.97,0,NATIVE_BATCHES +dbpedia,100,False,32,independent/1/k10,0,0,0.4247425,0.6274561499999999,0.996875,0.9,0,NATIVE_BATCHES +dbpedia,100,True,1,semantic/0/k10,0,0,0.000181,0.000181,,,0,NATIVE_BATCHES +dbpedia,100,True,1,semantic/1/k10,0,0,92.84001,92.84001,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,True,1,semantic/10/k10,0,0,100.138558,100.138558,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,True,1,semantic/11/k10,0,0,93.987924,93.987924,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,True,1,semantic/9/k10,0,0,99.667536,99.667536,1.0,1.0,0,NATIVE_BATCHES +dbpedia,100,False,277,ALL,0,0,3.449219,104.7070616,0.9964492753623188,0.9,1,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.001/k10,0,0,104.26170400000001,113.1109945,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.01/k10,0,0,104.2459815,107.5087812,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.1/k10,0,0,97.09997200000001,104.0909993,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.001/k10,0,0,0.4160275,0.4972129,0.9875,0.9,1,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.01/k10,0,0,0.4331805,0.5009728,0.9875,0.9,1,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.1/k10,0,0,0.412329,0.4893945,0.9875,0.9,1,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.0001/k10,0,0,100.496213,111.47755595,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.001/k10,0,0,21.605036,24.60718245,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,False,32,independent/0.01/k10,0,0,2.4339985000000004,4.27707755,0.99375,0.9,1,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.01/k100,0,0,20.0093205,22.74611155,0.9975,0.98,1,NATIVE_BATCHES +dbpedia,100,False,32,independent/0.1/k10,0,0,0.689012,0.9599762999999999,0.996875,0.9,1,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.1/k100,0,0,3.025869,4.0513629,0.99375,0.97,1,NATIVE_BATCHES +dbpedia,100,False,32,independent/1/k10,0,0,0.4250925,0.5263437000000001,0.996875,0.9,1,NATIVE_BATCHES +dbpedia,100,True,1,semantic/0/k10,0,0,8.3e-05,8.3e-05,,,1,NATIVE_BATCHES +dbpedia,100,True,1,semantic/1/k10,0,0,93.615975,93.615975,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,True,1,semantic/10/k10,0,0,98.640722,98.640722,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,True,1,semantic/11/k10,0,0,93.56039,93.56039,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,True,1,semantic/9/k10,0,0,99.314022,99.314022,1.0,1.0,1,NATIVE_BATCHES +dbpedia,100,False,277,ALL,0,0,3.592284,103.6802232,0.9964492753623188,0.9,2,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.001/k10,0,0,104.07723250000001,109.9689439,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.01/k10,0,0,104.0294035,104.3696082,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,True,8,anchor_far/0.1/k10,0,0,98.09928049999999,99.7899388,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.001/k10,0,0,0.4132385,0.48811724999999995,0.9875,0.9,2,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.01/k10,0,0,0.39450850000000004,0.45604785,0.9875,0.9,2,NATIVE_BATCHES +dbpedia,100,False,8,anchor_near/0.1/k10,0,0,0.42198749999999996,0.52523895,0.9875,0.9,2,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.0001/k10,0,0,99.14226550000001,104.24622475,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.001/k10,0,0,20.825744999999998,23.49155895,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,False,32,independent/0.01/k10,0,0,2.3883824999999996,4.2921823,0.99375,0.9,2,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.01/k100,0,0,19.7160035,21.8290309,0.9975,0.98,2,NATIVE_BATCHES +dbpedia,100,False,32,independent/0.1/k10,0,0,0.6986395,0.9552218,0.996875,0.9,2,NATIVE_BATCHES +dbpedia,100,True,32,independent/0.1/k100,0,0,3.1017799999999998,4.09242235,0.99375,0.97,2,NATIVE_BATCHES +dbpedia,100,False,32,independent/1/k10,0,0,0.426698,0.5403882,0.996875,0.9,2,NATIVE_BATCHES +dbpedia,100,True,1,semantic/0/k10,0,0,0.00017,0.00017,,,2,NATIVE_BATCHES +dbpedia,100,True,1,semantic/1/k10,0,0,93.667899,93.667899,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,True,1,semantic/10/k10,0,0,98.607802,98.607802,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,True,1,semantic/11/k10,0,0,94.738983,94.738983,1.0,1.0,2,NATIVE_BATCHES +dbpedia,100,True,1,semantic/9/k10,0,0,100.443426,100.443426,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,277,ALL,0,0,0.540631,15.7531038,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.001/k10,0,0,0.060144,0.0977157,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.01/k10,0,0,0.462876,0.4880998,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.1/k10,0,0,3.0164225,3.0718422,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.001/k10,0,0,0.063684,0.1176682,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.01/k10,0,0,0.491906,0.5060368,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.1/k10,0,0,3.147837,4.4956124,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,32,independent/0.0001/k10,0,0,0.0105595,0.012060299999999998,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,32,independent/0.001/k10,0,0,0.06307650000000001,0.06613375,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,32,independent/0.01/k10,0,0,0.536354,0.55071895,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,32,independent/0.01/k100,0,0,0.541377,0.5583855,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,32,independent/0.1/k10,0,0,3.1810479999999997,3.31185095,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,32,independent/0.1/k100,0,0,3.178525,3.2644230000000003,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,32,independent/1/k10,0,0,15.738230999999999,15.90202725,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,1,semantic/0/k10,0,0,0.002405,0.002405,,,0,NATIVE_SCAN +dbpedia,200,True,1,semantic/1/k10,0,0,0.003699,0.003699,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,1,semantic/10/k10,0,0,0.01088,0.01088,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,1,semantic/11/k10,0,0,0.011878,0.011878,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,1,semantic/9/k10,0,0,0.010899,0.010899,1.0,1.0,0,NATIVE_SCAN +dbpedia,200,True,277,ALL,0,0,0.584721,16.1636098,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.001/k10,0,0,0.061169,0.0658232,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.01/k10,0,0,0.47831,0.5674880999999999,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.1/k10,0,0,3.10968,4.03835475,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.001/k10,0,0,0.056039,0.0708721,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.01/k10,0,0,0.4547355,0.6792363499999998,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.1/k10,0,0,3.094542,3.25028835,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,32,independent/0.0001/k10,0,0,0.011856,0.0171228,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,32,independent/0.001/k10,0,0,0.0676035,0.08732234999999999,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,32,independent/0.01/k10,0,0,0.5695060000000001,0.7731941999999998,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,32,independent/0.01/k100,0,0,0.583952,0.7234403,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,32,independent/0.1/k10,0,0,3.1841365,3.3847822,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,32,independent/0.1/k100,0,0,3.2334005,3.3781529,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,32,independent/1/k10,0,0,16.047486499999998,18.0322492,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,1,semantic/0/k10,0,0,4.4e-05,4.4e-05,,,1,NATIVE_SCAN +dbpedia,200,True,1,semantic/1/k10,0,0,0.003224,0.003224,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,1,semantic/10/k10,0,0,0.012473,0.012473,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,1,semantic/11/k10,0,0,0.013656,0.013656,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,1,semantic/9/k10,0,0,0.010283,0.010283,1.0,1.0,1,NATIVE_SCAN +dbpedia,200,True,277,ALL,0,0,0.559035,16.368181999999997,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.001/k10,0,0,0.06094,0.0631324,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.01/k10,0,0,0.48467899999999997,0.52903095,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,8,anchor_far/0.1/k10,0,0,3.0356725,4.1283767,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.001/k10,0,0,0.062097,0.07648155,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.01/k10,0,0,0.4987695,0.6193993,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,8,anchor_near/0.1/k10,0,0,3.144909,4.333421199999999,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,32,independent/0.0001/k10,0,0,0.011738499999999999,0.016912749999999997,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,32,independent/0.001/k10,0,0,0.065457,0.07673265,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,32,independent/0.01/k10,0,0,0.5541885,0.57886115,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,32,independent/0.01/k100,0,0,0.5557665,0.7463552,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,32,independent/0.1/k10,0,0,3.2197635,3.33486535,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,32,independent/0.1/k100,0,0,3.2161655,3.3274447499999997,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,32,independent/1/k10,0,0,16.2240045,29.770007099999994,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,1,semantic/0/k10,0,0,0.000242,0.000242,,,2,NATIVE_SCAN +dbpedia,200,True,1,semantic/1/k10,0,0,0.00528,0.00528,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,1,semantic/10/k10,0,0,0.010925,0.010925,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,1,semantic/11/k10,0,0,0.012637,0.012637,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,True,1,semantic/9/k10,0,0,0.010889,0.010889,1.0,1.0,2,NATIVE_SCAN +dbpedia,200,False,277,ALL,0,0,4.426686,166.767069,0.9985144927536233,0.9,0,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.001/k10,0,0,169.443417,177.2903807,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.01/k10,0,0,166.692185,168.5841871,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.1/k10,0,0,155.6006195,164.30260669999998,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.001/k10,0,0,0.7053054999999999,1.3100325499999999,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.01/k10,0,0,0.6631935,0.79106925,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.1/k10,0,0,0.7180899999999999,0.8701187,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.0001/k10,0,0,158.6710105,170.5769292,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.001/k10,0,0,27.372764,31.90643295,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,False,32,independent/0.01/k10,0,0,3.0394525000000003,5.3217630499999995,0.99375,0.9,0,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.01/k100,0,0,26.193763,29.7283196,0.9975,0.98,0,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.1/k10,0,0,1.0110615,1.5045065,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.1/k100,0,0,3.962862,5.2710319,0.9959375,0.98,0,NATIVE_BATCHES +dbpedia,200,True,32,independent/1/k10,0,0,0.719662,0.9363692,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,1,semantic/0/k10,0,0,3.8e-05,3.8e-05,,,0,NATIVE_BATCHES +dbpedia,200,True,1,semantic/1/k10,0,0,144.682506,144.682506,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,1,semantic/10/k10,0,0,155.279519,155.279519,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,1,semantic/11/k10,0,0,145.337712,145.337712,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,True,1,semantic/9/k10,0,0,154.502285,154.502285,1.0,1.0,0,NATIVE_BATCHES +dbpedia,200,False,277,ALL,0,0,4.624975,172.5930242,0.9985144927536233,0.9,1,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.001/k10,0,0,169.49975899999998,178.10844555,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.01/k10,0,0,173.09619600000002,192.87000365,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.1/k10,0,0,159.05184450000002,166.8430603,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.001/k10,0,0,0.737149,0.82544985,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.01/k10,0,0,0.7505065,0.8882667999999999,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.1/k10,0,0,0.700816,0.8184544,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.0001/k10,0,0,167.56277999999998,182.0563856,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.001/k10,0,0,30.11694,36.45738875,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,False,32,independent/0.01/k10,0,0,3.434628,5.7564915999999995,0.99375,0.9,1,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.01/k100,0,0,28.248174499999998,34.7166706,0.9975,0.98,1,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.1/k10,0,0,1.038799,1.4771112999999998,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.1/k100,0,0,3.9570055,5.12336205,0.9959375,0.98,1,NATIVE_BATCHES +dbpedia,200,True,32,independent/1/k10,0,0,0.769237,0.93409415,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,1,semantic/0/k10,0,0,5.3e-05,5.3e-05,,,1,NATIVE_BATCHES +dbpedia,200,True,1,semantic/1/k10,0,0,150.364604,150.364604,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,1,semantic/10/k10,0,0,157.487598,157.487598,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,1,semantic/11/k10,0,0,156.077998,156.077998,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,True,1,semantic/9/k10,0,0,158.423902,158.423902,1.0,1.0,1,NATIVE_BATCHES +dbpedia,200,False,277,ALL,0,0,4.454121,179.5437744,0.9985144927536233,0.9,2,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.001/k10,0,0,175.1255515,192.56088995000002,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.01/k10,0,0,176.32695999999999,199.04586845,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,8,anchor_far/0.1/k10,0,0,168.2581935,184.84871275,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.001/k10,0,0,0.697595,0.84728175,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.01/k10,0,0,0.7406600000000001,0.8940494999999999,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,8,anchor_near/0.1/k10,0,0,0.7330405,1.0354670499999998,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.0001/k10,0,0,171.6386915,189.20027705,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.001/k10,0,0,28.810236500000002,33.82244335,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,False,32,independent/0.01/k10,0,0,3.3188795000000004,6.0476567999999995,0.99375,0.9,2,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.01/k100,0,0,27.575251,33.3111701,0.9975,0.98,2,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.1/k10,0,0,1.0346765,1.43999605,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,32,independent/0.1/k100,0,0,3.8554455,5.1850746,0.9959375,0.98,2,NATIVE_BATCHES +dbpedia,200,True,32,independent/1/k10,0,0,0.8046155,1.0028472000000002,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,1,semantic/0/k10,0,0,7e-05,7e-05,,,2,NATIVE_BATCHES +dbpedia,200,True,1,semantic/1/k10,0,0,163.323642,163.323642,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,1,semantic/10/k10,0,0,168.788224,168.788224,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,1,semantic/11/k10,0,0,162.844705,162.844705,1.0,1.0,2,NATIVE_BATCHES +dbpedia,200,True,1,semantic/9/k10,0,0,158.499056,158.499056,1.0,1.0,2,NATIVE_BATCHES diff --git a/tests/benchmark/filtered/baselines/native-development-manifest.json b/tests/benchmark/filtered/baselines/native-development-manifest.json new file mode 100644 index 000000000..876fa3459 --- /dev/null +++ b/tests/benchmark/filtered/baselines/native-development-manifest.json @@ -0,0 +1,351 @@ +{ + "date": "2026-11-02", + "classification": "development baseline and harness validation; uncontrolled developer workstation, not an algorithm-selection verdict", + "source_revision": "2de821bd185805000e871181737bd3be90a58d77", + "source_dirty_at_compile": false, + "build_type": "Release", + "compiler": "GCC 13.3.0", + "cpu_features_version": "v0.10.1", + "use_svs": false, + "construction": { + "m": 16, + "ef_construction": 200, + "insertion_order": "ascending_external_id" + }, + "search": { + "batch_size": 10, + "repeats": 3, + "timeout_ms": 10000, + "concurrency": 1, + "cache_preparation": "none; policy order rotates by repeat" + }, + "host_cpu": { + "lscpu": [ + { + "field": "Architecture:", + "data": "x86_64" + }, + { + "field": "CPU op-mode(s):", + "data": "32-bit, 64-bit" + }, + { + "field": "Address sizes:", + "data": "46 bits physical, 48 bits virtual" + }, + { + "field": "Byte Order:", + "data": "Little Endian" + }, + { + "field": "CPU(s):", + "data": "14" + }, + { + "field": "On-line CPU(s) list:", + "data": "0-13" + }, + { + "field": "Vendor ID:", + "data": "GenuineIntel" + }, + { + "field": "Model name:", + "data": "Intel(R) Core(TM) Ultra 7 155U" + }, + { + "field": "CPU family:", + "data": "6" + }, + { + "field": "Model:", + "data": "170" + }, + { + "field": "Thread(s) per core:", + "data": "2" + }, + { + "field": "Core(s) per socket:", + "data": "12" + }, + { + "field": "Socket(s):", + "data": "1" + }, + { + "field": "Stepping:", + "data": "4" + }, + { + "field": "CPU(s) scaling MHz:", + "data": "85%" + }, + { + "field": "CPU max MHz:", + "data": "4800.0000" + }, + { + "field": "CPU min MHz:", + "data": "400.0000" + }, + { + "field": "BogoMIPS:", + "data": "5376.00" + }, + { + "field": "Flags:", + "data": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid bus_lock_detect movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities" + }, + { + "field": "Virtualization:", + "data": "VT-x" + }, + { + "field": "L1d cache:", + "data": "352 KiB (10 instances)" + }, + { + "field": "L1i cache:", + "data": "640 KiB (10 instances)" + }, + { + "field": "L2 cache:", + "data": "10 MiB (5 instances)" + }, + { + "field": "L3 cache:", + "data": "12 MiB (1 instance)" + }, + { + "field": "NUMA node(s):", + "data": "1" + }, + { + "field": "NUMA node0 CPU(s):", + "data": "0-13" + }, + { + "field": "Vulnerability Gather data sampling:", + "data": "Not affected" + }, + { + "field": "Vulnerability Ghostwrite:", + "data": "Not affected" + }, + { + "field": "Vulnerability Indirect target selection:", + "data": "Not affected" + }, + { + "field": "Vulnerability Itlb multihit:", + "data": "Not affected" + }, + { + "field": "Vulnerability L1tf:", + "data": "Not affected" + }, + { + "field": "Vulnerability Mds:", + "data": "Not affected" + }, + { + "field": "Vulnerability Meltdown:", + "data": "Not affected" + }, + { + "field": "Vulnerability Mmio stale data:", + "data": "Not affected" + }, + { + "field": "Vulnerability Old microcode:", + "data": "Not affected" + }, + { + "field": "Vulnerability Reg file data sampling:", + "data": "Not affected" + }, + { + "field": "Vulnerability Retbleed:", + "data": "Not affected" + }, + { + "field": "Vulnerability Spec rstack overflow:", + "data": "Not affected" + }, + { + "field": "Vulnerability Spec store bypass:", + "data": "Mitigation; Speculative Store Bypass disabled via prctl" + }, + { + "field": "Vulnerability Spectre v1:", + "data": "Mitigation; usercopy/swapgs barriers and __user pointer sanitization" + }, + { + "field": "Vulnerability Spectre v2:", + "data": "Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS Not affected; BHI BHI_DIS_S" + }, + { + "field": "Vulnerability Srbds:", + "data": "Not affected" + }, + { + "field": "Vulnerability Tsa:", + "data": "Not affected" + }, + { + "field": "Vulnerability Tsx async abort:", + "data": "Not affected" + }, + { + "field": "Vulnerability Vmscape:", + "data": "Mitigation; IBPB before exit to userspace" + } + ] + }, + "source_download": { + "schema_version": 1, + "dataset": "dbpedia-1m", + "dtype": " length: + raise ValueError("response contains more bytes than requested") + target.write(block) + digest.update(block) + if received != length: + raise ValueError(f"truncated array: received {received}, expected {length}") + # Exclusive creation preserves the no-overwrite contract even if another + # process creates the final path while the download is in flight. + output.hardlink_to(part) + part.unlink() + return { + "url": url, "etag": etag, "s3_version_id": version, "last_modified": modified, + "source_rows": source_rows, "source_bytes": expected_total, + "row_start": first_row, "row_stop": first_row + rows, + "content_range": f"bytes {start}-{end}/{expected_total}", + "bytes": received, "sha256": digest.hexdigest(), "file": output.name, + } + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--output", type=Path, required=True) + parser.add_argument("--documents", type=int, choices=(100_000, 1_000_000), default=100_000) + parser.add_argument("--query-count", type=int, default=32) + parser.add_argument("--query-start", type=int, default=0) + args = parser.parse_args(argv) + query_end = args.query_start + args.query_count + if args.query_start < 0 or args.query_count <= 0 or query_end > QUERIES: + parser.error("query rows must be a nonempty interval inside [0, 10000)") + if args.query_start < DEVELOPMENT_END < query_end: + parser.error("a download must not mix development and held-out query rows") + args.output.mkdir(parents=True, exist_ok=False) + vectors = download_range(VECTOR_URL, args.output / "vectors.raw", 0, args.documents, DOCUMENTS) + queries = download_range(QUERY_URL, args.output / "queries.raw", args.query_start, args.query_count, QUERIES) + source = f"dbpedia-http-range-docs0:{args.documents}-queries{args.query_start}:{query_end}" + command = [ + sys.executable, str(Path(__file__).with_name("filtered_bench.py")), "import", + "--output", str(args.output.parent / (args.output.name + "-bundle")), + "--vectors", str(args.output / "vectors.raw"), "--queries", str(args.output / "queries.raw"), + "--format", "raw", "--documents", str(args.documents), "--query-count", str(args.query_count), + "--dimensions", str(DIMENSIONS), "--metric", "cosine", "--source", source, "--seed", "20221", + ] + provenance = { + "schema_version": 1, "dataset": "dbpedia-1m", "dtype": "= {minimum}") + return value + + +def validate_vectors(vectors, metric): + for start in range(0, len(vectors), 4096): + block = vectors[start:start + 4096] + if not np.isfinite(block).all(): + raise ValueError("vectors must be finite") + if metric == "cosine" and np.any(np.linalg.norm(block.astype(np.float64), axis=1) == 0): + raise ValueError("cosine vectors must have nonzero norm") + + +def load_bundle(path): + root = Path(path) + manifest = read_json(root / "manifest.json") + if not isinstance(manifest, dict): + raise ValueError("manifest must be an object") + if type(manifest.get("schema_version")) is not int or manifest["schema_version"] != SCHEMA_VERSION: + raise ValueError("unsupported bundle schema_version") + dimensions = require_int(manifest.get("dimensions"), "dimensions", 1) + documents = require_int(manifest.get("document_count"), "document_count", 1) + query_count = require_int(manifest.get("query_count"), "query_count", 1) + metric = manifest.get("metric") + if metric not in ("l2", "cosine") or manifest.get("dtype") != "= documents: + raise ValueError("filter document ID out of range") + if ids != sorted(set(ids)): + raise ValueError("filter IDs must be sorted and unique") + cases = read_json(root / "cases.json") + if not isinstance(cases, list) or not cases: + raise ValueError("cases must be a nonempty list") + seen = set() + for case in cases: + if not isinstance(case, dict) or set(case) != {"case_id", "query_id", "filter_id", "k", "cohort"}: + raise ValueError("unexpected case fields") + case_id = case["case_id"] + if not isinstance(case_id, str) or not case_id or case_id in seen: + raise ValueError("case IDs must be nonempty and unique") + seen.add(case_id) + if require_int(case["query_id"], "query_id") >= query_count: + raise ValueError("query_id out of range") + if not isinstance(case["filter_id"], str) or case["filter_id"] not in filters: + raise ValueError("invalid case filter") + if not isinstance(case["cohort"], str) or not case["cohort"] or case["cohort"] == "ALL": + raise ValueError("invalid case filter/cohort") + require_int(case["k"], "k", 1) + return Bundle(manifest, arrays[0], arrays[1], filters, cases, sha256(root / "manifest.json")) + + +def distances_to(vectors, query, metric, block_size=4096): + """Calculate each distance once, in float64 over the original FP32 values.""" + query = np.asarray(query, dtype=np.float64) + distances = np.empty(len(vectors), dtype=np.float64) + query_norm = np.linalg.norm(query) + for start in range(0, len(vectors), block_size): + block = np.asarray(vectors[start:start + block_size], dtype=np.float64) + if metric == "l2": + delta = block - query + values = np.einsum("ij,ij->i", delta, delta) + else: + values = 1.0 - (block @ query) / (np.linalg.norm(block, axis=1) * query_norm) + values = np.clip(values, 0.0, 2.0) + distances[start:start + len(block)] = values + return distances + + +def create_cases(vectors, queries, metric, seed): + count = len(vectors) + rng = np.random.default_rng(seed) + permutation = rng.permutation(count) + filters, cases = {}, [] + + def add_filter(name, ids): + filters[name] = sorted(int(x) for x in ids) + + def add_case(query_id, filter_id, k, cohort): + cases.append({"case_id": f"q{query_id}:{filter_id}:k{k}", "query_id": query_id, + "filter_id": filter_id, "k": k, "cohort": cohort}) + + for fraction in (1.0, 0.1, 0.01, 0.001, 0.0001): + eligible = max(1, int(count * fraction)) + name = f"independent_{fraction:g}" + add_filter(name, permutation[:eligible]) + for query_id in range(len(queries)): + add_case(query_id, name, 10, f"independent/{fraction:g}/k10") + if eligible >= 200 and fraction in (0.1, 0.01): + add_case(query_id, name, 100, f"independent/{fraction:g}/k100") + + # These are static indexed fields. Each anchor is evaluated against its own frozen filters. + for query_id in range(min(8, len(queries))): + distances = distances_to(vectors, queries[query_id], metric) + ranked = np.lexsort((np.arange(count), distances)) + for fraction in (0.1, 0.01, 0.001): + eligible = max(1, int(count * fraction)) + for direction, ids in (("near", ranked[:eligible]), ("far", ranked[-eligible:])): + name = f"anchor_{query_id}_{direction}_{fraction:g}" + add_filter(name, ids) + add_case(query_id, name, 10, f"anchor_{direction}/{fraction:g}/k10") + for eligible in sorted({0, 1, min(9, count), min(10, count), min(11, count)}): + name = f"semantic_{eligible}" + add_filter(name, permutation[:eligible]) + add_case(0, name, 10, f"semantic/{eligible}/k10") + return filters, cases + + +def write_bundle(output, vectors, queries, metric, seed, provenance): + if metric not in ("l2", "cosine"): + raise ValueError("metric must be l2 or cosine") + if vectors.ndim != 2 or queries.ndim != 2 or vectors.shape[1] != queries.shape[1]: + raise ValueError("document and query matrices must have the same dimensions") + if not len(vectors) or not len(queries) or vectors.shape[1] == 0: + raise ValueError("empty vector matrices are not supported") + validate_vectors(vectors, metric) + validate_vectors(queries, metric) + filters, cases = create_cases(vectors, queries, metric, seed) + root = Path(output) + root.mkdir(parents=True, exist_ok=False) + np.asarray(vectors, dtype="= repeats or case_id not in cases: + raise ValueError("result refers to an unexpected policy, repeat, or case") + key = (policy, repeat, case_id) + if key in indexed: + raise ValueError(f"duplicate result record: {key}") + indexed[key] = record + scored = [] + for policy in policies: + for repeat in range(repeats): + for case_id, case in cases.items(): + oracle = truth[case_id] + target = oracle["target_count"] + record = indexed.get((policy, repeat, case_id)) + status, issue, latency, recall = "missing", None, None, (0.0 if target else None) + complete = False + if record is not None: + status = record.get("status") + ids, scores = record.get("ids"), record.get("distances") + latency = record.get("latency_ms") + if type(latency) not in (int, float) or not math.isfinite(latency) or latency < 0: + issue = "latency_ms must be finite and nonnegative" + latency = None + elif status not in ("ok", "error", "timeout"): + issue = "unknown status" + elif not isinstance(ids, list) or not isinstance(scores, list) or len(ids) != len(scores): + issue = "ids/distances must be same-length lists" + elif any(type(doc_id) is not int for doc_id in ids) or len(set(ids)) != len(ids): + issue = "document IDs must be integers without duplicates" + elif not set(ids).issubset(bundle.filters[case["filter_id"]]): + issue = "returned an ineligible or out-of-range document" + elif len(ids) > target: + issue = "returned more than min(k, eligible_count) documents" + elif any(type(score) not in (int, float) or not math.isfinite(score) for score in scores): + issue = "distances must be finite numbers" + if issue: + status = "invalid" + elif status == "ok": + returned = set(ids) + strict = set(oracle["strict_ids"]) + boundary = set(oracle["boundary_ids"]) + credit = len(returned & strict) + min(target - len(strict), len(returned & boundary)) + recall = credit / target if target else None + complete = len(ids) == target + scored.append({"case_id": case_id, "cohort": case["cohort"], "requested_policy": policy, + "repeat": repeat, "status": status, "recall": recall, + "complete": complete, "latency_ms": latency, "validation_error": issue}) + summaries = [] + for policy in policies: + for repeat in range(repeats): + cohorts = sorted({case["cohort"] for case in bundle.cases}) + for cohort in ["ALL", *cohorts]: + rows = [row for row in scored if row["requested_policy"] == policy and + row["repeat"] == repeat and (cohort == "ALL" or row["cohort"] == cohort)] + recalls = [row["recall"] for row in rows if row["recall"] is not None] + latencies = [row["latency_ms"] for row in rows if row["status"] == "ok"] + passed = all(row["status"] == "ok" and row["complete"] and + (row["recall"] is None or row["recall"] >= target_recall) for row in rows) + summaries.append({"requested_policy": policy, "repeat": repeat, "cohort": cohort, + "cases": len(rows), "failures": sum(row["status"] != "ok" for row in rows), + "incomplete": sum(not row["complete"] for row in rows), + "mean_recall": float(np.mean(recalls)) if recalls else None, + "min_recall": min(recalls) if recalls else None, + "latency_p50_ms": float(np.percentile(latencies, 50)) if latencies else None, + "latency_p95_ms": float(np.percentile(latencies, 95)) if latencies else None, + "all_queries_reach_target": passed}) + return {"schema_version": SCHEMA_VERSION, "bundle_id": bundle.bundle_id, + "target_recall": target_recall, + "expected_policies": policies, "expected_repeats": repeats, + "summaries": summaries, "queries": scored} + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__) + commands = parser.add_subparsers(dest="command", required=True) + prepare = commands.add_parser("prepare", help="make a deterministic synthetic bundle") + prepare.add_argument("--output", required=True) + prepare.add_argument("--documents", type=int, default=10000) + prepare.add_argument("--dimensions", type=int, default=128) + prepare.add_argument("--queries", type=int, default=32) + prepare.add_argument("--seed", type=int, default=20221) + prepare.add_argument("--metric", choices=("l2", "cosine"), default="cosine") + ingest = commands.add_parser("import", help="import original little-endian FP32 arrays") + ingest.add_argument("--output", required=True) + ingest.add_argument("--vectors", required=True) + ingest.add_argument("--queries", required=True) + ingest.add_argument("--format", choices=("raw", "fbin"), required=True) + ingest.add_argument("--documents", type=int, required=True) + ingest.add_argument("--query-count", type=int, required=True) + ingest.add_argument("--dimensions", type=int, required=True) + ingest.add_argument("--limit-documents", type=int) + ingest.add_argument("--limit-queries", type=int) + ingest.add_argument("--query-start", type=int, default=0, help="first source query row, for held-out splits") + ingest.add_argument("--metric", choices=("l2", "cosine"), required=True) + ingest.add_argument("--seed", type=int, default=20221) + ingest.add_argument("--source", required=True, help="source URL or immutable dataset identifier") + oracle = commands.add_parser("oracle", help="write untimed exhaustive filtered ground truth") + oracle.add_argument("bundle") + oracle.add_argument("--output") + score = commands.add_parser("score", help="validate and score every declared run/case") + score.add_argument("bundle") + score.add_argument("results") + score.add_argument("--oracle") + score.add_argument("--policies", nargs="+", required=True) + score.add_argument("--repeats", type=int, required=True, help="repeat IDs must be 0..N-1") + score.add_argument("--output", required=True) + score.add_argument("--target-recall", type=float, default=0.95) + score.add_argument("--fail-below-target", action="store_true") + args = parser.parse_args(argv) + if args.command == "prepare": + for field in ("documents", "dimensions", "queries"): + require_int(getattr(args, field), field, 1) + rng = np.random.default_rng(args.seed) + vectors = rng.standard_normal((args.documents, args.dimensions), dtype=np.float32) + queries = rng.standard_normal((args.queries, args.dimensions), dtype=np.float32) + bundle = write_bundle(args.output, vectors, queries, args.metric, args.seed, + {"source": "synthetic independent Gaussian FP32", "numpy_version": np.__version__}) + print(bundle.bundle_id) + elif args.command == "import": + vectors = read_matrix(args.vectors, args.format, args.documents, args.dimensions) + queries = read_matrix(args.queries, args.format, args.query_count, args.dimensions) + if Path(args.vectors).resolve() == Path(args.queries).resolve(): + raise ValueError("base and query arrays must be distinct source files") + for limit, count in ((args.limit_documents, args.documents), (args.limit_queries, args.query_count)): + if limit is not None and (require_int(limit, "limit", 1) > count): + raise ValueError("prefix limit exceeds source count") + require_int(args.query_start, "query_start") + query_stop = args.query_count if args.limit_queries is None else args.query_start + args.limit_queries + if args.query_start >= args.query_count or query_stop > args.query_count: + raise ValueError("query subset exceeds source count") + bundle = write_bundle(args.output, vectors[:args.limit_documents], queries[args.query_start:query_stop], + args.metric, args.seed, {"source": args.source, "format": args.format, + "base_sha256": sha256(args.vectors), "query_sha256": sha256(args.queries), + "source_document_count": args.documents, "source_query_count": args.query_count, + "document_subset": "fixed source prefix", "query_start": args.query_start, + "query_stop": query_stop, "numpy_version": np.__version__}) + print(bundle.bundle_id) + elif args.command == "oracle": + bundle = load_bundle(args.bundle) + write_oracle(bundle, args.output or Path(args.bundle) / "ground_truth.jsonl") + else: + bundle = load_bundle(args.bundle) + truth = load_oracle(bundle, args.oracle or Path(args.bundle) / "ground_truth.jsonl") + report = score_results(bundle, read_jsonl(args.results), truth, args.policies, args.repeats, + args.target_recall) + write_json(args.output, report) + if any(row["failures"] or row["incomplete"] for row in report["summaries"]): + return 1 + if args.fail_below_target and any(not row["all_queries_reach_target"] for row in report["summaries"]): + return 1 + return 0 + + +if __name__ == "__main__": + try: + sys.exit(main()) + except (ValueError, OSError, KeyError, TypeError) as error: + print(f"error: {error}", file=sys.stderr) + sys.exit(2) diff --git a/tests/benchmark/filtered/native_candidates.cpp b/tests/benchmark/filtered/native_candidates.cpp new file mode 100644 index 000000000..9dfa0f6e6 --- /dev/null +++ b/tests/benchmark/filtered/native_candidates.cpp @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2006-Present, Redis Ltd. + * All rights reserved. + * + * Licensed under your choice of the Redis Source Available License 2.0 + * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the + * GNU Affero General Public License v3 (AGPLv3). + */ +#include "native_candidates.h" + +#include +#include +#include +#include +#include +#include + +namespace filtered_bench { +namespace { + +bool nearer(const Neighbor &left, const Neighbor &right) { + return left.distance < right.distance || + (left.distance == right.distance && left.id < right.id); +} + +using TopK = std::priority_queue, decltype(&nearer)>; + +void offer(TopK &heap, Neighbor value, size_t k) { + if (!std::isfinite(value.distance)) { + throw std::runtime_error("VecSim returned a nonfinite distance"); + } + if (heap.size() < k) { + heap.push(value); + } else if (nearer(value, heap.top())) { + heap.pop(); + heap.push(value); + } +} + +void finish(SearchResult &result, TopK &heap, const Parameters ¶meters) { + if (Clock::now() >= parameters.deadline) { + result.status = "timeout"; + } + if (result.status != "ok") { + return; + } + result.neighbors.reserve(heap.size()); + while (!heap.empty()) { + result.neighbors.push_back(heap.top()); + heap.pop(); + } + std::reverse(result.neighbors.begin(), result.neighbors.end()); +} + +SearchResult scan(VecSimIndex *index, std::span query, const Eligibility &eligible, + size_t k, const Parameters ¶meters) { + SearchResult result; + result.distance_evaluations = 0; + if (eligible.ids.empty()) { + return result; + } + std::vector prepared(query.begin(), query.end()); + if (parameters.metric == VecSimMetric_Cosine) { + VecSim_Normalize(prepared.data(), prepared.size(), VecSimType_FLOAT32); + } + TopK heap(&nearer); + for (const uint64_t id : eligible.ids) { + if (*result.distance_evaluations % 64 == 0 && Clock::now() >= parameters.deadline) { + result.status = "timeout"; + break; + } + // The graph is immutable, single-value FP32, and these labels were validated. + double distance = VecSimIndex_GetDistanceFrom_Unsafe(index, id, prepared.data()); + ++*result.distance_evaluations; + offer(heap, {static_cast(id), distance}, k); + } + finish(result, heap, parameters); + return result; +} + +SearchResult batches(VecSimIndex *index, std::span query, const Eligibility &eligible, + size_t k, const Parameters ¶meters) { + SearchResult result; + result.candidates_returned = 0; + result.batches = 0; + const size_t target = std::min(k, eligible.ids.size()); + if (target == 0) { + return result; + } + auto deadline = parameters.deadline; + VecSimQueryParams runtime = {}; + runtime.hnswRuntimeParams.efRuntime = parameters.ef_runtime; + runtime.timeoutCtx = &deadline; + std::unique_ptr iterator( + VecSimBatchIterator_New(index, query.data(), &runtime), &VecSimBatchIterator_Free); + if (!iterator) { + throw std::runtime_error("VecSim could not create a batch iterator"); + } + TopK heap(&nearer); + std::unordered_set qualified; + while (heap.size() < target && VecSimBatchIterator_HasNext(iterator.get())) { + if (Clock::now() >= deadline) { + result.status = "timeout"; + break; + } + std::unique_ptr reply( + VecSimBatchIterator_Next(iterator.get(), parameters.batch_size, BY_SCORE), + &VecSimQueryReply_Free); + if (!reply) { + throw std::runtime_error("VecSim returned a null batch"); + } + ++*result.batches; + *result.candidates_returned += VecSimQueryReply_Len(reply.get()); + if (VecSimQueryReply_GetCode(reply.get()) == VecSim_QueryReply_TimedOut) { + result.status = "timeout"; + break; + } + if (VecSimQueryReply_GetCode(reply.get()) != VecSim_QueryReply_OK) { + throw std::runtime_error("VecSim returned an unexpected batch status"); + } + if (VecSimQueryReply_Len(reply.get()) == 0) { + if (VecSimBatchIterator_HasNext(iterator.get())) { + throw std::runtime_error("VecSim batch iterator made no progress"); + } + break; + } + std::unique_ptr items( + VecSimQueryReply_GetIterator(reply.get()), &VecSimQueryReply_IteratorFree); + while (VecSimQueryReply_IteratorHasNext(items.get())) { + const VecSimQueryResult *item = VecSimQueryReply_IteratorNext(items.get()); + const int64_t id = VecSimQueryResult_GetId(item); + if (id < 0 || static_cast(id) >= eligible.membership.size()) { + throw std::runtime_error("VecSim returned an out-of-range document label"); + } + if (eligible.membership[id] && qualified.insert(id).second) { + offer(heap, {static_cast(id), VecSimQueryResult_GetScore(item)}, target); + } + } + } + finish(result, heap, parameters); + return result; +} + +} // namespace + +int deadlineExpired(void *context) { + return context && Clock::now() >= *static_cast(context); +} + +std::vector candidateAdapters() { + return {{"NATIVE_SCAN", scan}, {"NATIVE_BATCHES", batches}}; +} + +} // namespace filtered_bench diff --git a/tests/benchmark/filtered/native_candidates.h b/tests/benchmark/filtered/native_candidates.h new file mode 100644 index 000000000..a3845b7ba --- /dev/null +++ b/tests/benchmark/filtered/native_candidates.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2006-Present, Redis Ltd. + * All rights reserved. + * + * Licensed under your choice of the Redis Source Available License 2.0 + * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the + * GNU Affero General Public License v3 (AGPLv3). + */ +#pragma once + +#include "VecSim/vec_sim.h" + +#include +#include +#include +#include +#include +#include + +namespace filtered_bench { + +using Clock = std::chrono::steady_clock; + +struct Eligibility { + std::span ids; + std::span membership; +}; + +struct Parameters { + size_t ef_runtime; + size_t batch_size; + VecSimMetric metric; + Clock::time_point deadline; +}; + +struct Neighbor { + size_t id; + double distance; +}; + +struct SearchResult { + std::vector neighbors; + std::string status = "ok"; + std::optional distance_evaluations; + std::optional candidates_returned; + std::optional batches; +}; + +// Adapters receive the same loaded graph and eligibility set. Query preprocessing, +// traversal, filtering, top-k selection, and adapter cleanup belong inside this call. +using SearchFunction = SearchResult (*)(VecSimIndex *, std::span, const Eligibility &, + size_t, const Parameters &); + +struct CandidateAdapter { + std::string name; + SearchFunction search; +}; + +// Register an implemented candidate here; a label alone is not an implementation. +std::vector candidateAdapters(); +int deadlineExpired(void *context); + +} // namespace filtered_bench diff --git a/tests/benchmark/filtered/native_main.cpp b/tests/benchmark/filtered/native_main.cpp new file mode 100644 index 000000000..09a6766d5 --- /dev/null +++ b/tests/benchmark/filtered/native_main.cpp @@ -0,0 +1,448 @@ +/* + * Copyright (c) 2006-Present, Redis Ltd. + * All rights reserved. + * + * Licensed under your choice of the Redis Source Available License 2.0 + * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the + * GNU Affero General Public License v3 (AGPLv3). + */ +#include "native_candidates.h" +#include "VecSim/algorithms/hnsw/hnsw_serializer.h" +#include "VecSim/index_factories/hnsw_factory.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace filtered_bench; +namespace fs = std::filesystem; + +namespace { + +using Index = std::unique_ptr; + +void logToStderr(void *, const char *level, const char *message) { + std::cerr << "VecSim [" << (level ? level : "unknown") << "]: " << (message ? message : "") + << '\n'; +} + +std::string jsonString(std::string_view value) { + std::ostringstream output; + output << '"'; + for (const unsigned char ch : value) { + if (ch == '"' || ch == '\\') { + output << '\\' << ch; + } else if (ch < 32) { + output << "\\u" << std::hex << std::setw(4) << std::setfill('0') << int(ch) << std::dec; + } else { + output << ch; + } + } + output << '"'; + return output.str(); +} + +size_t unsignedValue(std::string_view text, bool allow_zero = false) { + size_t value = 0; + auto [end, error] = std::from_chars(text.data(), text.data() + text.size(), value); + if (error != std::errc() || end != text.data() + text.size() || (!allow_zero && value == 0)) { + throw std::runtime_error("Invalid unsigned integer: " + std::string(text)); + } + return value; +} + +class Arguments { + std::map values; + +public: + Arguments(int argc, char **argv, const std::set &allowed) { + for (int i = 2; i < argc; i += 2) { + if (i + 1 == argc || !allowed.contains(argv[i]) || + !values.emplace(argv[i], argv[i + 1]).second) { + throw std::runtime_error("Unknown, duplicate, or incomplete argument: " + + std::string(argv[i])); + } + } + } + const std::string &get(const std::string &name) const { + auto value = values.find(name); + if (value == values.end()) { + throw std::runtime_error("Missing argument: " + name); + } + return value->second; + } + size_t number(const std::string &name) const { return unsignedValue(get(name)); } +}; + +size_t product(size_t a, size_t b) { + if (b && a > std::numeric_limits::max() / b) { + throw std::runtime_error("Input size overflow"); + } + return a * b; +} + +template +std::vector readArray(const fs::path &path, size_t expected_count) { + size_t bytes = product(expected_count, sizeof(T)); + if (fs::file_size(path) != bytes || + bytes > size_t(std::numeric_limits::max())) { + throw std::runtime_error("Wrong payload length: " + path.string()); + } + std::vector values(expected_count); + std::ifstream input(path, std::ios::binary); + input.exceptions(std::ios::badbit | std::ios::failbit); + if (bytes) { + input.read(reinterpret_cast(values.data()), bytes); + } + return values; +} + +VecSimMetric parseMetric(const std::string &metric) { + if (metric == "cosine") { + return VecSimMetric_Cosine; + } + if (metric == "l2") { + return VecSimMetric_L2; + } + throw std::runtime_error("Metric must be cosine or l2"); +} + +void validateVectors(std::span vectors, size_t dim, VecSimMetric metric) { + for (size_t begin = 0; begin < vectors.size(); begin += dim) { + double norm_squared = 0; + for (size_t j = 0; j < dim; ++j) { + float value = vectors[begin + j]; + if (!std::isfinite(value)) { + throw std::runtime_error("Nonfinite vector component"); + } + norm_squared += double(value) * value; + } + if (metric == VecSimMetric_Cosine && norm_squared == 0) { + throw std::runtime_error("Zero-norm cosine vector"); + } + } +} + +double elapsedMs(Clock::time_point begin) { + return std::chrono::duration(Clock::now() - begin).count(); +} + +void provenance(std::ostream &output) { + output << "\"compiler\":" << jsonString(__VERSION__) + << ",\"build_type\":" << jsonString(FILTERED_BUILD_TYPE) + << ",\"source_revision\":" << jsonString(FILTERED_SOURCE_REVISION) + << ",\"source_dirty\":" << FILTERED_SOURCE_DIRTY + << ",\"shared_memory_bytes\":" << VecSim_GetSharedMemory() + << ",\"write_mode\":\"in_place\""; +} + +void validateIndex(VecSimIndex *index, size_t documents, size_t dimensions, VecSimMetric metric) { + if (!index) { + throw std::runtime_error("Failed to construct or load HNSW index"); + } + auto info = VecSimIndex_BasicInfo(index); + if (info.algo != VecSimAlgo_HNSWLIB || info.type != VecSimType_FLOAT32 || info.isMulti || + info.isTiered || info.isDisk || info.dim != dimensions || info.metric != metric || + VecSimIndex_IndexSize(index) != documents) { + throw std::runtime_error( + "Graph metadata does not match the requested FP32 single HNSW index"); + } + auto *typed = dynamic_cast *>(index); + if (!typed || typed->usesQuantizedStorage()) { + throw std::runtime_error("The native baselines require unquantized FP32 storage"); + } +} + +void build(int argc, char **argv) { + Arguments args(argc, argv, + {"--vectors", "--documents", "--dimensions", "--metric", "--graph", "--m", + "--ef-construction"}); + const size_t documents = args.number("--documents"); + if (documents >= std::numeric_limits::max()) { + throw std::runtime_error("Document count exceeds the HNSW internal ID range"); + } + const size_t dimensions = args.number("--dimensions"); + const auto metric = parseMetric(args.get("--metric")); + const fs::path graph(args.get("--graph")); + if (fs::exists(graph)) { + throw std::runtime_error("Refusing to overwrite a graph"); + } + const size_t m = args.number("--m"); + if (m < 2 || m > std::numeric_limits::max() / 2) { + throw std::runtime_error("M must be between 2 and 32767 (the HNSW link count limit)"); + } + auto vectors = readArray(args.get("--vectors"), product(documents, dimensions)); + validateVectors(vectors, dimensions, metric); + VecSimParams params = {}; + params.algo = VecSimAlgo_HNSWLIB; + auto &hnsw = params.algoParams.hnswParams; + hnsw.type = VecSimType_FLOAT32; + hnsw.dim = dimensions; + hnsw.metric = metric; + hnsw.M = m; + hnsw.efConstruction = args.number("--ef-construction"); + hnsw.efRuntime = 10; + auto begin = Clock::now(); + Index index(VecSimIndex_New(¶ms), &VecSimIndex_Free); + if (!index) { + throw std::runtime_error("Failed to create HNSW index"); + } + for (size_t id = 0; id < documents; ++id) { + if (VecSimIndex_AddVector(index.get(), vectors.data() + id * dimensions, id) != 1) { + throw std::runtime_error("Failed to insert a new vector"); + } + } + double build_ms = elapsedMs(begin); + validateIndex(index.get(), documents, dimensions, metric); + auto *serializer = dynamic_cast(index.get()); + if (!serializer) { + throw std::runtime_error("HNSW serialization helpers are unavailable"); + } + begin = Clock::now(); + serializer->saveIndex(graph.string()); + const double serialization_ms = elapsedMs(begin); + if (!fs::is_regular_file(graph) || fs::file_size(graph) == 0) { + throw std::runtime_error("Could not write graph snapshot"); + } + std::cout << std::setprecision(17) << '{'; + provenance(std::cout); + std::cout << ",\"build_ms\":" << build_ms << ",\"serialization_ms\":" << serialization_ms + << ",\"index_bytes\":" << VecSimIndex_StatsInfo(index.get()).memory << "}\n"; +} + +struct Case { + size_t id; + size_t query; + size_t k; + size_t offset; + size_t count; +}; + +std::vector readCases(const std::string &path, std::span filters, + size_t query_count, size_t documents) { + std::ifstream input(path); + if (!input) { + throw std::runtime_error("Could not open cases"); + } + std::vector cases; + std::set ids; + std::string line; + while (std::getline(input, line)) { + std::istringstream fields(line); + std::vector words; + for (std::string word; fields >> word;) { + words.push_back(word); + } + if (words.size() != 5) { + throw std::runtime_error("Each case needs five numeric fields"); + } + Case c{unsignedValue(words[0], true), unsignedValue(words[1], true), + unsignedValue(words[2]), unsignedValue(words[3], true), + unsignedValue(words[4], true)}; + if (c.query >= query_count || c.offset > filters.size() || + c.count > filters.size() - c.offset || !ids.insert(c.id).second) { + throw std::runtime_error("Invalid query, filter slice, or duplicate case ID"); + } + auto eligible = filters.subspan(c.offset, c.count); + for (size_t i = 0; i < eligible.size(); ++i) { + if (eligible[i] >= documents || (i && eligible[i] <= eligible[i - 1])) { + throw std::runtime_error("Eligible IDs must be sorted, unique, and in range"); + } + } + cases.push_back(c); + } + if (!input.eof() || cases.empty()) { + throw std::runtime_error("Empty or unreadable cases file"); + } + return cases; +} + +std::vector selectAdapters(const std::string &policies) { + const auto registered = candidateAdapters(); + std::vector selected; + std::set names; + std::istringstream input(policies); + for (std::string name; std::getline(input, name, ',');) { + auto found = std::find_if(registered.begin(), registered.end(), + [&](const auto &adapter) { return adapter.name == name; }); + if (found == registered.end() || !names.insert(name).second) { + throw std::runtime_error("Unknown or repeated candidate policy: " + name); + } + selected.push_back(*found); + } + if (selected.empty() || policies.back() == ',') { + throw std::runtime_error("Empty candidate policy"); + } + return selected; +} + +void optionalCount(std::ostream &output, std::optional value) { + if (value) { + output << *value; + } else { + output << "null"; + } +} + +void emit(std::ostream &output, const Case &c, size_t repeat, const std::string &policy, + const SearchResult &result, double latency_ms, const std::string &error) { + output << std::setprecision(17) << "{\"case_index\":" << c.id << ",\"repeat\":" << repeat + << ",\"requested_policy\":" << jsonString(policy) + << ",\"effective_policy\":" << jsonString(policy) + << ",\"status\":" << jsonString(result.status) << ",\"ids\":["; + for (size_t i = 0; i < result.neighbors.size(); ++i) { + output << (i ? "," : "") << result.neighbors[i].id; + } + output << "],\"distances\":["; + for (size_t i = 0; i < result.neighbors.size(); ++i) { + output << (i ? "," : "") << result.neighbors[i].distance; + } + output << "],\"latency_ms\":" << latency_ms << ",\"counters\":{\"distance_evaluations\":"; + optionalCount(output, result.distance_evaluations); + output << ",\"candidates_returned\":"; + optionalCount(output, result.candidates_returned); + output << ",\"batches\":"; + optionalCount(output, result.batches); + output << '}'; + if (!error.empty()) { + output << ",\"error\":" << jsonString(error); + } + output << "}\n"; +} + +void run(int argc, char **argv) { + Arguments args(argc, argv, + {"--queries", "--query-count", "--documents", "--dimensions", "--metric", + "--graph", "--filters", "--cases", "--output", "--policies", "--repeats", + "--ef-runtime", "--batch-size", "--timeout-ms"}); + const size_t documents = args.number("--documents"); + if (documents >= std::numeric_limits::max()) { + throw std::runtime_error("Document count exceeds the HNSW internal ID range"); + } + const size_t dimensions = args.number("--dimensions"); + const size_t query_count = args.number("--query-count"); + const auto metric = parseMetric(args.get("--metric")); + const size_t repeats = args.number("--repeats"); + const size_t timeout_ms = args.number("--timeout-ms"); + if (timeout_ms > 86400000) { + throw std::runtime_error("Per-query timeout must not exceed one day"); + } + Parameters parameters{args.number("--ef-runtime"), args.number("--batch-size"), metric, {}}; + auto adapters = selectAdapters(args.get("--policies")); + const fs::path output_path(args.get("--output")); + if (fs::exists(output_path)) { + throw std::runtime_error("Refusing to overwrite results"); + } + auto queries = readArray(args.get("--queries"), product(query_count, dimensions)); + validateVectors(queries, dimensions, metric); + const auto filter_bytes = fs::file_size(args.get("--filters")); + if (filter_bytes % sizeof(uint64_t)) { + throw std::runtime_error("Filter payload is not a uint64 array"); + } + auto filters = readArray(args.get("--filters"), filter_bytes / sizeof(uint64_t)); + auto cases = readCases(args.get("--cases"), filters, query_count, documents); + auto begin = Clock::now(); + Index index(HNSWFactory::NewIndex(args.get("--graph")), &VecSimIndex_Free); + const double load_ms = elapsedMs(begin); + validateIndex(index.get(), documents, dimensions, metric); + VecSim_SetTimeoutCallbackFunction(deadlineExpired); + std::ofstream output(output_path); + output.exceptions(std::ios::badbit | std::ios::failbit); + std::vector membership(documents, 0); + for (size_t repeat = 0; repeat < repeats; ++repeat) { + for (const auto &c : cases) { + const auto ids = std::span(filters).subspan(c.offset, c.count); + for (uint64_t id : ids) { + membership[id] = 1; + } + const Eligibility eligible{ids, membership}; + const auto query = + std::span(queries).subspan(c.query * dimensions, dimensions); + for (size_t offset = 0; offset < adapters.size(); ++offset) { + const auto &adapter = adapters[(repeat + offset) % adapters.size()]; + SearchResult result; + std::string error; + begin = Clock::now(); + parameters.deadline = begin + std::chrono::milliseconds(timeout_ms); + try { + result = adapter.search(index.get(), query, eligible, c.k, parameters); + } catch (const std::exception &exception) { + result = {}; + result.status = "error"; + error = exception.what(); + } + const double latency_ms = elapsedMs(begin); + if (result.status == "ok" && Clock::now() >= parameters.deadline) { + result.status = "timeout"; + result.neighbors.clear(); + } + emit(output, c, repeat, adapter.name, result, latency_ms, error); + } + for (uint64_t id : ids) { + membership[id] = 0; + } + } + } + output.close(); + std::cout << std::setprecision(17) << '{'; + provenance(std::cout); + std::cout << ",\"load_ms\":" << load_ms + << ",\"index_bytes\":" << VecSimIndex_StatsInfo(index.get()).memory + << ",\"timing_scope\":\"candidate call including query preparation, traversal, " + "filtering, top-k selection and cleanup; excludes graph load, eligibility setup " + "and output serialization\",\"filter_setup_scope\":\"one dense byte membership " + "array reused across cases; populate and clear outside timed calls\"}\n"; +} + +void describe() { + std::cout << '{'; + provenance(std::cout); + std::cout << ",\"policies\":["; + bool first = true; + for (const auto &adapter : candidateAdapters()) { + std::cout << (first ? "" : ",") << jsonString(adapter.name); + first = false; + } + std::cout << "]}\n"; +} + +} // namespace + +int main(int argc, char **argv) { + try { + VecSim_SetLogCallbackFunction(logToStderr); + VecSim_UpdateThreadPoolSize(0); + if constexpr (std::endian::native != std::endian::little) { + throw std::runtime_error("The native runner currently requires a little-endian host"); + } + if (argc < 2) { + throw std::runtime_error("Expected build, run, or describe command"); + } + const std::string command(argv[1]); + if (command == "build") { + build(argc, argv); + } else if (command == "run") { + run(argc, argv); + } else if (command == "describe" && argc == 2) { + describe(); + } else { + throw std::runtime_error("Expected build, run, or describe command"); + } + return 0; + } catch (const std::exception &error) { + std::cerr << "native_filtered_bench: " << error.what() << '\n'; + return 1; + } +} diff --git a/tests/benchmark/filtered/native_run.py b/tests/benchmark/filtered/native_run.py new file mode 100644 index 000000000..89d6f6dd1 --- /dev/null +++ b/tests/benchmark/filtered/native_run.py @@ -0,0 +1,299 @@ +#!/usr/bin/env python3 +# Copyright (c) 2006-Present, Redis Ltd. +# All rights reserved. +# +# Licensed under your choice of the Redis Source Available License 2.0 +# (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the +# GNU Affero General Public License v3 (AGPLv3). + +"""Validate frozen artifacts and drive the native VecSim filtered-search executable.""" + +import argparse +from datetime import datetime, timezone +import hashlib +import json +import math +import os +from pathlib import Path +import platform +import re +import subprocess +import sys +import time + +import numpy as np + +import filtered_bench as bench + + +GRAPH_SCHEMA_VERSION = 1 +DEFAULT_POLICIES = ["NATIVE_SCAN", "NATIVE_BATCHES"] + + +def positive_int(value): + number = int(value) + if number <= 0: + raise argparse.ArgumentTypeError("must be a positive integer") + return number + + +def checkout_context(): + """The working checkout is context, not proof of which source built a binary.""" + root = Path(__file__).resolve().parents[3] + try: + revision = subprocess.check_output( + ["git", "-C", str(root), "rev-parse", "HEAD"], text=True, + stderr=subprocess.DEVNULL).strip() + dirty = bool(subprocess.check_output( + ["git", "-C", str(root), "status", "--porcelain"], text=True, + stderr=subprocess.DEVNULL).strip()) + tracked_diff = subprocess.check_output( + ["git", "-C", str(root), "diff", "HEAD", "--binary"], stderr=subprocess.DEVNULL) + return {"path": str(root), "revision": revision, "dirty": dirty, + "tracked_diff_sha256": hashlib.sha256(tracked_diff).hexdigest(), + "diff_note": "tracked diff only; untracked files contribute to dirty status but not this hash"} + except (OSError, subprocess.CalledProcessError): + return {"path": str(root), "revision": None, "dirty": None} + + +def binary_description(binary): + completed = subprocess.run([str(binary), "describe"], capture_output=True, text=True, + check=True, timeout=30) + description = json.loads(completed.stdout) + policies = description.get("policies") if isinstance(description, dict) else None + if not isinstance(policies, list) or not policies or any( + not isinstance(label, str) or not re.fullmatch(r"[A-Z][A-Z0-9_]*", label) + for label in policies) or len(set(policies)) != len(policies): + raise ValueError("native describe must report distinct policy labels") + return description + + +def corpus_identity(bundle): + return {key: bundle.manifest[key] for key in + ("dtype", "metric", "dimensions", "document_count")} | { + "vectors_sha256": bundle.manifest["files"]["vectors.f32"]} + + +def validate_graph(directory, bundle): + directory = Path(directory).resolve() + graph = directory / "graph.hnsw" + metadata = bench.read_json(directory / "graph.json") + if not isinstance(metadata, dict) or type(metadata.get("schema_version")) is not int or metadata["schema_version"] != GRAPH_SCHEMA_VERSION: + raise ValueError("unsupported native graph sidecar schema") + if metadata.get("graph_file") != "graph.hnsw" or graph.is_symlink(): + raise ValueError("graph sidecar must name a regular graph.hnsw file") + if metadata.get("corpus") != corpus_identity(bundle): + raise ValueError("graph corpus does not match the bundle vectors, metric, or shape") + construction = metadata.get("construction") + if not isinstance(construction, dict): + raise ValueError("graph sidecar lacks construction parameters") + bench.require_int(construction.get("m"), "graph m", 2) + bench.require_int(construction.get("ef_construction"), "graph ef_construction", 1) + if construction.get("insertion_order") != "ascending_external_id": + raise ValueError("unsupported graph insertion order") + if metadata.get("graph_sha256") != bench.sha256(graph): + raise ValueError("native graph checksum mismatch") + return graph, metadata + + +def write_native_inputs(bundle, output): + offsets = {} + position = 0 + with (output / "filters.u64").open("xb") as target: + for name, ids in bundle.filters.items(): + offsets[name] = (position, len(ids)) + np.asarray(ids, dtype="= len(bundle.cases) or repeat >= repeats: + raise ValueError("native case/repeat is out of range") + policy = row.get("requested_policy") + if policy not in policies or row.get("effective_policy") != policy: + raise ValueError("native result policy does not match its registered adapter") + key = (index, repeat, policy) + if key in seen: + raise ValueError("duplicate native result") + seen.add(key) + if row.get("status") not in ("ok", "error", "timeout"): + raise ValueError("invalid native result status") + latency = row.get("latency_ms") + if isinstance(latency, bool) or not isinstance(latency, (int, float)) or not math.isfinite(latency) or latency < 0: + raise ValueError("native latency must be finite and nonnegative") + case = bundle.cases[index] + ids, distances = row.get("ids"), row.get("distances") + if not isinstance(ids, list) or not isinstance(distances, list) or len(ids) != len(distances) or len(ids) > case["k"]: + raise ValueError("native IDs/distances have invalid lengths") + eligible = set(bundle.filters[case["filter_id"]]) + if any(type(doc_id) is not int or doc_id not in eligible for doc_id in ids) or len(set(ids)) != len(ids): + raise ValueError("native IDs must be distinct eligible document IDs") + if any(isinstance(distance, bool) or not isinstance(distance, (int, float)) or not math.isfinite(distance) + for distance in distances): + raise ValueError("native distances must be finite") + counters = row.get("counters") + if not isinstance(counters, dict) or any(value is not None and + (type(value) is not int or value < 0) for value in counters.values()): + raise ValueError("native counters must be nonnegative integers or null") + converted = {key: row[key] for key in ("repeat", "requested_policy", "effective_policy", + "status", "ids", "distances", "latency_ms", "counters")} + if "error" in row: + if not isinstance(row["error"], str): + raise ValueError("native error must be a string") + converted["error"] = row["error"] + converted.update(bundle_id=bundle.bundle_id, case_id=case["case_id"]) + rows.append(converted) + if len(seen) != len(bundle.cases) * len(policies) * repeats: + raise ValueError("native results do not cover the complete case/policy/repeat matrix") + return rows + + +def invoke_native(command, output, timeout): + started = time.monotonic() + with (output / "native.stdout").open("x", encoding="utf-8") as stdout, \ + (output / "native.stderr").open("x", encoding="utf-8") as stderr: + subprocess.run(command, stdout=stdout, stderr=stderr, timeout=timeout, check=True) + elapsed = time.monotonic() - started + metadata = bench.read_json(output / "native.stdout") + if not isinstance(metadata, dict): + raise ValueError("native executable must return a JSON metadata object") + return metadata, elapsed + + +def execute(args): + bundle_root = Path(args.bundle).resolve() + bundle = bench.load_bundle(bundle_root) + binary = Path(args.binary).resolve(strict=True) + binary_hash = bench.sha256(binary) + description = binary_description(binary) + output = Path(args.output).resolve() + graph, graph_metadata = None, None + if args.command == "run": + if len(set(args.policies)) != len(args.policies) or any( + label not in description["policies"] for label in args.policies): + raise ValueError(f"choose distinct policies registered by this binary: {description['policies']}") + graph, graph_metadata = validate_graph(args.graph, bundle) + elif not 2 <= args.m <= 32767: + raise ValueError("HNSW m must be between 2 and 32767") + output.mkdir(parents=True, exist_ok=False) + metadata = { + "schema_version": 1, "command": args.command, "status": "failed", + "created_at": datetime.now(timezone.utc).isoformat(), + "bundle_id": bundle.bundle_id, "bundle": str(bundle_root), + "binary": str(binary), "binary_sha256": binary_hash, + "binary_description": description, + "binary_source_note": "source_revision/source_dirty reported by the binary are configure-time metadata; binary_sha256 identifies the executable", + "wrapper_checkout": checkout_context(), + "host": {"platform": platform.platform(), "machine": platform.machine(), + "processor": platform.processor(), "logical_cpus": os.cpu_count()}, + "process_timeout_seconds": args.process_timeout_seconds, + } + command = [str(binary), args.command, "--dimensions", str(bundle.manifest["dimensions"]), + "--documents", str(bundle.manifest["document_count"]), + "--metric", bundle.manifest["metric"]] + result_code = 0 + try: + if args.command == "build": + graph = output / "graph.hnsw" + construction = {"m": args.m, "ef_construction": args.ef_construction, + "insertion_order": "ascending_external_id"} + metadata["construction"] = construction + command += ["--vectors", str(bundle_root / "vectors.f32"), "--graph", str(graph), + "--m", str(args.m), "--ef-construction", str(args.ef_construction)] + else: + write_native_inputs(bundle, output) + metadata.update(graph_sha256=graph_metadata["graph_sha256"], graph=str(graph), + graph_metadata=graph_metadata, + policies=args.policies, repeats=args.repeats, ef_runtime=args.ef_runtime, + batch_size=args.batch_size, timeout_ms=args.timeout_ms, + input_checksums={name: bench.sha256(output / name) + for name in ("filters.u64", "cases.tsv")}) + command += ["--graph", str(graph), "--queries", str(bundle_root / "queries.f32"), + "--query-count", str(bundle.manifest["query_count"]), + "--filters", str(output / "filters.u64"), "--cases", str(output / "cases.tsv"), + "--output", str(output / "native-results.jsonl"), + "--policies", ",".join(args.policies), "--repeats", str(args.repeats), + "--ef-runtime", str(args.ef_runtime), "--batch-size", str(args.batch_size), + "--timeout-ms", str(args.timeout_ms)] + metadata["native_command"] = command + native, elapsed = invoke_native(command, output, args.process_timeout_seconds) + metadata.update(native=native, subprocess_wall_seconds=elapsed) + if bench.sha256(binary) != binary_hash: + raise ValueError("native binary changed during execution") + if args.command == "build": + if bench.sha256(bundle_root / "vectors.f32") != corpus_identity(bundle)["vectors_sha256"]: + raise ValueError("bundle vectors changed during graph construction") + graph_metadata = { + "schema_version": GRAPH_SCHEMA_VERSION, "graph_file": "graph.hnsw", + "graph_sha256": bench.sha256(graph), "creator_bundle_id": bundle.bundle_id, + "corpus": corpus_identity(bundle), "construction": construction, + "creator_binary_sha256": binary_hash, "native_build": native, + "trusted_input_only": True, + } + bench.write_json(output / "graph.json", graph_metadata) + metadata["graph_sha256"] = graph_metadata["graph_sha256"] + else: + if bench.sha256(graph) != graph_metadata["graph_sha256"]: + raise ValueError("native graph changed during search") + if bench.sha256(bundle_root / "queries.f32") != bundle.manifest["files"]["queries.f32"]: + raise ValueError("bundle queries changed during search") + rows = convert_results(bundle, output / "native-results.jsonl", args.policies, args.repeats) + with (output / "results.jsonl").open("x", encoding="utf-8") as target: + for row in rows: + target.write(json.dumps(row, allow_nan=False) + "\n") + cases = {case["case_id"]: case for case in bundle.cases} + incomplete = sum(len(row["ids"]) != min(cases[row["case_id"]]["k"], + len(bundle.filters[cases[row["case_id"]]["filter_id"]])) for row in rows) + failures = sum(row["status"] != "ok" for row in rows) + metadata.update(result_count=len(rows), failure_count=failures, incomplete_count=incomplete, + results_sha256=bench.sha256(output / "results.jsonl")) + if failures or incomplete: + result_code = 1 + metadata["status"] = "completed" if result_code == 0 else "completed_with_failures" + except Exception as error: + metadata["error"] = f"{type(error).__name__}: {error}" + raise + finally: + bench.write_json(output / ("build.json" if args.command == "build" else "run.json"), metadata) + return result_code + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__) + subcommands = parser.add_subparsers(dest="command", required=True) + for name in ("build", "run"): + command = subcommands.add_parser(name) + command.add_argument("--bundle", required=True) + command.add_argument("--binary", required=True) + command.add_argument("--output", required=True) + command.add_argument("--process-timeout-seconds", type=positive_int, default=3600) + if name == "build": + command.add_argument("--m", type=positive_int, default=16) + command.add_argument("--ef-construction", type=positive_int, default=200) + else: + command.add_argument("--graph", required=True) + command.add_argument("--policies", nargs="+", default=DEFAULT_POLICIES) + command.add_argument("--repeats", type=positive_int, default=3) + command.add_argument("--ef-runtime", type=positive_int, default=200) + command.add_argument("--batch-size", type=positive_int, default=100) + command.add_argument("--timeout-ms", type=positive_int, default=10000) + args = parser.parse_args(argv) + try: + return execute(args) + except (OSError, ValueError, subprocess.SubprocessError) as error: + print(f"native benchmark failed: {error}", file=sys.stderr) + return 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/benchmark/filtered/native_test.cpp b/tests/benchmark/filtered/native_test.cpp new file mode 100644 index 000000000..ca87b4205 --- /dev/null +++ b/tests/benchmark/filtered/native_test.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2006-Present, Redis Ltd. + * All rights reserved. + * + * Licensed under your choice of the Redis Source Available License 2.0 + * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the + * GNU Affero General Public License v3 (AGPLv3). + */ +#include "native_candidates.h" + +#include +#include +#include +#include +#include +#include + +using namespace filtered_bench; + +namespace { + +size_t timeout_callback_calls = 0; + +int forceTimeout(void *) { + ++timeout_callback_calls; + return 1; +} + +struct RestoreTimeoutCallback { + ~RestoreTimeoutCallback() { VecSim_SetTimeoutCallbackFunction(deadlineExpired); } +}; + +void check(bool condition, const std::string &message) { + if (!condition) { + throw std::runtime_error(message); + } +} + +SearchFunction adapter(const std::string &name) { + for (const auto &candidate : candidateAdapters()) { + if (candidate.name == name) { + return candidate.search; + } + } + throw std::runtime_error("Missing native adapter: " + name); +} + +void checkRecovered(const SearchResult &result, const std::string &name) { + check(result.status == "ok", name + " did not recover after timeout"); + check(result.neighbors.size() == 3, name + " returned the wrong number of neighbors"); + for (size_t i = 0; i < result.neighbors.size(); ++i) { + const size_t expected_id = 2 * i; + check(result.neighbors[i].id == expected_id, + name + " returned the wrong eligible neighbor after timeout"); + check(std::isfinite(result.neighbors[i].distance) && + result.neighbors[i].distance == double(expected_id * expected_id), + name + " returned the wrong distance after timeout"); + } +} + +void testTimeoutsAndRecovery() { + constexpr size_t documents = 40; + constexpr size_t dimensions = 2; + VecSimParams params = {}; + params.algo = VecSimAlgo_HNSWLIB; + auto &hnsw = params.algoParams.hnswParams; + hnsw.type = VecSimType_FLOAT32; + hnsw.dim = dimensions; + hnsw.metric = VecSimMetric_L2; + hnsw.M = 8; + hnsw.efConstruction = documents; + hnsw.efRuntime = documents; + std::unique_ptr index(VecSimIndex_New(¶ms), + &VecSimIndex_Free); + check(bool(index), "Could not create the test HNSW index"); + std::vector eligible_ids; + std::vector membership(documents, 0); + for (size_t id = 0; id < documents; ++id) { + const std::array vector{float(id), 0.0f}; + check(VecSimIndex_AddVector(index.get(), vector.data(), id) == 1, + "Could not insert a test vector"); + if (id % 2 == 0) { + eligible_ids.push_back(id); + membership[id] = 1; + } + } + const Eligibility eligible{eligible_ids, membership}; + const std::array query{0.0f, 0.0f}; + const auto scan = adapter("NATIVE_SCAN"); + const auto batches = adapter("NATIVE_BATCHES"); + Parameters runtime{documents, 4, VecSimMetric_L2, Clock::now() - std::chrono::seconds(1)}; + VecSim_SetTimeoutCallbackFunction(deadlineExpired); + const auto expired_scan = scan(index.get(), query, eligible, 3, runtime); + check(expired_scan.status == "timeout" && expired_scan.neighbors.empty(), + "An expired scan deadline must return timeout with no results"); + check(expired_scan.distance_evaluations == 0, + "An already expired scan must not calculate distances"); + + // Keep the runner's deadline in the future so this exercises a VecSim reply + // timeout, rather than the adapter's own pre-batch deadline check. + runtime.deadline = Clock::now() + std::chrono::hours(1); + SearchResult timed_out_batch; + { + RestoreTimeoutCallback restore; + VecSim_SetTimeoutCallbackFunction(forceTimeout); + timed_out_batch = batches(index.get(), query, eligible, 3, runtime); + } + check(timeout_callback_calls > 0, "The forced VecSim timeout callback was not called"); + check(timed_out_batch.batches == 1, "Expected a timeout from the first actual VecSim batch"); + check(timed_out_batch.status == "timeout" && timed_out_batch.neighbors.empty(), + "A VecSim batch timeout must return timeout with no results"); + + runtime.deadline = Clock::now() + std::chrono::hours(1); + checkRecovered(scan(index.get(), query, eligible, 3, runtime), "NATIVE_SCAN"); + checkRecovered(batches(index.get(), query, eligible, 3, runtime), "NATIVE_BATCHES"); +} + +} // namespace + +int main() { + try { + VecSim_UpdateThreadPoolSize(0); +#if !HAVE_SVS + check(VecSim_GetSharedMemory() == 0, "SVS-disabled builds must have no shared SVS memory"); + VecSim_UpdateThreadPoolSize(1); + check(VecSim_GetSharedMemory() == 0, "Resizing an absent SVS pool must allocate no memory"); + VecSim_UpdateThreadPoolSize(0); +#endif + testTimeoutsAndRecovery(); + std::cout << "Native adapter timeout and recovery tests passed\n"; + return 0; + } catch (const std::exception &error) { + std::cerr << "Native adapter test failure: " << error.what() << '\n'; + return 1; + } +} diff --git a/tests/benchmark/filtered/requirements.txt b/tests/benchmark/filtered/requirements.txt new file mode 100644 index 000000000..a86682aff --- /dev/null +++ b/tests/benchmark/filtered/requirements.txt @@ -0,0 +1,68 @@ +# Requires Python >=3.12. Wheel hashes from the official PyPI release JSON. +# Regenerate together in both benchmark repositories when upgrading dependencies. +numpy==2.5.4 \ + --hash=sha256:067374eb538c34c745436365cf7b0112595c1d326f21ce4ff340f61230239fbb \ + --hash=sha256:0b4724a19de67bea8cfc4970798efa78bcbbe2ac2613cfac16721a42d44de2a5 \ + --hash=sha256:0f02a46e49cfb6c73bdb7aea1c0d3461dbae9aba613542b65f657cd3d17b9fab \ + --hash=sha256:1c2e71b04c6cad90026e544501bbe0ab9290fa8a4d845e7e8c0d124fb429c988 \ + --hash=sha256:1ef3aa6d7e29bb13677323114280b05acc57607fa2300e66432d665d5418a162 \ + --hash=sha256:2132418bf8dd124a427ca9e6a1daf9ee1a87185344c95119ceae868b99466da1 \ + --hash=sha256:2199ed071f460487c8db2c0e5c0b564494190edb4772fe80f9aad88b2604def5 \ + --hash=sha256:2377da2dd3ba2c1200956acbab2a358c83b8e1f8531191672d1cd6ad83250d53 \ + --hash=sha256:298eca75243f2cbbfdb460560b9fb2a1792a33cf2ab4286efd43d92e8d3df508 \ + --hash=sha256:2c2c4afffdeb7920e445028dd71eb932cac3e704792e964bc2a232426d4f1255 \ + --hash=sha256:2ca144f15135b6212a5c47b1e2aeca6e412f102f95a2d5d88d8aec77eb255de3 \ + --hash=sha256:2fa3328f784fc8277fc48026f6cad516f5c561c5d8e2e39b3c9e0c8f23223b34 \ + --hash=sha256:325518d4245b9e331387702aa58c2ce1dc4cdcbb41dfb4ccd5dcbc7e08db1266 \ + --hash=sha256:332f3378fe077dd850e677ec01bdcc4f22368fb5d50ef10b2c79230b1bf5a592 \ + --hash=sha256:3573cd22564692a5b899ec344e5d5b9cc4576f2985b96f22af3564ed54f2710f \ + --hash=sha256:381a7a3d2e65e64c0ec302795ab9dc12bb1e73f150904699c153716177eebdaf \ + --hash=sha256:38f47be9f74ab870d2633b5456ae519c43758a8d1fd05342f0ce4ecc034396ee \ + --hash=sha256:4054173604cd8658796053f1f3bc0befb68ec1c0762c57fdad61e199256a8617 \ + --hash=sha256:468397ba3c64427474706e5c9123fe266395496714dc684294eac75cd4930d1e \ + --hash=sha256:4e263278bfb5ee6409db8aedbc4cc32973b1b82bc1e8d3c668551d04d83a7e37 \ + --hash=sha256:5258bc06526964be5face2fc6f756857a3f24f21ec3e72ca131337a75b165d6c \ + --hash=sha256:56733449d2544178beaa4545cee357370440cf056c197f9c7bfb19dbfdd0e86d \ + --hash=sha256:5ec3753760c1a6d8bb91200666e545c3a9728e6269dfb5d6ce02340996698aa3 \ + --hash=sha256:5fbf7141bbfd63aea22f435c9062a032b9ea0082fe9845dad7f021d3f1234e71 \ + --hash=sha256:64d1c8ac28a4077cf987e0a71a7a0ef7e2df70722f07f0baa42dbb7eb6938647 \ + --hash=sha256:64f9c9878c1938476365e11ccfb6b770f3b9e5f045ccddc514235041e6959365 \ + --hash=sha256:6c109eac9cd439193678f69d70733c1108487546ca8eafc107b510ae10c1aecd \ + --hash=sha256:6d6a71b9d9a97c03633aa12565ef2825ffa036cc1d99cfd50dacf0f128af4fe2 \ + --hash=sha256:6ffa07666f8da0eef81d149934a626d0d95fbd6838432a33e66245423a9062c0 \ + --hash=sha256:7415db95818b39ec475a5eea54d9e3b6bc83e3912158e46da3438cdce399804d \ + --hash=sha256:77045a4b175bbf5316ec08003880804336c78f92281a1b72222b274ea85ec5ac \ + --hash=sha256:7a14a461d9340f1b46b8648578aed9cdb8b3b018a8fac6c1dde2c9192a01a87f \ + --hash=sha256:80d6ef6e8620eb2c2b4c4caad50b5935d6db3cde2d51581b55dcc79e14016d1d \ + --hash=sha256:81e3420b27048b65eb14c3acf0c174a8cb0e023277716110347d2dcb26026dad \ + --hash=sha256:823874a507a84af050493b622affde94b6f7c3a0dc22cb2801381bc03b871c00 \ + --hash=sha256:8b4d2fd2d34e5f8c9235ee787de5631a37a28402b15cb80814df973d2be54129 \ + --hash=sha256:8dddfbee2e68d26d0d7d7d9cb247b1fd4409241cce32d815a11d97ec2cfde179 \ + --hash=sha256:950ea81d57ef070665581b6e1b5f6a029306423cd1739c5b95fe78aa30db6b9d \ + --hash=sha256:956555e0603a4d38019ae6925711cb9dc43195c076a928accf7ea5d50bddfe53 \ + --hash=sha256:98b053943e5a0474ec0da309d2cb9d3f18ea57f8a2067c2ab7b5f763d1068380 \ + --hash=sha256:9968ab7e49b93ac6e1c3b2239732183152c9150f16308d30b66a372cffe3483c \ + --hash=sha256:9cb18a327b49c5c337f972b03682f6a49855525faaf3c0d3e9c96cd0fd8880a8 \ + --hash=sha256:a7b1b6353e36a7e50de2973a38d705c88ee93adcf120673cee7f45a4a3fa223a \ + --hash=sha256:a813ed7719bf45463c51779e6a98d0385fe905e48447526938a4b8337333d551 \ + --hash=sha256:aa1cce2ff3f8d953de38b76bf44602caeb69f101430208f64a10067f7cb4b1d3 \ + --hash=sha256:ad62a416ddcf863bf44bba76fbf6b53366ab0692e294f51cae4b5fbe0d246788 \ + --hash=sha256:aec3fc4b32ff82421274f5d205c559c51c840c8df66a78efd7f3612dd005a26a \ + --hash=sha256:b1185012870173de7ae33d370bd45b1cf5baee747ea4b97036b65f4e93016877 \ + --hash=sha256:b11e8fda06a7d69f15ebf542660b74466c2e51094800c1fb794f47ad4faeef17 \ + --hash=sha256:b64a85f40e154983960a4167d4c1d57a50c7f109b3d3264a3a984154e90a8454 \ + --hash=sha256:b86966fbe4ad7de710422175572bcdc75fdedadfb54bc6fab7deabccddd7780b \ + --hash=sha256:b89d0aaae2fe498c648f4c4795c084db535af5bd98ef942b2a3681fb74ce8645 \ + --hash=sha256:bc39ac66a7a9a3fbd6134fda43136b60ffde99c8f4501e64e0d2b24da137babf \ + --hash=sha256:c05ede731b03fb1b7591faca9389ade3267d2bddf1ad8882bb3f2cc5e101694f \ + --hash=sha256:c6342f54c67093cae5c0227eb0eb772fdb79f2a2c37a6eb278b9909ee06aa356 \ + --hash=sha256:c668b2f0d651605b58892644b0e302c7157f7159544227758c896982ef384b18 \ + --hash=sha256:c9b80cdf5cedba0e90d93fa5f9a333c4d65bd545cd669b71bb97ce2b703c9d73 \ + --hash=sha256:cfd73180400042a7c532d30c5e287bdd03c59ff9ee1b4c0316af0539e29dfe23 \ + --hash=sha256:d4cccbbc78717966f764cd3af4fb70276fa01fc7a2688af11c78901fa5c04f05 \ + --hash=sha256:d549420b8858885cea8838a727842249218b9c1da24dd517e25c9c7a948310a3 \ + --hash=sha256:d8200f16437b289a5bb927c6e184eccc3e8389bc0070fea4cd5b9e13c1757959 \ + --hash=sha256:e94aef2c639da4a960ad0db8e06471208d8589974953d78b61d345b4eb99e394 \ + --hash=sha256:fbde6962867ee75b48b0ee29b2b9372ec5d617799dbaf38e82dc0596f2f7738a \ + --hash=sha256:fe4d21ab149f15e4e6043dfb0de87e6e5f34ac176cde83060e9802981fca2ac2 \ + --hash=sha256:ffa6ce09a1c6a08e9667dd9c97aa0b14184e8d18f2a14b78b2a2328c9147f076 diff --git a/tests/benchmark/filtered/test_download_dbpedia.py b/tests/benchmark/filtered/test_download_dbpedia.py new file mode 100644 index 000000000..26dc043ec --- /dev/null +++ b/tests/benchmark/filtered/test_download_dbpedia.py @@ -0,0 +1,77 @@ +# Copyright (c) 2006-Present, Redis Ltd. +# All rights reserved. +# +# Licensed under your choice of the Redis Source Available License 2.0 +# (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the +# GNU Affero General Public License v3 (AGPLv3). + +import hashlib +import io +from pathlib import Path +import tempfile +import unittest + +from download_dbpedia import DIMENSIONS, download_range, main + + +class Response(io.BytesIO): + def __init__(self, status, headers, body=b""): + super().__init__(body) + self.status = status + self.headers = headers + + +class DownloadTest(unittest.TestCase): + def fetch(self, directory, mutation=None, truncated=False): + payload = b"x" * (DIMENSIONS * 4) + calls = [] + + def opener(request, timeout): + calls.append(request) + headers = {"ETag": '"pinned"', "x-amz-version-id": "version-1"} + if request.get_method() == "HEAD": + return Response(200, dict(headers, **{"Content-Length": str(len(payload) * 10)})) + self.assertEqual(request.get_header("If-match"), '"pinned"') + self.assertEqual(request.get_header("Range"), f"bytes={len(payload)}-{2 * len(payload) - 1}") + headers.update({"Content-Length": str(len(payload)), "Content-Range": f"bytes {len(payload)}-{2 * len(payload) - 1}/{10 * len(payload)}"}) + if mutation: + headers.update(mutation) + return Response(206, headers, payload[:-1] if truncated else payload) + + result = download_range("https://example.invalid/array", Path(directory) / "array.raw", 1, 1, 10, opener) + self.assertEqual(len(calls), 2) + return result, payload + + def test_pinned_range_and_digest(self): + with tempfile.TemporaryDirectory() as directory: + result, payload = self.fetch(directory) + self.assertEqual(result["sha256"], hashlib.sha256(payload).hexdigest()) + self.assertEqual(result["row_start"], 1) + self.assertEqual(result["row_stop"], 2) + self.assertEqual((Path(directory) / "array.raw").read_bytes(), payload) + with self.assertRaises(FileExistsError): + self.fetch(directory) + + def test_range_version_and_size_must_match(self): + for mutation in ({"Content-Range": "bytes 0-1/2"}, {"x-amz-version-id": "changed"}, {"ETag": '"changed"'}, {"Content-Length": "1"}): + with self.subTest(mutation=mutation), tempfile.TemporaryDirectory() as directory: + with self.assertRaises(ValueError): + self.fetch(directory, mutation) + self.assertFalse((Path(directory) / "array.raw").exists()) + + def test_truncation_does_not_publish_completed_asset(self): + with tempfile.TemporaryDirectory() as directory: + with self.assertRaises(ValueError): + self.fetch(directory, truncated=True) + self.assertFalse((Path(directory) / "array.raw").exists()) + + def test_query_intervals_reject_invalid_and_mixed_splits(self): + with tempfile.TemporaryDirectory() as directory: + for start, count in ((-1, 1), (0, 0), (9999, 2), (1999, 2)): + with self.subTest(start=start, count=count), self.assertRaises(SystemExit): + main(["--output", str(Path(directory) / "output"), "--query-start", str(start), "--query-count", str(count)]) + self.assertFalse((Path(directory) / "output").exists()) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/benchmark/filtered/test_filtered_bench.py b/tests/benchmark/filtered/test_filtered_bench.py new file mode 100644 index 000000000..4f8b8b856 --- /dev/null +++ b/tests/benchmark/filtered/test_filtered_bench.py @@ -0,0 +1,197 @@ +# Copyright (c) 2006-Present, Redis Ltd. +# All rights reserved. +# +# Licensed under your choice of the Redis Source Available License 2.0 +# (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the +# GNU Affero General Public License v3 (AGPLv3). + +import json +from pathlib import Path +import struct +import tempfile +import unittest + +import numpy as np + +import filtered_bench as bench + + +class FilteredBenchmarkTest(unittest.TestCase): + def setUp(self): + self.temporary = tempfile.TemporaryDirectory() + self.root = Path(self.temporary.name) + self.bundle = bench.write_bundle( + self.root / "bundle", np.array([[0, 0], [1, 0], [-1, 0], [2, 0]], dtype=np.float32), + np.array([[0, 0]], dtype=np.float32), "l2", 7, {"source": "test"}) + + def tearDown(self): + self.temporary.cleanup() + + def custom_case(self, ids, k): + self.bundle.filters = {"chosen": ids} + self.bundle.cases = [{"case_id": "chosen", "query_id": 0, "filter_id": "chosen", "k": k, + "cohort": "test"}] + return {row["case_id"]: row for row in bench.oracle_rows(self.bundle)} + + def result(self, ids, **changes): + result = {"bundle_id": self.bundle.bundle_id, "case_id": "chosen", "requested_policy": "AUTO", + "effective_policy": None, "repeat": 0, "status": "ok", "ids": ids, + "distances": [0.0] * len(ids), "latency_ms": 1.0} + result.update(changes) + return result + + def score(self, truth, result): + return bench.score_results(self.bundle, [result], truth, ["AUTO"], 1)["queries"][0] + + def test_known_squared_l2_and_cosine(self): + np.testing.assert_array_equal(bench.distances_to(self.bundle.vectors, [0, 0], "l2"), [0, 1, 1, 4]) + vectors = np.array([[1, 0], [0, 2], [-3, 0]], dtype=np.float32) + np.testing.assert_allclose(bench.distances_to(vectors, [1, 0], "cosine"), [0, 1, 2]) + + def test_boundary_tie_does_not_replace_strict_neighbor(self): + truth = self.custom_case([0, 1, 2, 3], 2) + self.assertEqual(truth["chosen"]["strict_ids"], [0]) + self.assertEqual(truth["chosen"]["boundary_ids"], [1, 2]) + self.assertEqual(self.score(truth, self.result([0, 2]))["recall"], 1) + self.assertEqual(self.score(truth, self.result([1, 2]))["recall"], 0.5) + + def test_fewer_than_k_and_zero_eligible(self): + truth = self.custom_case([1], 10) + self.assertEqual(self.score(truth, self.result([1]))["recall"], 1) + self.assertFalse(self.score(truth, self.result([]))["complete"]) + truth = self.custom_case([], 10) + scored = self.score(truth, self.result([])) + self.assertIsNone(scored["recall"]) + self.assertTrue(scored["complete"]) + + def test_bad_results_are_not_successes(self): + truth = self.custom_case([0, 1], 2) + for ids in ([0, 0], [0, 2], [-1], [False], [0, 1, 2]): + with self.subTest(ids=ids): + row = self.score(truth, self.result(ids)) + self.assertEqual(row["status"], "invalid") + self.assertEqual(row["recall"], 0) + self.assertEqual(self.score(truth, self.result([0], distances=[float("nan")]))["status"], "invalid") + self.assertEqual(self.score(truth, self.result([0], latency_ms=-1))["status"], "invalid") + + def test_missing_runs_and_errors_remain_in_denominator(self): + truth = self.custom_case([0, 1], 2) + records = [self.result([], status="timeout")] + report = bench.score_results(self.bundle, records, truth, ["AUTO", "BATCHES"], 2) + self.assertEqual(len(report["queries"]), 4) + self.assertEqual([row["status"] for row in report["queries"]], ["timeout", "missing", "missing", "missing"]) + self.assertTrue(all(row["recall"] == 0 for row in report["queries"])) + + def test_mixed_bundle_and_duplicate_records_rejected(self): + truth = self.custom_case([0], 1) + with self.assertRaisesRegex(ValueError, "bundle_id"): + self.score(truth, self.result([0], bundle_id="other")) + with self.assertRaisesRegex(ValueError, "duplicate result"): + bench.score_results(self.bundle, [self.result([0])] * 2, truth, ["AUTO"], 1) + + def test_manifest_checksums_and_file_lengths(self): + vectors = self.root / "bundle" / "vectors.f32" + vectors.write_bytes(vectors.read_bytes() + b"extra") + with self.assertRaisesRegex(ValueError, "checksum"): + bench.load_bundle(self.root / "bundle") + manifest_path = self.root / "bundle" / "manifest.json" + manifest = json.loads(manifest_path.read_text()) + manifest["files"]["vectors.f32"] = bench.sha256(vectors) + manifest_path.write_text(json.dumps(manifest)) + with self.assertRaisesRegex(ValueError, "byte length"): + bench.load_bundle(self.root / "bundle") + + def test_bad_filter_and_case_ids_rejected(self): + root = self.root / "bundle" + path = root / "filters.json" + filters = json.loads(path.read_text()) + filters["bad"] = [1, 1] + path.write_text(json.dumps(filters)) + manifest = json.loads((root / "manifest.json").read_text()) + manifest["files"]["filters.json"] = bench.sha256(path) + (root / "manifest.json").write_text(json.dumps(manifest)) + with self.assertRaisesRegex(ValueError, "sorted and unique"): + bench.load_bundle(root) + + def test_oracle_checksum_and_no_overwrite(self): + path = self.root / "truth.jsonl" + bench.write_oracle(self.bundle, path) + self.assertEqual(len(bench.load_oracle(self.bundle, path)), len(self.bundle.cases)) + with self.assertRaisesRegex(ValueError, "already exists"): + bench.write_oracle(self.bundle, path) + path.write_text(path.read_text() + "{}\n") + with self.assertRaisesRegex(ValueError, "checksum"): + bench.load_oracle(self.bundle, path) + + def test_fbin_header_and_payload_validation(self): + path = self.root / "base.fbin" + path.write_bytes(struct.pack("