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

Abierto
#869 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@feihongxu0824 ya está trabajando en esto.

Desde el 2/11/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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.

Lenguaje dominante
C++
Estrellas
16.3k
Forks
1k
Merge medio
2 d 10 h
PR fusionados (30 d)
32

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de alibaba/zvec

Todos los issues de alibaba/zvec

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.