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

[Execution] Increase the default concurrency to 32 #12200

Merged
merged 1 commit into from
Feb 24, 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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions aptos-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fail = { workspace = true }
futures = { workspace = true }
hex = { workspace = true }
maplit = { workspace = true }
num_cpus = { workspace = true }
rand = { workspace = true }
rayon = { workspace = true }
serde = { workspace = true }
Expand Down
10 changes: 8 additions & 2 deletions aptos-node/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// SPDX-License-Identifier: Apache-2.0

use anyhow::anyhow;
use aptos_config::config::NodeConfig;
use aptos_config::config::{NodeConfig, DEFAULT_CONCURRENCY_LEVEL};
use aptos_storage_interface::{state_view::LatestDbStateCheckpointView, DbReaderWriter};
use aptos_types::{
account_config::CORE_CODE_ADDRESS, account_view::AccountView, chain_id::ChainId,
state_store::account_with_state_view::AsAccountWithStateView,
};
use aptos_vm::AptosVM;
use std::cmp::min;

/// Error message to display when non-production features are enabled
pub const ERROR_MSG_BAD_FEATURE_FLAGS: &str = r#"
Expand Down Expand Up @@ -49,7 +50,12 @@ pub fn fetch_chain_id(db: &DbReaderWriter) -> anyhow::Result<ChainId> {
/// Sets the Aptos VM configuration based on the node configurations
pub fn set_aptos_vm_configurations(node_config: &NodeConfig) {
AptosVM::set_paranoid_type_checks(node_config.execution.paranoid_type_verification);
AptosVM::set_concurrency_level_once(node_config.execution.concurrency_level as usize);
let effective_concurrency_level = if node_config.execution.concurrency_level == 0 {
min(DEFAULT_CONCURRENCY_LEVEL, (num_cpus::get() / 2) as u16)
} else {
node_config.execution.concurrency_level
};
AptosVM::set_concurrency_level_once(effective_concurrency_level as usize);
AptosVM::set_discard_failed_blocks(node_config.execution.discard_failed_blocks);
AptosVM::set_num_proof_reading_threads_once(
node_config.execution.num_proof_reading_threads as usize,
Expand Down
8 changes: 5 additions & 3 deletions config/src/config/execution_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::{
};

const GENESIS_DEFAULT: &str = "genesis.blob";
pub const DEFAULT_CONCURRENCY_LEVEL: u16 = 32;

#[derive(Clone, Deserialize, PartialEq, Eq, Serialize)]
#[serde(default, deny_unknown_fields)]
Expand All @@ -25,7 +26,8 @@ pub struct ExecutionConfig {
pub genesis: Option<Transaction>,
/// Location of the genesis file
pub genesis_file_location: PathBuf,
/// Number of threads to run execution
/// Number of threads to run execution.
/// If 0, we use min of (num of cores/2, DEFAULT_CONCURRENCY_LEVEL) as default concurrency level
pub concurrency_level: u16,
/// Number of threads to read proofs
pub num_proof_reading_threads: u16,
Expand Down Expand Up @@ -64,8 +66,8 @@ impl Default for ExecutionConfig {
ExecutionConfig {
genesis: None,
genesis_file_location: PathBuf::new(),
// Parallel execution by default.
concurrency_level: 8,
// use min of (num of cores/2, DEFAULT_CONCURRENCY_LEVEL) as default concurrency level
concurrency_level: 0,
num_proof_reading_threads: 32,
paranoid_type_verification: true,
paranoid_hot_potato_verification: true,
Expand Down
Loading