Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rooch-da): add cache size options for rocksdb #3115

Merged
merged 2 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions crates/rooch/src/commands/da/commands/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ pub struct ExecCommand {
#[clap(long = "btc-local-block-store-dir")]
pub btc_local_block_store_dir: Option<PathBuf>,

#[clap(name = "rocksdb-row-cache-size", long, help = "rocksdb row cache size")]
pub row_cache_size: Option<u64>,

#[clap(
name = "rocksdb-block-cache-size",
long,
help = "rocksdb block cache size"
)]
pub block_cache_size: Option<u64>,
#[clap(long = "enable-rocks-stats", help = "rocksdb-enable-statistics")]
pub enable_rocks_stats: bool,

Expand Down Expand Up @@ -108,6 +117,8 @@ impl ExecCommand {
self.chain_id.clone(),
&actor_system,
self.enable_rocks_stats,
self.row_cache_size,
self.block_cache_size,
)
.await?;

Expand Down Expand Up @@ -508,11 +519,18 @@ async fn build_executor_and_store(
chain_id: Option<RoochChainID>,
actor_system: &ActorSystem,
enable_rocks_stats: bool,
row_cache_size: Option<u64>,
block_cache_size: Option<u64>,
) -> anyhow::Result<(ExecutorProxy, MoveOSStore, RoochDB)> {
let registry_service = RegistryService::default();

let (root, rooch_db) =
build_rooch_db(base_data_dir.clone(), chain_id.clone(), enable_rocks_stats);
let (root, rooch_db) = build_rooch_db(
base_data_dir.clone(),
chain_id.clone(),
enable_rocks_stats,
row_cache_size,
block_cache_size,
);
let (rooch_store, moveos_store) = (rooch_db.rooch_store.clone(), rooch_db.moveos_store.clone());

let event_bus = EventBus::new();
Expand Down
4 changes: 4 additions & 0 deletions crates/rooch/src/commands/da/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ pub(crate) fn build_rooch_db(
base_data_dir: Option<PathBuf>,
chain_id: Option<RoochChainID>,
enable_rocks_stats: bool,
row_cache_size: Option<u64>,
block_cache_size: Option<u64>,
) -> (ObjectMeta, RoochDB) {
let mut opt = RoochOpt::new_with_default(base_data_dir, chain_id, None).unwrap();
opt.store.enable_statistics = enable_rocks_stats;
opt.store.row_cache_size = row_cache_size;
opt.store.block_cache_size = block_cache_size;
let registry_service = RegistryService::default();
let rooch_db = RoochDB::init(opt.store_config(), &registry_service.default_registry()).unwrap();
let root = rooch_db.latest_root().unwrap().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch/src/commands/da/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ impl CommandAction<String> for DA {
pub enum DACommand {
Unpack(UnpackCommand),
Namespace(NamespaceCommand),
Exec(ExecCommand),
Exec(Box<ExecCommand>),
IndexTx(IndexTxCommand),
}
Loading