Skip to content

Commit 995e216

Browse files
committed
[Hot State] Use config to replace hard-coded parameters
1 parent f7ef7f8 commit 995e216

File tree

16 files changed

+41
-47
lines changed

16 files changed

+41
-47
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/src/config/storage_config.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,29 @@ impl Default for RocksdbConfigs {
237237
}
238238
}
239239

240+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
241+
#[serde(default, deny_unknown_fields)]
242+
pub struct HotStateConfig {
243+
/// Max number of items in each shard.
244+
pub max_items_per_shard: usize,
245+
}
246+
247+
impl Default for HotStateConfig {
248+
fn default() -> Self {
249+
Self {
250+
max_items_per_shard: 250_000,
251+
}
252+
}
253+
}
254+
240255
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
241256
#[serde(default, deny_unknown_fields)]
242257
pub struct StorageConfig {
243258
pub backup_service_address: SocketAddr,
244259
/// Top level directory to store the RocksDB
245260
pub dir: PathBuf,
261+
/// Hot state configuration
262+
pub hot_state_config: HotStateConfig,
246263
/// Storage pruning configuration
247264
pub storage_pruner_config: PrunerConfig,
248265
/// Subdirectory for storage in tests only
@@ -406,6 +423,7 @@ impl Default for StorageConfig {
406423
StorageConfig {
407424
backup_service_address: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 6186),
408425
dir: PathBuf::from("db"),
426+
hot_state_config: HotStateConfig::default(),
409427
// The prune window must at least out live a RPC request because its sub requests are
410428
// to return a consistent view of the DB at exactly same version. Considering a few
411429
// thousand TPS we are potentially going to achieve, and a few minutes a consistent view

execution/executor-types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rust-version = { workspace = true }
1414

1515
[dependencies]
1616
anyhow = { workspace = true }
17+
aptos-config = { workspace = true }
1718
aptos-crypto = { workspace = true }
1819
aptos-drop-helper = { workspace = true }
1920
aptos-infallible = { workspace = true }

execution/executor-types/src/execution_output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use crate::{
77
planned::Planned,
88
transactions_with_output::{TransactionsToKeep, TransactionsWithOutput},
99
};
10+
use aptos_config::config::HotStateConfig;
1011
use aptos_drop_helper::DropHelper;
1112
use aptos_storage_interface::state_store::{
1213
state::LedgerState, state_view::cached_state_view::ShardedStateCache,
1314
};
1415
use aptos_types::{
1516
contract_event::ContractEvent,
1617
epoch_state::EpochState,
17-
state_store::hot_state::HotStateConfig,
1818
transaction::{
1919
block_epilogue::BlockEndInfo, ExecutionStatus, Transaction, TransactionStatus, Version,
2020
},

execution/executor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ rust-version = { workspace = true }
1515
[dependencies]
1616
anyhow = { workspace = true }
1717
aptos-block-executor = { workspace = true }
18+
aptos-config = { workspace = true }
1819
aptos-consensus-types = { workspace = true }
1920
aptos-crypto = { workspace = true }
2021
aptos-drop-helper = { workspace = true }

execution/executor/src/block_executor/block_tree/test.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ use crate::{
55
block_executor::block_tree::{epoch_genesis_block_id, BlockLookup, BlockTree},
66
types::partial_state_compute_result::PartialStateComputeResult,
77
};
8+
use aptos_config::config::HotStateConfig;
89
use aptos_crypto::{hash::PRE_GENESIS_BLOCK_ID, HashValue};
910
use aptos_infallible::Mutex;
1011
use aptos_storage_interface::LedgerSummary;
11-
use aptos_types::{
12-
block_info::BlockInfo, epoch_state::EpochState, ledger_info::LedgerInfo,
13-
state_store::hot_state::HotStateConfig,
14-
};
12+
use aptos_types::{block_info::BlockInfo, epoch_state::EpochState, ledger_info::LedgerInfo};
1513
use std::sync::Arc;
1614

1715
impl BlockTree {

execution/executor/src/workflow/do_get_execution_output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,12 @@ impl TStateView for WriteSetStateView<'_> {
564564
#[cfg(test)]
565565
mod tests {
566566
use super::Parser;
567+
use aptos_config::config::HotStateConfig;
567568
use aptos_storage_interface::state_store::{
568569
state::LedgerState, state_view::cached_state_view::CachedStateView,
569570
};
570571
use aptos_types::{
571572
contract_event::ContractEvent,
572-
state_store::hot_state::HotStateConfig,
573573
transaction::{
574574
AuxiliaryInfo, ExecutionStatus, PersistedAuxiliaryInfo, Transaction,
575575
TransactionAuxiliaryData, TransactionOutput, TransactionStatus,

storage/aptosdb/src/state_store/hot_state.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33

44
use crate::metrics::{COUNTER, GAUGE, OTHER_TIMERS_SECONDS};
55
use anyhow::{ensure, Result};
6+
use aptos_config::config::HotStateConfig;
67
use aptos_infallible::Mutex;
78
use aptos_logger::prelude::*;
89
use aptos_metrics_core::{IntCounterVecHelper, IntGaugeVecHelper, TimerHelper};
910
use aptos_storage_interface::state_store::{
1011
state::State, state_view::hot_state_view::HotStateView,
1112
};
1213
use aptos_types::state_store::{
13-
hot_state::{HotStateConfig, THotStateSlot},
14-
state_key::StateKey,
15-
state_slot::StateSlot,
16-
NUM_STATE_SHARDS,
14+
hot_state::THotStateSlot, state_key::StateKey, state_slot::StateSlot, NUM_STATE_SHARDS,
1715
};
1816
#[cfg(test)]
1917
use aptos_types::transaction::Version;

storage/aptosdb/src/state_store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use crate::{
3030
ShardedStateKvSchemaBatch,
3131
},
3232
};
33+
use aptos_config::config::HotStateConfig;
3334
use aptos_crypto::{
3435
hash::{CryptoHash, CORRUPTION_SENTINEL, SPARSE_MERKLE_PLACEHOLDER_HASH},
3536
HashValue,
@@ -63,7 +64,6 @@ use aptos_storage_interface::{
6364
use aptos_types::{
6465
proof::{definition::LeafCount, SparseMerkleProofExt, SparseMerkleRangeProof},
6566
state_store::{
66-
hot_state::HotStateConfig,
6767
state_key::{prefix::StateKeyPrefix, StateKey},
6868
state_slot::StateSlot,
6969
state_storage_usage::StateStorageUsage,

storage/aptosdb/src/state_store/persisted_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// Licensed pursuant to the Innovation-Enabling Source Code License, available at https://github.com/aptos-labs/aptos-core/blob/main/LICENSE
33

44
use crate::{metrics::OTHER_TIMERS_SECONDS, state_store::hot_state::HotState};
5+
use aptos_config::config::HotStateConfig;
56
use aptos_infallible::Mutex;
67
use aptos_metrics_core::TimerHelper;
78
use aptos_scratchpad::SUBTREE_DROPPER;
89
use aptos_storage_interface::state_store::{
910
state::State, state_summary::StateSummary, state_view::hot_state_view::HotStateView,
1011
state_with_summary::StateWithSummary,
1112
};
12-
use aptos_types::state_store::hot_state::HotStateConfig;
1313
use std::sync::Arc;
1414

1515
#[derive(Clone)]

0 commit comments

Comments
 (0)