Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A benchmark suite for the getTokenSupply RPC call #4048

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ pub enum RpcBench {
Transaction,
TransactionParsed,
FirstAvailableBlock,
TokenSupply,
}

#[derive(Debug)]
Expand All @@ -339,6 +340,7 @@ impl FromStr for RpcBench {
"multiple-accounts" => Ok(RpcBench::MultipleAccounts),
"token-accounts-by-delegate" => Ok(RpcBench::TokenAccountsByDelegate),
"token-accounts-by-owner" => Ok(RpcBench::TokenAccountsByOwner),
"token-supply" => Ok(RpcBench::TokenSupply),
"transaction" => Ok(RpcBench::Transaction),
"transaction-parsed" => Ok(RpcBench::TransactionParsed),
"version" => Ok(RpcBench::Version),
Expand Down Expand Up @@ -701,6 +703,27 @@ fn run_rpc_bench_loop(
}
}
}
RpcBench::TokenSupply => {
let mut rpc_time = Measure::start("rpc-get-token-supply");
match client
.get_token_supply_with_commitment(&mint.unwrap(), CommitmentConfig::confirmed())
{
Ok(_ui_token_amount) => {
rpc_time.stop();
stats.success += 1;
stats.total_success_time_us += rpc_time.as_us();
}
Err(e) => {
rpc_time.stop();
stats.errors += 1;
stats.total_errors_time_us += rpc_time.as_us();
if last_error.elapsed().as_secs() > 2 {
info!("get-token-supply error: {:?}", e);
last_error = Instant::now();
}
}
}
}
RpcBench::Transaction => {
process_get_transaction(
"rpc-get-transaction-base64",
Expand Down Expand Up @@ -1264,6 +1287,7 @@ fn main() {
.requires_ifs(&[
("supply", "mint"),
("token-accounts-by-owner", "mint"),
("token-supply", "mint"),
])
.help("Spawn a thread which calls a specific RPC method in a loop to benchmark it"),
)
Expand Down
Loading