Skip to content

Commit

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

#[derive(Debug)]
Expand All @@ -270,6 +271,7 @@ impl FromStr for RpcBench {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"account-info" => Ok(RpcBench::AccountInfo),
"first-available-block" => Ok(RpcBench::FirstAvailableBlock),
"slot" => Ok(RpcBench::Slot),
"supply" => Ok(RpcBench::Supply),
"multiple-accounts" => Ok(RpcBench::MultipleAccounts),
Expand Down Expand Up @@ -421,6 +423,25 @@ fn run_rpc_bench_loop(
}
}
}
RpcBench::FirstAvailableBlock => {
let mut rpc_time = Measure::start("rpc-get-first-available-block");
match client.get_first_available_block() {
Ok(_slot) => {
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_first_available_block 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 6bb3a03

Please sign in to comment.