[Enhance]: FTS RocksDB column families get 128 MiB x 6 write buffers with no global cap
Maintainer thường phản hồi trong vòng 1 ngày
@iaojnh đang làm issue này rồi.
Từ ngày 21/10/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- C++
- Star
- 16.3k
- Fork
- 1k
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 32
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của alibaba/zvec
-
[Feature]: IVF_TIEREDQ index type, with a learned variable-bit codec (25–44% less index memory than `IVF_RABITQ` at equal recall)Có thể đã có người làm @richyreachy đã nhận 7 ngày trước. Đang mởfeature
alibaba/zvec#909 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support an opt-in portable x86 FastPFOR build without SSE4.1Có thể đã có người làm @egolearner đã nhận 20 ngày trước. Đang mở
alibaba/zvec#875 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Enhance]: Reduce vector index block fragmentation caused by frequent flushesCó thể đã có người làm @feihongxu0824 đã nhận 22 ngày trước. Đang mởenhancement
alibaba/zvec#869 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Performance]:High-selectivity range filter materializes a full bitmap — `bitset_set_list` ~49% CPU, dwarfing the ANN searchCó thể đã có người làm @zhourrr đã nhận 22 ngày trước. Đang mởenhancement
alibaba/zvec#868 · 13 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Performance] Warm-query latency on small collections with query() and query_internal_ids() in v0.8.0Có thể làm lại được @egolearner đã nhận 33 ngày trước và không có pull request nào đang mở. Đang mở
alibaba/zvec#841 · 2 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
-
deprecation internal refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
realloc(ptr, 0) on glibc leaves the freed block in the capture as a leakCó thể đã có người làm @ADAMAMZAR đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
bloomberg/memray#1097 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
new-compilers request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
compiler-explorer/compiler-explorer#9640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
deepseek-ai/DeepEP#839 ·
Maintainer thường phản hồi trong vòng 6 ngày