fluss icon indicating copy to clipboard operation
fluss copied to clipboard

[kv] RocksDB keeps an unused in-memory stats history per bucket

Open mcgrj opened this issue 2 days ago • 0 comments

Search before asking

  • [x] I searched in the issues and found nothing similar.

Fluss version

main (development)

Please describe the bug 🐞

Following on from #4948, here's one more per-bucket RocksDB memory cost.

Every PK bucket leader opens a RocksDB instance with Statistics attached. RocksDB then copies all ticker values into an in-memory stats history every stats_persist_period_sec (default 600 s). RocksDBResourceContainer#createBaseCommonDBOptions() turns off the stats dump but not this. 1.0.0 has the same code.

Nothing in Fluss reads the history, RocksJava has no API to read it, and rocksdbMemoryUsageTotal doesn't include it.

RocksDB trims it at stats_history_buffer_size (1 MiB) by its own estimate. The estimate leaves out map nodes and allocator overhead, so the real size is larger. Measured on RocksDB instances opened through RocksDBResourceContainer, with the period cut to 1 s to reach the cap quickly:

main (RocksDB 11.8.1) 1.0.0 (FRocksDB 6.20.3)
RocksDB's own estimate at the cap 1.0 MiB 1.0 MiB
Measured native memory per instance 2.8 MiB 2.8 MiB
Time to reach the cap at 600 s about 14 h about 22 h

The cost per instance is the same with per-table shared Statistics (#4948), at 100 and 500 instances, and whether RocksDB sees 8 or 64 CPUs. A tablet server leading 2,000 PK buckets would hold about 5.4 GiB of it. Followers don't open RocksDB, so only leader buckets count.

This is separate from the Statistics object cost that #4948 reduced.

Solution

Add .setStatsPersistPeriodSec(0) next to .setStatsDumpPeriodSec(0). Statistics stay attached, so all RocksDB metrics stay the same.

Are you willing to submit a PR?

  • [x] I'm willing to submit a PR!

mcgrj avatar Nov 30 '26 16:11 mcgrj