Skip to content

feat(hotblocks): expose the LSM base level size - #107

Merged
mo4islona merged 1 commit into
masterfrom
feat/rocksdb-level-base
Jul 27, 2026
Merged

feat(hotblocks): expose the LSM base level size#107
mo4islona merged 1 commit into
masterfrom
feat/rocksdb-level-base

Conversation

@mo4islona

Copy link
Copy Markdown
Contributor

Adds --rocksdb-level-base-mb. Default stays RocksDB's own 256 MB, so this is inert until a deployment sets it — same pattern as the memtable flags in #106.

Why now

Two independent reasons, both surfaced by the production roll of #106.

1. The memtable change left the ladder mis-sized. Raising write_buffer_size 64 → 512 MB without touching the base inverted the L0/L1 relationship:

before after #106
compressed L0 file per flush ~16 MB ~128 MB
4 files = compaction trigger 64 MB 512 MB
target L1 (max_bytes_for_level_base) 256 MB 256 MB
L1 / L0 4 — healthy 0.5 — inverted

L0 now arrives larger than the level it merges into, so every L0 compaction rewrites all of L1 and immediately pushes it down. Canonical pairing is base ≥ level0_file_num_compaction_trigger × compressed flush size.

2. It is the lever the memtable could not reach. A byte is rewritten once per level it descends. Memtable size only addresses the L0→L1 hop; at ~60 GB live the ladder runs several levels deeper and that work is untouched by it.

Production bears this out. The bench predicted 2.4× fewer device writes — measured at ~130 MB live, where there is barely a ladder. What internal actually delivered at ~60 GB live, 35 min post-roll:

before after
device writes 307 / 322 MiB/s 184 / 193 −40 % (1.67×)
CPU 2.52 / 2.62 cores 1.84 / 2.07 −27 %

morpho, which writes least and is therefore WAL-dominated, got only −23 % — consistent with the same model from the other end.

The write-stall fix from #106 is unambiguous and unaffected by any of this: write_stopped 1.206 % → 0 on internal-db-1, immutable_memtables 1 of 4 across all eight pods, zero restarts on the roll.

What this PR deliberately does not do

It does not set a value, and the value is unmeasured. The bench cannot price this parameter: at 130 MB live there is no ladder to shorten, so a sweep there would measure noise. Pricing it needs a bench run with live size in the GBs — materially longer than the runs behind #106 — or a canary on internal.

Suggested starting point when someone does measure it: 2 GB and 4 GB against the current 256 MB, all at 512 × 4 + direct I/O.

Cost of raising it

Fewer levels ⇒ lower write amplification, but larger individual compactions, more transient space during them, and read amplification roughly flat or slightly better. Nothing here is free at 60 GB live, which is exactly why the default is unchanged.

🤖 Generated with Claude Code

Raising write_buffer_size 8x without touching this left L0 arriving larger
than the level it merges into: four 512 MB memtables flush ~512 MB of
compressed L0 into a 256 MB L1, so every L0 compaction rewrites all of L1 and
immediately pushes it down. The canonical pairing is base >=
level0_file_num_compaction_trigger x the compressed flush size.

It is also the lever the memtable change could not reach. A byte is rewritten
once per level, and memtable size only addresses the L0->L1 hop; at ~60 GB
live the ladder runs several levels deeper and that work is untouched. The
production numbers show it: the bench predicted 2.4x fewer device writes at
~130 MB live, internal delivered 1.67x at ~60 GB.

Default stays RocksDB's 256 MB, so this is inert until a deployment sets it.
Deliberately unmeasured: the bench cannot price it at 130 MB live, where there
is barely a ladder to shorten.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mo4islona
mo4islona merged commit 607d8be into master Jul 27, 2026
3 checks passed
@mo4islona
mo4islona deleted the feat/rocksdb-level-base branch July 27, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant