From 6bb3a03657b0fcd86b8d00539ceec405e3cf5035 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Mon, 9 Dec 2024 12:57:48 -0500 Subject: [PATCH] A benchmark suite for the `getFirstAvailableBlock` RPC call (#3982) --- accounts-cluster-bench/src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index dfd89dbdffb4d5..258e471303edab 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -257,6 +257,7 @@ pub enum RpcBench { Supply, TokenAccountsByDelegate, AccountInfo, + FirstAvailableBlock, } #[derive(Debug)] @@ -270,6 +271,7 @@ impl FromStr for RpcBench { fn from_str(s: &str) -> Result { 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), @@ -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() {