[Enhance]: FTS RocksDB column families get 128 MiB x 6 write buffers with no global cap
I maintainer di solito rispondono entro 1 giorno
@iaojnh ci sta già lavorando.
Dal 21/10/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Affected Component
RocksDB options for the FTS index and the ID map (RocksdbContext::prepare_options, src/db/common/rocksdb_context.cc)
Current Behavior
On main (53c1bb6):
prepare_options()callsOptimizeLevelStyleCompaction()with its default 512 MiB memtable budget (rocksdb_context.cc:247). This sets every column family of every RocksDB instance towrite_buffer_size= 128 MiB andmax_write_buffer_number= 6.- The only override is
write_buffer_size = 8 << 20(8 MiB), and it applies only when a DB-widemerge_opis passed (rocksdb_context.cc:271-275). The FTS index registers per-CF merge operators and passesmerge_op = nullptr(src/db/index/column/fts_column/fts_indexer.cc:71-72,:75-77;src/db/index/segment/segment_helper.cc:1042-1044), so FTS column families keep 128 MiB. The ID map also passes no merge operator (src/db/index/common/id_map.cc:36,:42). - A writable FTS index has 5 column families per FTS field, plus
$FTS_STATanddefault(fts_indexer.cc:50-65). That makes 7 column families for one field and 12 for two. - Nothing bounds the total across column families or DBs:
write_buffer_manager = nullptr(rocksdb_context.cc:286-287) anddb_write_buffer_size= 0. - Every FTS column family uses a HashSkipList memtable with 1,000,000 buckets (
rocksdb_context.cc:295-305), which is an 8 MB bucket array per memtable. Read-only opens use it too. - Each DB creates a
rocksdb::Statisticsobject (rocksdb_context.cc:283-284). Nothing undersrc/reads it. This is minor and we did not measure it.
Standalone check, with zvec 0.7.0 from PyPI (rocksdb_context.cc is identical in v0.7.0 and 53c1bb6):
# python fts_memtables.py 0|1|2 (number of FTS fields)
import glob, os, re, sys, tempfile
import zvec
from zvec import CollectionOption, CollectionSchema, DataType, Doc, FieldSchema, FtsIndexParam
def rss_anon_mb():
return next(int(l.split()[1]) // 1024 for l in open("/proc/self/status") if l.startswith("RssAnon:"))
n_fts = int(sys.argv[1])
schema = CollectionSchema(name="fts", fields=[FieldSchema("v", DataType.INT64)] + [
FieldSchema(f"t{i}", DataType.STRING, index_param=FtsIndexParam(tokenizer_name="standard"))
for i in range(n_fts)])
path = os.path.join(tempfile.mkdtemp(), "c")
base = rss_anon_mb()
coll = zvec.create_and_open(path=path, schema=schema,
option=CollectionOption(read_only=False, enable_mmap=True))
print(f"{n_fts} FTS field(s): create_and_open RssAnon +{rss_anon_mb() - base} MB")
coll.insert([Doc(id=str(i), fields={"v": i, **{f"t{j}": f"hello {i}" for j in range(n_fts)}})
for i in range(100)])
coll.flush()
del coll
base = rss_anon_mb()
coll = zvec.open(path=path, option=CollectionOption(read_only=True, enable_mmap=True))
print(f"{n_fts} FTS field(s): open read-only RssAnon +{rss_anon_mb() - base} MB")
for opts in sorted(glob.glob(f"{path}/*/fts.*/OPTIONS-*"))[-1:]:
text = open(opts).read()
print("column families:", len(re.findall(r"^\[CFOptions ", text, re.M)))
for key in ("write_buffer_size", "max_write_buffer_number", "db_write_buffer_size", "bucket_count"):
print(" ", sorted(set(re.findall(rf"\b{key}=(\d+)", text))), key)
0 FTS field(s): create_and_open RssAnon +2 MB
0 FTS field(s): open read-only RssAnon +0 MB
1 FTS field(s): create_and_open RssAnon +57 MB
1 FTS field(s): open read-only RssAnon +46 MB
column families: 7
['134217728'] write_buffer_size
['6'] max_write_buffer_number
['0'] db_write_buffer_size
['1000000'] bucket_count
2 FTS field(s): create_and_open RssAnon +95 MB
2 FTS field(s): open read-only RssAnon +92 MB
column families: 12
['134217728'] write_buffer_size
['6'] max_write_buffer_number
['0'] db_write_buffer_size
['1000000'] bucket_count
Measured write path, in an application that flushes every 64 docs. This run was its full rebuild, which writes one collection with a single flush at the end: 10,785 English paragraphs, two FTS fields (standard and ngram tokenizers) and a 1024-dim fp32 HNSW field. The library was zvec 1ab7975 from the zvec-rust 0.7.2 prebuilt. We changed the constants by patching immediates in the prebuilt libzvec_c_api.so, which affects every RocksDB instance in the process. Peak RSS is VmHWM, 2 rounds per arm with the arm order rotated:
| Arm | Peak RSS (round 1 / round 2) | Write-phase wall time (round 1 / round 2) |
|---|---|---|
| Stock | 1,103 MB / 1,165 MB | 73.8 s / 68.7 s |
bucket_count 16,384 |
740 MB / 782 MB | 95.1 s / 83.2 s |
bucket_count 16,384 and memtable budget 32 MiB (write_buffer_size 8 MiB) |
357 MB / 360 MB | 56.9 s / 58.8 s |
- The 32 MiB budget also changes
target_file_size_base(to 4 MiB) andmax_bytes_for_level_base(to 32 MiB). The collection had 27 SSTs instead of 18, with the same total SST bytes (57.6 MB). - We did not control the timings for host load, so treat them as indicative only.
Desired Improvement
- Give FTS (and ID-map) column families an explicit, small
write_buffer_sizeand a lowermax_write_buffer_number. One way is to apply the existing 8 MiB setting wheneverper_cf_merge_opsis non-empty, not only when a DB-widemerge_opis set. Another is to callOptimizeLevelStyleCompaction()with a budget sized for these small DBs. - Keep a process-wide bound on memtable memory. Open PR #770 does this with a shared
WriteBufferManagerand block cache, and derives the HashSkipList bucket count from its budget. On the 16 GiB host above, its default budget works out to about 1.9 GiB for RocksDB: 15% of 0.8 × host memory. That is above the 1.1 GB peak we measured, so the per-CF size in point 1 still decides the write-path peak. We left details on the bucket sizing as a comment on #770. - Minor: create
rocksdb::Statisticsonly when asked for. It is still created per DB in #770.
Impact
- Lower and more predictable memory per writable collection. In the measurement above, peak RSS for the same write fell from 1,103–1,165 MB to 357–360 MB when both the bucket count and the write buffer size were reduced.
- Each FTS column family would no longer hold up to 6 × 128 MiB of memtables, so memory would scale less with the number of FTS fields and open collections.
- Lingua principale
- C++
- Stelle
- 16.3k
- Fork
- 1k
- Merge medio
- 2g 10h
- PR unite (30g)
- 32
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di alibaba/zvec
-
[Feature]: IVF_TIEREDQ index type, with a learned variable-bit codec (25–44% less index memory than `IVF_RABITQ` at equal recall)Forse già presa @richyreachy l’ha presa 7 giorni fa. Apertafeature
alibaba/zvec#909 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Support an opt-in portable x86 FastPFOR build without SSE4.1Forse già presa @egolearner l’ha presa 20 giorni fa. Aperta
alibaba/zvec#875 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhance]: Reduce vector index block fragmentation caused by frequent flushesForse già presa @feihongxu0824 l’ha presa 22 giorni fa. Apertaenhancement
alibaba/zvec#869 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Performance]:High-selectivity range filter materializes a full bitmap — `bitset_set_list` ~49% CPU, dwarfing the ANN searchForse già presa @zhourrr l’ha presa 22 giorni fa. Apertaenhancement
alibaba/zvec#868 · 13 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Performance] Warm-query latency on small collections with query() and query_internal_ids() in v0.8.0Forse di nuovo libera @egolearner l’ha presa 33 giorni fa e non c’è nessuna pull request aperta. Aperta
alibaba/zvec#841 · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di alibaba/zvec
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
deepseek-ai/DeepEP#839 ·
I maintainer di solito rispondono entro 6 giorni
-
multilabel_margin_loss returns an unwritten scalar for an empty CPU batch with reduction='sum'Apertabot-triaged module: correctness (silent) module: cpu module: empty tensor module: loss triage review
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
stephenberry/glaze#3126 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ultravideo/kvazaar#453 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
google-ai-edge/LiteRT-LM#4783 ·
I maintainer di solito rispondono entro 1 giorno