Skip to content

Commit 3b05d1c

Browse files
feat: ratelimiting and other ux improvements (#4)
* 50k conns? * rm: json parsing on testserver * huge backlog * allow get * log concurrent * limit to 1 worker * 50 workers * feat: hyper * fix? * actix -> axum * Update main.rs * rm batch factor * 3 second measurement interval * Update main.rs * worker id * request durr * fix: workers * Update network.rs * fix ids * feat: implied total rps * Update network.rs * Update network.rs * Create genesis.json * genalloc * 25k * start reth * 50k again? * wip: try one of 10k addrs * even workers * 20k conns * Update main.rs * back to 20 acc * 100 accounts * 100 acc * 2500 accounts * oops fix tx queue reporting * feat: rand addr * 500 accounts * use existing people, log * allow dead code * Update tx_gen.rs * lawging * hrmf * 1k accs * 10k accounts * wip: startup delay * Update tx_queue.rs * Update tx_queue.rs * log * moar thresholds * Update tx_queue.rs * feat: rayonify * Update tx_gen.rs * 50k connections? * Revert "50k connections?" This reverts commit 34ec48c. * log rayon thread pool size * Update tx_gen.rs * Initialize Rayon with explicit thread count. * Update tx_gen.rs * Update tx_gen.rs * feat: alternate ratelimit system * Update tx_queue.rs * Update tx_queue.rs * Update tx_queue.rs * Update tx_queue.rs * Update tx_queue.rs * hm * thresholds * Update tx_queue.rs * Update tx_queue.rs * Update tx_queue.rs * thresholds * Update tx_queue.rs * fewer socket conns * 10k connections * 50k RPS? * feat: longer ramp * 35k rps? * Update tx_queue.rs * 25k * Update start-reth.sh * Update genesis.json * Update start-reth.sh * batch factor of 5 * fix: implied rps * disable batching * feat: even slower ramp up * slightly faster * feat: 50k genesis * feat: better ramp * oops * worker ratio * feat: pareto distribute recipients * Update tx_gen.rs * Empty the rate limiter. * feat: empty rate limiter before AND after * wip: can we remove first set avail? * 15k tps * 20k? * 15k again * feat: ramp up faster * even faster * faster!
1 parent d945d37 commit 3b05d1c

File tree

10 files changed

+150417
-67
lines changed

10 files changed

+150417
-67
lines changed

Cargo.lock

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

crescendo/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@ alloy = { version = "1", features = ["genesis", "signers"] }
1919
alloy-evm = "0.13"
2020
alloy-consensus = { version = "1", features = ["secp256k1"] }
2121
alloy-signer-local = { version = "1", features = ["mnemonic"] }
22-
core_affinity = "0.8.3"
22+
core_affinity = "0.8.3"
23+
rayon = "1.10"
24+
serde = { version = "1.0", features = ["derive"] }
25+
serde_json = "1.0"
26+
hex = "0.4"
27+
simple-tqdm = { version = "0.2.0", features = ["rayon"] }
28+
rand = "0.9.1"
29+
ratelimit = "0.10"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
use std::collections::BTreeMap;
2+
use std::fs;
3+
use std::path::Path;
4+
5+
use alloy::signers::local::MnemonicBuilder;
6+
use alloy::signers::utils::secret_key_to_address;
7+
use alloy_signer_local::coins_bip39::English;
8+
use rayon::prelude::*;
9+
use serde::{Deserialize, Serialize};
10+
use simple_tqdm::ParTqdm;
11+
12+
#[derive(Debug, Serialize, Deserialize)]
13+
struct AccountBalance {
14+
balance: String,
15+
}
16+
17+
fn main() -> Result<(), Box<dyn std::error::Error>> {
18+
const NUM_ACCOUNTS: u32 = 50_000;
19+
const MNEMONIC: &str = "test test test test test test test test test test test junk";
20+
21+
println!("Generating {} accounts...", NUM_ACCOUNTS);
22+
23+
let genesis_alloc: BTreeMap<String, AccountBalance> = (0..NUM_ACCOUNTS)
24+
.into_par_iter()
25+
.tqdm()
26+
.map(|worker_id| {
27+
let signer =
28+
MnemonicBuilder::<English>::default().phrase(MNEMONIC).index(worker_id).unwrap().build().unwrap();
29+
30+
let address = secret_key_to_address(&signer.credential());
31+
32+
(format!("{:?}", address), AccountBalance { balance: "0xD3C21BCECCEDA1000000".to_string() })
33+
})
34+
.collect();
35+
36+
let output_path = Path::new("genesis-alloc.json");
37+
let json = serde_json::to_string_pretty(&genesis_alloc)?;
38+
fs::write(output_path, json)?;
39+
40+
println!("\nSuccessfully generated {} accounts!", NUM_ACCOUNTS);
41+
println!("Accounts saved to: {}", output_path.display());
42+
43+
Ok(())
44+
}

crescendo/src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::workers::{DesireType, WorkerType};
2020
static GLOBAL: MiMalloc = MiMalloc;
2121

2222
// TODO: Configurable CLI args.
23-
const TOTAL_CONNECTIONS: u64 = 50_000; // This is limited by the amount of ephemeral ports available on the system.
23+
const TOTAL_CONNECTIONS: u64 = 10_000; // This is limited by the amount of ephemeral ports available on the system.
2424
const THREAD_PINNING: bool = true;
2525
const TARGET_URL: &str = "http://127.0.0.1:8545";
2626

@@ -33,13 +33,16 @@ async fn main() {
3333
let mut core_ids = core_affinity::get_core_ids().unwrap();
3434
println!("[*] Detected {} effective cores.", core_ids.len());
3535

36+
// Initialize Rayon with explicit thread count.
37+
rayon::ThreadPoolBuilder::new().num_threads(core_ids.len()).build_global().unwrap();
38+
3639
// Pin the tokio runtime to a core (if enabled).
3740
utils::maybe_pin_thread(core_ids.pop().unwrap(), THREAD_PINNING);
3841

3942
// Given our desired breakdown of workers, translate this into actual numbers of workers to spawn.
4043
let (workers, worker_counts) = workers::assign_workers(
4144
core_ids, // Doesn't include the main runtime core.
42-
vec![(WorkerType::TxGen, DesireType::Exact(20)), (WorkerType::Network, DesireType::Percentage(1.0))],
45+
vec![(WorkerType::TxGen, DesireType::Percentage(0.1)), (WorkerType::Network, DesireType::Percentage(0.9))],
4346
THREAD_PINNING, // Only log core ranges if thread pinning is actually enabled.
4447
);
4548

0 commit comments

Comments
 (0)