Batch RocksDB writes in snapcake for improved I/O performance#101
Merged
liuchengxu merged 5 commits intomainfrom Jan 3, 2026
Merged
Batch RocksDB writes in snapcake for improved I/O performance#101liuchengxu merged 5 commits intomainfrom
liuchengxu merged 5 commits intomainfrom
Conversation
Instead of writing each UTXO individually to RocksDB (2-3 operations per UTXO), collect all UTXOs from a state response and write them in a single atomic batch using rocksdb::WriteBatch. This reduces disk operations from ~360M+ to ~18K for mainnet, providing 10,000-20,000x fewer disk operations. Changes: - Replace push()/store_utxo() with push_batch()/store_utxos_batch() - Use rocksdb::WriteBatch for atomic batch writes - Pre-allocate Vec based on response entry count
- Fix typo: key_vlaue_state_entry → key_value_state_entry - Extract magic number 6 to CONFIRMATION_DEPTH constant - Replace abrupt std::process::exit(0) with shutdown channel signal for cleaner separation of concerns
By default, mDNS and local peer discovery are disabled in snapcake. This adds a --discover-local flag that enables mDNS-based discovery for development and testing scenarios with multiple nodes on the same local network.
Group snapcake-specific parameters into SnapcakeSyncParams struct to reduce function arguments from 8 to 4.
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.
Summary
rocksdb::WriteBatchTest plan