Skip to content

Commit

Permalink
A benchmark suite for the getFirstAvailableBlock RPC call
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Dec 6, 2024
1 parent b3c2274 commit 9c9de1e
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 @@ -237,6 +237,7 @@ pub enum RpcBench {
MultipleAccounts,
ProgramAccounts,
TokenAccountsByOwner,
FirstAvailableBlock,
}

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

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"first-available-block" => Ok(RpcBench::FirstAvailableBlock),
"slot" => Ok(RpcBench::Slot),
"multiple-accounts" => Ok(RpcBench::MultipleAccounts),
"token-accounts-by-owner" => Ok(RpcBench::TokenAccountsByOwner),
Expand Down Expand Up @@ -340,6 +342,25 @@ fn run_rpc_bench_loop(
break;
}
match rpc_bench {
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 9c9de1e

Please sign in to comment.