[Enhance]: Reduce vector index block fragmentation caused by frequent flushes

Aperta
#869 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@feihongxu0824 ci sta già lavorando.

Dal 2/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement
Affected Component

Collection flush, vector index block lifecycle, querying, and optimize.

Current Behavior

While reading the source, I noticed that flush() persists pending writes and also ends the current writing block:

  • SegmentImpl::flush() calls finish_memory_components(), which adds the current vector index to the persisted block list and clears the current writer references.
  • On the next insert, init_memory_components() creates a new Flat vector index for the next batch.
  • At query time, CombinedVectorColumnIndexer::search() searches the blocks individually and merges their results.

As a result, applications that write small batches and frequently request durability keep creating new vector index blocks:

for batch in small_batches:
    collection.insert(batch)
    collection.flush()

Without merging, the block count grows with the number of flushes following nonempty write batches.

Desired Improvement

It would be helpful to reduce the direct coupling between an application's durability requirements and the number of internal vector index blocks.

I understand that sealing each batch helps manage commit boundaries and crash recovery. Could we consider either:

  • Separating durable log synchronization from block sealing, so applications can frequently request durability without creating many small blocks.
  • Keeping the current model, but providing automatic merging based on block count or size, together with clear usage guidance.

I would also appreciate clarification on these questions:

  1. Is ending the current vector block on every flush primarily a consistency and crash recovery decision?
  2. Is there an existing mechanism that bounds the accumulation of small blocks?
  3. What flush and optimize policy is recommended for continuous small-batch writes that require frequent durability guarantees?
Impact

Many small blocks may increase index file and metadata overhead, as well as the cost of per-block searches and candidate merging. Requiring applications to call optimize frequently may also add maintenance overhead.

The concern here is the additional fragmentation overhead; splitting the same number of vectors across more Flat blocks does not necessarily increase the total number of distance calculations.

This is a design concern based on source inspection. I have not yet quantified the performance impact with benchmarks.

Lingua principale
C++
Stelle
16.3k
Fork
1k
Merge medio
2g 10h
PR unite (30g)
32

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di alibaba/zvec

Tutte le issue di alibaba/zvec

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.