Skip to content

feat(benchmarks): organize subsystem suites and add inverted microbenchmarks - #908

Merged
zhourrr merged 17 commits into
alibaba:mainfrom
zhourrr:feat/invert_benchmarks
Nov 18, 2026
Merged

zhourrr merged 17 commits into
alibaba:mainfrom
zhourrr:feat/invert_benchmarks

Conversation

@zhourrr

@zhourrr zhourrr commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

中文

将现有 FTS 和 vector benchmark 从 tools/ 迁移到独立的 benchmarks/ 模块,并新增面向 INT32/INT64 的倒排索引 microbenchmarks。

  • 使用 BUILD_BENCHMARKS=ON 显式启用构建,替代原来的 BUILD_TOOLS,默认关闭;同步更新 CI、构建脚本、打包配置、CODEOWNERS 和文档。
  • Numeric 使用类型明确的 profile,覆盖 Uniform、Moderate Hotspot(3,000 个热值、50% 非 NULL 文档)和 Extreme Hotspot(300 个热值、90% 非 NULL 文档),以及两种非负值域、升序/随机排列、0%/10%/50% NULL、10 万/1 千万文档档位。
  • C++ 分别执行 build、完整文档 ID 校验和全部查询计时。Numeric 自己的 Python 脚本枚举 workload、重复执行并汇总 JSON 报告;查询列表从 build 报告读取,无需 C++ list 命令。
  • 记录插入与 seal 耗时、查询延迟和吞吐、磁盘占用、进程 RSS 和峰值 RSS。保留 shared 中的索引、计时、校验、进程调用与报告 helpers。

验证:本地 Debug 构建通过;12 个 C++ 测试和 28 个 Python 测试通过。C++ 测试覆盖 72 种 numeric 配置组合,每组使用 10 万文档。另已完成 72 组 1 千万文档的 benchmark,每组重复 3 次。Ruff 0.14.4、clang-format 18.1.8 和 diff 检查通过。

数值索引查询性能参考

在同一台 macOS arm64 机器上,用 workload 40 的 1,000 万条 INT64 记录分别与 SQLite 3.53.3 和 Qdrant Edge 0.9.0 对照。每次对照都重新测量了 zvec。数值均匀分布在 0–29,999,按文档 ID 打散,无 NULL。逐行核对了文档 ID 和数值,也核对了每个查询参数的命中数。原始 benchmark 报告中的 workload 40

查询 平均命中文档数 zvec(SQLite 对照) SQLite zvec(Qdrant 对照) Qdrant Edge
等值命中(7 个值) 340.14 5.70 µs 6.00 µs 5.61 µs 15.61 µs
等值未命中(−1 至 −7,均在值域外) 0 0.10 µs 0.27 µs 0.10 µs 1.48 µs
v < 300 100,109 0.63 ms 1.57 ms 0.75 ms 7.19 ms
v < 15006 4,999,849 6.16 ms 77.97 ms 6.16 ms 432.16 ms

表中为单次精确过滤计数的平均耗时。每次测试使用一个查询线程,每个参数执行 100 次,共 3 轮。zvec 查询倒排索引并读取结果位图的基数,SQLite 通过原生 C API 在读事务内使用覆盖索引执行 COUNT(*),SQL 预编译和参数绑定均在计时前完成。SQLite 对照中,等值命中耗时接近,zvec 的两条范围计数查询更快。

Qdrant Edge 使用一个 segment,整数索引同时启用等值和范围查询,覆盖全部 1,000 万条记录。过滤条件在计时前构造,计时包含通过进程内 Python 绑定调用 Rust 引擎的开销。exact=true 会收集匹配的点 ID、去重并计数。命中 4,999,849 条时,zvec 和 Qdrant Edge 的平均耗时分别为 6.16 ms 和 432.16 ms。Qdrant Edge 精确计数实现

English

Move the existing FTS and vector benchmarks from tools/ into a dedicated benchmarks/ module, and add inverted-index microbenchmarks for INT32/INT64.

  • Replace BUILD_TOOLS with opt-in BUILD_BENCHMARKS=ON, disabled by default. Update CI, build scripts, packaging configuration, CODEOWNERS, and documentation.
  • Use typed numeric profiles covering Uniform, Moderate Hotspot (3,000 hot values and 50% of non-NULL documents), and Extreme Hotspot (300 hot values and 90% of non-NULL documents), plus two nonnegative value domains, ascending/shuffled ordering, 0%/10%/50% NULLs, and 100K/10M document presets.
  • C++ workers build the index, verify complete document IDs, and measure every applicable query. The numeric suite's Python script enumerates workloads, runs repetitions, and aggregates JSON reports. Query cases come from the build report, with no C++ list command.
  • Report insertion and seal time, query latency and throughput, disk usage, process RSS, and peak RSS. Retain shared helpers for index lifecycle, timing, verification, subprocesses, and reporting.

