diff --git a/Cargo.lock b/Cargo.lock index c7d46fc..1b32c93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1599,6 +1599,7 @@ dependencies = [ "clap", "core_affinity", "crossbeam-utils", + "dashmap", "hex", "http", "http-body-util", diff --git a/configs/max.toml b/configs/max.toml new file mode 100644 index 0000000..d5b4cf9 --- /dev/null +++ b/configs/max.toml @@ -0,0 +1,17 @@ +inherits = "aggressive.toml" + +[rate_limiting] +initial_ratelimit = 500 +ratelimit_thresholds = [ + [2_500, 1_000], + [5_000, 2_500], + [25_000, 500_000], +] + +[network_worker] +total_connections = 20_000 +tx_queue_empty_sleep_ms = 5 + +[workers] +tx_gen_worker_percentage = 0.3 +network_worker_percentage = 0.7 diff --git a/crescendo/Cargo.toml b/crescendo/Cargo.toml index 4888976..7ff91e6 100644 --- a/crescendo/Cargo.toml +++ b/crescendo/Cargo.toml @@ -29,4 +29,5 @@ rand = "0.9.1" ratelimit = "0.10" clap = { version = "4.5", features = ["derive", "env"] } toml = "0.8" -parking_lot = "0.12.4" \ No newline at end of file +parking_lot = "0.12.4" +dashmap = "6.1" \ No newline at end of file diff --git a/crescendo/src/workers/tx_gen.rs b/crescendo/src/workers/tx_gen.rs index c1fa9ff..6511a4a 100644 --- a/crescendo/src/workers/tx_gen.rs +++ b/crescendo/src/workers/tx_gen.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::sync::LazyLock; use std::time::Instant; @@ -9,7 +8,7 @@ use alloy::sol_types::SolCall; use alloy_consensus::{SignableTransaction, TxLegacy}; use alloy_signer_local::coins_bip39::English; use alloy_signer_local::{MnemonicBuilder, PrivateKeySigner}; -use parking_lot::Mutex; +use dashmap::DashMap; use rand::Rng; use rayon::prelude::*; use thousands::Separable; @@ -17,12 +16,12 @@ use thousands::Separable; use crate::config; use crate::tx_queue::TX_QUEUE; -static NONCE_MAP: LazyLock>> = LazyLock::new(|| { - let mut map = HashMap::with_capacity(config::get().tx_gen_worker.num_accounts as usize); +static NONCE_MAP: LazyLock> = LazyLock::new(|| { + let map = DashMap::with_capacity(config::get().tx_gen_worker.num_accounts as usize); for i in 0..config::get().tx_gen_worker.num_accounts { map.insert(i, 0); } - Mutex::new(map) + map }); static SIGNER_LIST: LazyLock> = LazyLock::new(|| { @@ -54,9 +53,9 @@ pub fn tx_gen_worker(_worker_id: u32) { // Get and increment nonce atomically. let nonce = { - let mut nonce_map = NONCE_MAP.lock(); - let current_nonce = *nonce_map.get(&account_index).unwrap(); - nonce_map.insert(account_index, current_nonce + 1); + let mut entry = NONCE_MAP.get_mut(&account_index).unwrap(); + let current_nonce = *entry; + *entry = current_nonce + 1; current_nonce }; diff --git a/testserver/src/main.rs b/testserver/src/main.rs index a66e8d8..ca177b5 100644 --- a/testserver/src/main.rs +++ b/testserver/src/main.rs @@ -17,7 +17,7 @@ static CONCURRENT_REQUESTS: CachePadded = CachePadded::new(AtomicU64: async fn handler() -> Json { CONCURRENT_REQUESTS.fetch_add(1, Ordering::Relaxed); - tokio::time::sleep(Duration::from_millis(500)).await; // Simulate processing time. + tokio::time::sleep(Duration::from_millis(1)).await; // Simulate processing time. CONCURRENT_REQUESTS.fetch_sub(1, Ordering::Relaxed); TOTAL_REQUESTS.fetch_add(1, Ordering::Relaxed); Json(json!({