From 9c9de1e36c09cd9b618385d42dc17b80896a5330 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Fri, 6 Dec 2024 18:52:17 +0000 Subject: [PATCH] A benchmark suite for the `getFirstAvailableBlock` RPC call --- 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 e800945a321cce..d24355c90a217a 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -237,6 +237,7 @@ pub enum RpcBench { MultipleAccounts, ProgramAccounts, TokenAccountsByOwner, + FirstAvailableBlock, } #[derive(Debug)] @@ -249,6 +250,7 @@ impl FromStr for RpcBench { fn from_str(s: &str) -> Result { match s { + "first-available-block" => Ok(RpcBench::FirstAvailableBlock), "slot" => Ok(RpcBench::Slot), "multiple-accounts" => Ok(RpcBench::MultipleAccounts), "token-accounts-by-owner" => Ok(RpcBench::TokenAccountsByOwner), @@ -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() {