Repository navigation
Backport feat/write buffer manager - #596
Merged
Merged
Conversation
Adds a process-wide WriteBufferManager singleton in DBSettings, lazy- created on first DB open and shared across every database in the process. Memtable memory is bounded by a single configurable limit rather than each DB managing its own budget. New `RocksDatabase.config()` options: - `writeBufferManagerSize` — bytes of memtable memory the WBM caps across all DBs (0 disables); runtime-mutable via SetBufferSize - `writeBufferManagerCostToCache` — when true, memtable charges show up in `block-cache-usage` as pinned entries, giving a single observability metric for read cache + memtable footprint - `writeBufferManagerAllowStall` — when true, writes stall once the cap is reached instead of letting memtables grow past it Implementation notes: - DBSettings::getInstance() now uses C++11 magic statics for thread- safe lazy initialization (previously raced on concurrent first-call from libuv worker threads). - Configuration fields are `std::atomic` so JS-thread Config() writes are safe against worker-thread reads in getWriteBufferManager(). - WBM creation is mutex-protected; double-checked locking on the atomic size guards against teardown between load and lock. - `costToCache` and `allowStall` are fixed at first WBM creation (already-open DBs hold shared_ptr refs; the WBM can't be swapped). Config() writes after creation are ignored with an stderr warning. - Setting size=0 at runtime is a "no new attachments" signal, not a teardown — RocksDB asserts SetBufferSize(>0). Verified by 11 tests covering: negative-size rejection, default-off path, costToCache wiring, multi-DB sharing, runtime resize, active memtable reclamation after flush, block-cache-usage charge visibility, the actual structural cap (writeBufferManagerSize, not blockCacheSize), and maintain-window cycling. Co-Authored-By: Claude Sonnet 4.7 <noreply@anthropic.com>
kriszyp
approved these changes
May 27, 2026
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.
Backport of #584