Validation: local Debug build passed; all 12 C++ tests and 28 Python tests passed. C++ coverage includes 72 numeric configurations at 100K documents each. A full run also covered 72 workloads at 10M documents each, with three repetitions per workload. Ruff 0.14.4, clang-format 18.1.8, and diff checks passed.

Numeric query performance reference

We compared zvec with SQLite 3.53.3 and Qdrant Edge 0.9.0 in two separate runs on the same macOS arm64 machine, measuring zvec again for each comparison. All engines used workload 40’s 10 million INT64 values, uniformly distributed over 0–29,999, shuffled by document ID, with zero NULLs. We checked every document ID and value after import and compared match counts for each query input. Workload 40 in the original benchmark report

Query Mean matches zvec (SQLite run) SQLite zvec (Qdrant run) Qdrant Edge
Equality hit (7 values) 340.14 5.70 µs 6.00 µs 5.61 µs 15.61 µs
Equality miss (−1 through −7, all outside the domain) 0 0.10 µs 0.27 µs 0.10 µs 1.48 µs
v < 300 100,109 0.63 ms 1.57 ms 0.75 ms 7.19 ms
v < 15006 4,999,849 6.16 ms 77.97 ms 6.16 ms 432.16 ms

The table shows mean latency per exact filtered count. Each engine used one query thread and executed each input 100 times in each of three rounds. zvec searched the inverted index and read the result bitmap's cardinality. SQLite executed COUNT(*) over a covering index through its native C API in a read transaction, with statements prepared and parameters bound before timing. In the SQLite comparison, equality hits took similar time and zvec was faster for both range counts.

Qdrant Edge used one segment with integer lookup and range indexing enabled for all 10 million points. Filters were constructed before timing. The timings include the call through the in-process Python binding to the Rust engine. With exact=true, Edge collects and deduplicates matching point IDs before counting them. At 4,999,849 matches, zvec averaged 6.16 ms and Qdrant Edge averaged 432.16 ms. Qdrant Edge exact-count implementation

@zhourrr
zhourrr force-pushed the feat/invert_benchmarks branch from b7e6211 to 4cd8e0a Compare November 17, 2026 12:46
Align workload options, simplify query timing metrics, and retain only failed phase logs. Fix cross-platform paths, terminal colors, and vector<bool> shuffling.
Measure inserts after each batch is decoded. Report observed value distributions and mean matches per query, and document how to run and interpret the benchmark.

@iaojnh iaojnh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有两个问题建议合并前处理:

  1. [P2] 独立运行 query 时会绕过 verify。 QueryNumeric() 只检查了索引路径和数据描述,没有检查校验结果。Python 驱动会在 verify 失败时停止,但 README 也支持直接运行 C++ 的各个阶段。本地复现:构建后让索引与源数据不一致,verify 返回 1,随后 query 仍返回 0 并生成 query.json。建议 verify 成功后写入与本次索引、数据和查询参数绑定的校验记录,query 只有在记录匹配时才开始计时。

  2. [P3] 原始 JSON 在汇总前就舍入了计时结果。 WriteJson() 对所有浮点数使用 fixed 和两位小数。例如,96 ms 和 104 ms 的构建耗时都会写成 0.10 s,Python 汇总时已经无法区分。建议原始 JSON 保留浮点精度,只在渲染 report.md 时舍入。

@zhourrr

zhourrr commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@iaojnh 感谢复现并指出这两个问题。针对这次 review,说明一下当前的设计取舍。

  1. 独立执行 query。 你观察到的行为符合这个入口的约定。直接调用 C++ 的 --mode=query 是为了在已有索引上单独复测查询性能,退出码 0 只表示计时成功。README 推荐的 Python 入口会按 prepare → build → verify → query 执行,每一轮都会对照原始数据逐个检查 doc ID。只要 verify 失败,这一轮就会停止。我们希望保留独立复测的能力,因此这次不引入持久化校验记录。
  2. 汇总前舍入。 你给的例子成立。构建耗时以秒写入 JSON 并保留两位小数,96 ms 和 104 ms 都会记为 0.10 s,Python 计算的是这些已舍入值的均值。当前选择让 JSON 和 Markdown 中的浮点指标统一保留两位小数,代价是无法用原始报告分辨这类毫秒级差异。如果后续要用这套 benchmark 追踪这个量级的回归,我们赞同让原始 JSON 保留完整精度、仅在 Markdown 展示时舍入。

@iaojnh
iaojnh self-requested a review November 18, 2026 04:52
@zhourrr
zhourrr merged commit 3dbe855 into alibaba:main Nov 18, 2026
19 checks passed
@zhourrr
zhourrr deleted the feat/invert_benchmarks branch November 18, 2026 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants