[Performance]:High-selectivity range filter materializes a full bitmap — `bitset_set_list` ~49% CPU, dwarfing the ANN search
メンテナーはふだん 1 日以内に返信
@zhourrr がすでに取り組んでいます。
2026年11月2日 から。
評価
この issue はまだ評価されていません。
説明
Affected Component
inverted index,HNSW index
Current Behavior
Summary
A hybrid query (scalar range filter + top-k vector search) becomes bottlenecked by bitmap materialization in the pre-filter stage, not by the vector search. bitset_set_list alone consumes ~49% of CPU. Throughput is capped far below expectations.(zvec v0.7.0)
Repro
- Collection schema (3 columns):
mail: string (email)vector: 62-dim float vector (cosine / inner-product metric)dataTime: int32, timestamp in hours
- Data: 10M rows covering the last 4 days (96 hourly buckets), inserted and optimized.
- Query:
dataTime >= (now - 3 days)(matches ~7.5M rows ≈ 75% selectivity), then top-21 vector search, returningmail. - Hardware: 8-core machine.
Measured ~500 QPS (target 1000+).
Perf profile (sudo perf top)
| Overhead | Symbol |
|---|---|
| 48.70% | bitset_set_list |
| 7.52% | compute_one_to_many_inner_product (distance) |
| 7.52% | dual_heap_search_neighbors<...Hnsw...> (HNSW traversal) |
| 2.48% | roaring_bitmap_portable_deserialize_frozen |
| 2.08% | BaseDistanceBatchWithScoreUnquantized<CosineMinusInnerProduct, signed char, ...> |
| 2.01% | roaring_bitmap_lazy_or_inplace |
| 1.78% | db_index_sprig_traverse (host app) |
Roaring bitmap work (bitset_set_list + deserialize_frozen + lazy_or_inplace) ≈ 53%; the actual ANN search + distance ≈ 19%.
Root cause
- The range filter is routed to the inverted index.
invert_to_forward_scan_ratiodefaults to0.9(src/db/common/config.cc:39). Insrc/db/sqlengine/planner/optimizer.cc:84a condition stays inverted whenratio < 0.9. At 75% selectivity,0.75 < 0.9, so a bitmap is built instead of scanning forward. get_bitmap_gt/get_bitmap_lt(src/db/index/column/inverted_column/inverted_column_indexer_search.cc:209/321) merge ~72 hourly posting lists viamerge_or→roaring_bitmap_or→bitset_set_list(thirdparty/CRoaring/.../roaring.c), producing a bitmap with ~7.5M bits set over the full 10M-id range (~1.25 MB bitset).bitset_set_listis an O(num-matches) read-modify-write: each word set requires an exclusive cache line (RFO). On a cold ~1.25 MB bitmap this is ~100+ cycles per miss; with millions of matches per query it dominates.- The existing complement-and-flip optimization
range_covers_most_values(threshold 0.7,..._search.cc:955) does not avoid the cost — it still builds a full-range bitmap and thenroaring_bitmap_flip_inplaceover[0, max_id+1](flip_bitmap,:977). It also only applies to sealed indexes with a range histogram.
Desired Improvement
target QPS 1000+
Any guidance on the recommended approach for this workload would be appreciated.
Impact
faster queries
- 主要言語
- C++
- スター
- 16.3k
- フォーク
- 1k
- 平均マージ
- 2日 10時間
- マージ済み PR(30日)
- 32
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
alibaba/zvec のほかの issue
-
[Feature]: IVF_TIEREDQ index type, with a learned variable-bit codec (25–44% less index memory than `IVF_RABITQ` at equal recall)対応中かも @richyreachy が 7 日前に担当しました。 オープンfeature
メンテナーはふだん 1 日以内に返信
-
Support an opt-in portable x86 FastPFOR build without SSE4.1対応中かも @egolearner が 20 日前に担当しました。 オープン
alibaba/zvec#875 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Enhance]: Reduce vector index block fragmentation caused by frequent flushes対応中かも @feihongxu0824 が 22 日前に担当しました。 オープンenhancement
メンテナーはふだん 1 日以内に返信
-
[Performance] Warm-query latency on small collections with query() and query_internal_ids() in v0.8.0再び着手できるかも @egolearner が 33 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
メンテナーはふだん 1 日以内に返信
-
[Bug]: Read-only collection concurrent query triggers permanent futex deadlock (process hangs, never recovers)再び着手できるかも @richyreachy が 34 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
deprecation internal refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
realloc(ptr, 0) on glibc leaves the freed block in the capture as a leak対応中かも @ADAMAMZAR が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
bloomberg/memray#1097 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
new-compilers request
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
compiler-explorer/compiler-explorer#9640 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
deepseek-ai/DeepEP#839 ·
メンテナーはふだん 6 日以内に返信