Skip to content

The cache preallocated 74 MB of WAL to hold 0.3 MB - #12

Merged
bjmeetsfo merged 1 commit into
mainfrom
fix/configurable-rocksdb-write-buffer
Aug 30, 2026
Merged

The cache preallocated 74 MB of WAL to hold 0.3 MB#12
bjmeetsfo merged 1 commit into
mainfrom
fix/configurable-rocksdb-write-buffer

Conversation

@bjmeetsfo

Copy link
Copy Markdown
Collaborator

RocksDB sizes its write-ahead log to hold a full memtable flush, so the write buffer is a floor on the DB's on-disk size — paid whether or not anything is cached. It was hardcoded at 64 MiB.

Measured on a TemporalStore block cache holding 0.32 MB of content:

000004.log   apparent content    331,697 bytes
             allocated on disk 73,822,208 bytes     222x
cache dir    0.4 MB of data, 74.5 MB allocated

74.1 MB of preallocated air. It is a fixed overhead per store, so it is noise at scale and dominates a small or short-lived cache completely.

MATRIXCACHE_ROCKSDB_WRITE_BUFFER_MB now sets it, defaulting to 64 so existing deployments are unchanged. Smaller memtables flush more often, so this trades write amplification against the fixed cost — worth it only when the cache is small relative to 64 MiB, which is why it is a knob and not a new default.

Zero and unparseable values fall back to the default rather than configuring a degenerate DB; the test covers "0", "", "abc" and "-4".

Suite: 284 passed, 0 failed.

🤖 Generated with Claude Code

RocksDB sizes its write-ahead log to hold a full memtable flush, so the write
buffer is a floor on the DB's on-disk size -- paid whether or not anything is
cached. It was hardcoded at 64 MiB.

Measured on a TemporalStore block cache holding 0.32 MB of content: the WAL file
reported 331,697 bytes of data against 73,822,208 bytes allocated, and the cache
directory was 74.5 MB of which 74.1 MB was preallocated air. A 222x fixed
overhead, and for a small or short-lived cache it dwarfs the data it protects.

MATRIXCACHE_ROCKSDB_WRITE_BUFFER_MB now sets it, defaulting to 64 so existing
deployments are unchanged. Smaller memtables flush more often, so this trades
write amplification against the fixed cost -- worth it only when the cache is
small relative to 64 MiB, which is why it is a knob rather than a new default.

Zero and unparseable values fall back to the default rather than configuring a
degenerate DB; the test covers 0, , abc and -4.

Suite: 284 passed, 0 failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@bjmeetsfo
bjmeetsfo merged commit e0951b3 into main Aug 30, 2026
5 checks passed
@bjmeetsfo
bjmeetsfo deleted the fix/configurable-rocksdb-write-buffer branch August 30, 2026 04:33
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