Skip to content

Commit

Permalink
A benchmark suite for the getAccountInfo RPC call (#3959)
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher authored Dec 9, 2024
1 parent e9e211f commit bd04d77
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ pub enum RpcBench {
TokenAccountsByOwner,
Supply,
TokenAccountsByDelegate,
AccountInfo,
}

#[derive(Debug)]
Expand All @@ -268,6 +269,7 @@ impl FromStr for RpcBench {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"account-info" => Ok(RpcBench::AccountInfo),
"slot" => Ok(RpcBench::Slot),
"supply" => Ok(RpcBench::Supply),
"multiple-accounts" => Ok(RpcBench::MultipleAccounts),
Expand Down Expand Up @@ -390,6 +392,35 @@ fn run_rpc_bench_loop(
break;
}
match rpc_bench {
RpcBench::AccountInfo => {
let start: u64 = max_closed.load(Ordering::Relaxed);
let end: u64 = max_created.load(Ordering::Relaxed);
let seed_range = start..end;
if seed_range.is_empty() {
info!("get_account_info: No accounts have yet been created; skipping");
continue;
}
let seed = thread_rng().gen_range(seed_range).to_string();
let account_pubkey =
Pubkey::create_with_seed(base_keypair_pubkey, &seed, program_id).unwrap();
let mut rpc_time = Measure::start("rpc-get-account-info");
match client.get_account(&account_pubkey) {
Ok(_account) => {
rpc_time.stop();
stats.success += 1;
stats.total_success_time_us += rpc_time.as_us();
}
Err(e) => {
rpc_time.stop();
stats.total_errors_time_us += rpc_time.as_us();
stats.errors += 1;
if last_error.elapsed().as_secs() > 2 {
info!("get_account_info error: {:?}", e);
last_error = Instant::now();
}
}
}
}
RpcBench::Slot => {
let mut rpc_time = Measure::start("rpc-get-slot");
match client.get_slot() {
Expand Down

0 comments on commit bd04d77

Please sign in to comment.