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

オープン
#869 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@feihongxu0824 がすでに取り組んでいます。

2026年11月2日 から。

評価

この issue はまだ評価されていません。

説明

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.

主要言語
C++
スター
16.3k
フォーク
1k
平均マージ
2日 10時間
マージ済み PR(30日)
32

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

alibaba/zvec のほかの issue

alibaba/zvec の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。