[Performance]:High-selectivity range filter materializes a full bitmap — `bitset_set_list` ~49% CPU, dwarfing the ANN search
Los mantenedores suelen responder en 1 día
@zhourrr ya está trabajando en esto.
Desde el 2/11/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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
- Lenguaje dominante
- C++
- Estrellas
- 16.3k
- Forks
- 1k
- Merge medio
- 2 d 10 h
- PR fusionados (30 d)
- 32
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de alibaba/zvec
-
[Feature]: IVF_TIEREDQ index type, with a learned variable-bit codec (25–44% less index memory than `IVF_RABITQ` at equal recall)Posiblemente ocupada @richyreachy la tomó hace 7 días. Abiertofeature
alibaba/zvec#909 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Support an opt-in portable x86 FastPFOR build without SSE4.1Posiblemente ocupada @egolearner la tomó hace 20 días. Abierto
alibaba/zvec#875 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Enhance]: Reduce vector index block fragmentation caused by frequent flushesPosiblemente ocupada @feihongxu0824 la tomó hace 22 días. Abiertoenhancement
alibaba/zvec#869 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Performance] Warm-query latency on small collections with query() and query_internal_ids() in v0.8.0Quizá libre de nuevo @egolearner la tomó hace 33 días y no hay ningún pull request abierto. Abierto
alibaba/zvec#841 · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Read-only collection concurrent query triggers permanent futex deadlock (process hangs, never recovers)Quizá libre de nuevo @richyreachy la tomó hace 34 días y no hay ningún pull request abierto. Abiertobug
alibaba/zvec#837 · 2 asignados ·
Los mantenedores suelen responder en 1 día
Todos los issues de alibaba/zvec
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
-
deprecation internal refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
realloc(ptr, 0) on glibc leaves the freed block in the capture as a leakPosiblemente ocupada @ADAMAMZAR la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
bloomberg/memray#1097 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
new-compilers request
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
compiler-explorer/compiler-explorer#9640 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
deepseek-ai/DeepEP#839 ·
Los mantenedores suelen responder en 6 días