Skip to content

Commit

Permalink
Wait for at least one account to have been created before starting th…
Browse files Browse the repository at this point in the history
…e account benchmarks
  • Loading branch information
steveluscher committed Dec 6, 2024
1 parent ca6d205 commit 0b0d539
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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 accounts-cluster-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ edition = { workspace = true }

[dependencies]
clap = { workspace = true }
crossbeam-channel = { workspace = true }
log = { workspace = true }
rand = { workspace = true }
rayon = { workspace = true }
Expand Down
10 changes: 9 additions & 1 deletion accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(clippy::arithmetic_side_effects)]
use {
clap::{crate_description, crate_name, value_t, values_t, values_t_or_exit, App, Arg},
crossbeam_channel::{unbounded, Receiver},
log::*,
rand::{thread_rng, Rng},
rayon::prelude::*,
Expand Down Expand Up @@ -353,7 +354,7 @@ fn run_rpc_bench_loop(
}
let seed = thread_rng().gen_range(seed_range).to_string();
let account_pubkey =
Pubkey::create_with_seed(&base_keypair_pubkey, &seed, &program_id).unwrap();
Pubkey::create_with_seed(base_keypair_pubkey, &seed, program_id).unwrap();
match client.get_account(&account_pubkey) {
Ok(_account) => {
rpc_time.stop();
Expand Down Expand Up @@ -490,6 +491,7 @@ fn run_rpc_bench_loop(
fn make_rpc_bench_threads(
rpc_benches: Vec<RpcBench>,
mint: &Option<Pubkey>,
start_bench_rx: &Receiver<()>,
exit: &Arc<AtomicBool>,
client: &Arc<RpcClient>,
seed_tracker: &SeedTracker,
Expand All @@ -506,13 +508,15 @@ fn make_rpc_bench_threads(
.flat_map(|rpc_bench| {
(0..num_rpc_bench_threads).map(move |thread| {
let client = client.clone();
let start = start_bench_rx.clone();
let exit = exit.clone();
let max_closed = seed_tracker.max_closed.clone();
let max_created = seed_tracker.max_created.clone();
let mint = *mint;
Builder::new()
.name(format!("rpc-bench-{}", thread))
.spawn(move || {
start.recv().unwrap();
run_rpc_bench_loop(
rpc_bench,
thread,
Expand Down Expand Up @@ -599,11 +603,13 @@ fn run_accounts_bench(
);

let exit = Arc::new(AtomicBool::new(false));
let (start_bench_tx, start_bench_rx) = unbounded();
let base_keypair_pubkey = base_keypair.pubkey();
let rpc_bench_threads: Vec<_> = if let Some(rpc_benches) = rpc_benches {
make_rpc_bench_threads(
rpc_benches,
&mint,
&start_bench_rx,
&exit,
&client,
&seed_tracker,
Expand Down Expand Up @@ -714,6 +720,8 @@ fn run_accounts_bench(
let _ = executor.drain_cleared();
}

start_bench_tx.send(()).unwrap();

count += 1;
let max_accounts_met = if let Some(max_accounts) = max_accounts {
total_accounts_created >= max_accounts
Expand Down

0 comments on commit 0b0d539

Please sign in to comment.