Skip to content

Commit

Permalink
fix mixed contract code cache size (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobayurii authored Jan 6, 2025
1 parent e7ab004 commit f0f7c26
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions rpc-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,20 @@ impl ServerContext {
crate::utils::gigabytes_to_bytes(rpc_server_config.general.contract_code_cache_size)
.await;

// For contract code cache we use 1/4 of total_contract_code_cache_size_in_bytes
let contract_code_cache_size_in_bytes = total_contract_code_cache_size_in_bytes / 4;
let contract_code_cache = std::sync::Arc::new(crate::cache::RwLockLruMemoryCache::new(
contract_code_cache_size_in_bytes,
));

// For compiled contract code cache we use 3/4 of total_contract_code_cache_size_in_bytes
// because the compiled contract code is bigger in 3 times than the contract code from the database
let compiled_contract_code_cache_size_in_bytes =
total_contract_code_cache_size_in_bytes / 4;
total_contract_code_cache_size_in_bytes - contract_code_cache_size_in_bytes;
let compiled_contract_code_cache = std::sync::Arc::new(CompiledCodeCache::new(
compiled_contract_code_cache_size_in_bytes,
));

// For contract code cache we use 1/4 of total_contract_code_cache_size_in_bytes
let contract_code_cache_size_in_bytes =
total_contract_code_cache_size_in_bytes - compiled_contract_code_cache_size_in_bytes;
let contract_code_cache = std::sync::Arc::new(crate::cache::RwLockLruMemoryCache::new(
contract_code_cache_size_in_bytes,
));

let total_block_cache_size_in_bytes =
crate::utils::gigabytes_to_bytes(rpc_server_config.general.block_cache_size).await;

Expand Down

0 comments on commit f0f7c26

Please sign in to comment.