Export RocksDB internal metrics via caller-driven…#3296
Open
awatts73 wants to merge 2 commits into
Open
Conversation
… polling Adds RocksDB property-based metrics (compaction pressure, SST file sizes, snapshot count, per-level file counts) gated behind the existing `metrics` feature. No background threads: a new `export_rocksdb_metrics()` public method on `RocksDB`, `BlockDB`, and `BlockStore<N, BlockDB<N>>` lets the caller decide when to poll (e.g. the auto-checkpoint loop in snarkOS). Propagates `snarkvm-ledger-store/metrics` through `snarkvm-ledger/metrics` so the feature chain is complete when snarkOS enables `snarkvm/metrics`.
Collaborator
|
I would want this to be it's own feature flag for now. This would allow us to test this feature properly, before we set it to be part of the default |
Collaborator
|
Alternatively, out of an abundance of caution, roll this out on testnet client and validator before merging. Just because we are not yet able to simulate such large ledgers in our test environment. I dont think mainnet state will be materially different so testnet should be sufficient. |
Collaborator
|
Most failing CI was spurious, pushed an fmt fix |
Collaborator
|
testnet-based snarkOS branch for you to deploy and test: https://github.com/ProvableHQ/snarkOS/tree/update_snarkvm_rocksdb_metrics |
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.
Motivation
RocksDB internals are currently invisible to operators. This became apparent during a recent incident where a major compaction caused a ~1 TB disk spike over two hours — with no metrics to explain what was happening in real time.
This PR adds the key RocksDB properties to Prometheus, gated behind the existing
metricsfeature with zero overhead when disabled.What's added
Compaction pressure — early warning for write stalls:
snarkvm_rocksdb_compaction_pendingsnarkvm_rocksdb_estimate_pending_compaction_bytessnarkvm_rocksdb_num_running_compactionssnarkvm_rocksdb_num_running_flushessnarkvm_rocksdb_mem_table_flush_pendingDisk footprint — explains why disk grows unexpectedly:
snarkvm_rocksdb_total_sst_files_size_bytessnarkvm_rocksdb_live_sst_files_size_bytesThe gap between
totalandliveis disk held by open snapshots or checkpoints blocking file deletion. This gap is what caused the recent disk spike.General state:
snarkvm_rocksdb_num_snapshotstotal - livegapsnarkvm_rocksdb_estimate_num_keysPer-level SST file counts (
snarkvm_rocksdb_num_files_at_level0…level6):L0 is the critical one — writes land here first. When L0 file count climbs RocksDB throttles writes and eventually stalls. Levels 1–6 confirm compaction is draining the LSM tree normally.
Implementation
All values come from RocksDB's in-memory property counters (
DB::property_int_value) — no disk I/O, noStatisticsoverhead.Rather than spawning a background thread inside library code,
RocksDB::export_rocksdb_metrics()is a plain public method. The caller decides when to poll. The delegation chain follows the same pattern asbackup_database:Feature propagation:
snarkvm/metrics→snarkvm-ledger/metrics→snarkvm-ledger-store/metrics.A companion snarkOS PR calls
export_rocksdb_metrics()every ~15 s from the existing auto-checkpoint polling loop (no new thread).Test Plan