-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(db): Fine-tune state keeper cache performance / RAM usage (#1804)
## What ❔ Allows to configure state keeper cache performance / RAM usage on EN. ## Why ❔ Right now, state keeper cache uses very small block cache (order of 5 MB), and eventually loads ~8 GB of SST files into the page cache. Both can be configured more optimally (by increasing block cache size and setting max open files for RocksDB). ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `zk spellcheck`. - [x] Linkcheck has been run via `zk linkcheck`.
- Loading branch information
Showing
25 changed files
with
363 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! Experimental part of configuration. | ||
use std::num::NonZeroU32; | ||
|
||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Clone, PartialEq, Deserialize)] | ||
pub struct ExperimentalDBConfig { | ||
/// Block cache capacity of the state keeper RocksDB cache. The default value is 128 MB. | ||
#[serde(default = "ExperimentalDBConfig::default_state_keeper_db_block_cache_capacity_mb")] | ||
pub state_keeper_db_block_cache_capacity_mb: usize, | ||
/// Maximum number of files concurrently opened by state keeper cache RocksDB. Useful to fit into OS limits; can be used | ||
/// as a rudimentary way to control RAM usage of the cache. | ||
pub state_keeper_db_max_open_files: Option<NonZeroU32>, | ||
} | ||
|
||
impl Default for ExperimentalDBConfig { | ||
fn default() -> Self { | ||
Self { | ||
state_keeper_db_block_cache_capacity_mb: | ||
Self::default_state_keeper_db_block_cache_capacity_mb(), | ||
state_keeper_db_max_open_files: None, | ||
} | ||
} | ||
} | ||
|
||
impl ExperimentalDBConfig { | ||
const fn default_state_keeper_db_block_cache_capacity_mb() -> usize { | ||
128 | ||
} | ||
|
||
pub fn state_keeper_db_block_cache_capacity(&self) -> usize { | ||
self.state_keeper_db_block_cache_capacity_mb * super::BYTES_IN_MEGABYTE | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.