Size the SSD tier's memtable for a cache, not for a write-heavy database - #11
Open
bjmeetsfo wants to merge 1 commit into
Open
Size the SSD tier's memtable for a cache, not for a write-heavy database#11bjmeetsfo wants to merge 1 commit into
bjmeetsfo wants to merge 1 commit into
Conversation
RocksDB reserves each WAL at ~1.1x the memtable, so a 64 MB memtable reserved a 70.4 MB log per cache instance and 211 MB across a three-prefix store. Measured downstream: 262.5 MB allocated to 79.6 MB, same bytes written, latency flat.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SSD tier sets a 64 MB memtable. RocksDB reserves each write-ahead log at roughly 1.1x the memtable size, so every cache instance reserves a 70.4 MB log file — regardless of how much is actually cached. A store split across three prefixes opens three instances, so it reserved 211 MB of blocks for a cache holding 8 MB of data.
The difference is invisible to anything that measures written bytes: the same store reports 35.6 MB apparent and 269.2 MB allocated.
dusees it;stat's size field does not.Measured downstream on a real ingest path, 400 adds of a 4 KB payload, with the before arm run twice:
70% less reserved disk. The two before arms land 0.8% apart, so the effect is far outside the noise, and latency is flat — the 8 MB arm sits below both controls. Bytes actually written are unchanged, which is the point: this is space reserved and never used.
Why not simply turn the log off
A cache is rebuildable, so journalling it looks like pure waste. It is not safe here. In the consumer, a hot page can live only in the cache until it is evicted or dumped; an entry evicted before the next flush used to read back as missing, which is an acknowledged write disappearing, and a spill handler exists specifically to close that hole. Dropping the log would reopen it.
So the log stays and only its reservation shrinks.
set_sync(false)is unchanged and the log is still written on every admission: crash behaviour is byte-for-byte what it was. This change is about reserved space, not durability.Shape
The size becomes a field with a default plus a setter, following the existing
SetCapacityshape, so a write-heavy tier that would rather flush less often can ask for more. Only the default moves.One note for reviewers: this file declares
StorageEngineRocksDbacross four separate blocks and contains three unrelatedSetCapacitymethods on three different structs. Anchoring edits by string search puts the setter on the wrong struct — it compiles until it reaches the missing field, and fails there. The edits here are anchored inside located line ranges for that reason.Tests
318 + 6 pass, 0 failed,
cargo check --libclean.