Skip to content

Commit

Permalink
feat(rocksdb): refine configs (#1648)
Browse files Browse the repository at this point in the history
1. add db recovery mode for internal consistence: using PointInTimeRecovery
2. using pipeline write
3. smaller cache for rooch instance
popcnt1 authored May 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b710b27 commit 4b2913a
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/rooch-config/src/store_config.rs
Original file line number Diff line number Diff line change
@@ -19,8 +19,10 @@ pub static R_DEFAULT_DB_DIR: Lazy<PathBuf> = Lazy::new(|| PathBuf::from("roochdb
static R_DEFAULT_DB_MOVEOS_SUBDIR: Lazy<PathBuf> = Lazy::new(|| PathBuf::from("moveos_store"));
static R_DEFAULT_DB_ROOCH_SUBDIR: Lazy<PathBuf> = Lazy::new(|| PathBuf::from("rooch_store"));

pub const DEFAULT_ROCKSDB_ROW_CACHE_SIZE: u64 = 1 << 28; // 256MB, for Rooch DB instance, doesn't need too much row cache
pub const DEFAULT_ROCKSDB_BLOCK_CACHE_SIZE: u64 = 1 << 30; // 1GB, for Rooch DB instance, doesn't need too much block cache
// for Rooch DB instance, doesn't need too much row cache:
// store ledger tx and several meta. Most of the time, they are always requested for newer data
pub const DEFAULT_ROCKSDB_ROW_CACHE_SIZE: u64 = 1 << 24; // 16MB,
pub const DEFAULT_ROCKSDB_BLOCK_CACHE_SIZE: u64 = 1 << 26; // 64MB

#[derive(Clone, Default, Debug, Deserialize, PartialEq, Serialize, Parser)]
#[serde(deny_unknown_fields)]
2 changes: 2 additions & 0 deletions moveos/raw-store/src/rocks/mod.rs
Original file line number Diff line number Diff line change
@@ -225,6 +225,8 @@ impl RocksDB {
db_opts.set_max_write_buffer_number(config.max_write_buffer_numer as c_int);
let cache = Cache::new_lru_cache(config.row_cache_size as usize);
db_opts.set_row_cache(&cache);
db_opts.set_enable_pipelined_write(true);
db_opts.set_wal_recovery_mode(rocksdb::DBRecoveryMode::PointInTime); // for memtable crash recovery
db_opts

// db_opts.enable_statistics();

0 comments on commit 4b2913a

Please sign in to comment.