Skip to content
Merged
Show file tree
Hide file tree
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
53 changes: 26 additions & 27 deletions bench-tps/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ where
let bsps = (tx_count) as f64 / ns as f64;
let nsps = ns as f64 / (tx_count) as f64;
info!(
"Done. {:.2} thousand signatures per second, {:.2} us per signature, {} ms total time, {:?}",
"Done. {:.2} thousand signatures per second, {:.2} us per signature, {} ms total \
time, {:?}",
bsps * 1_000_000_f64,
nsps / 1_000_f64,
duration.as_millis(),
Expand Down Expand Up @@ -266,14 +267,11 @@ where
T: 'static + TpsClient + Send + Sync + ?Sized,
{
if target_slots_per_epoch != 0 {
info!(
"Waiting until epochs are {} slots long..",
target_slots_per_epoch
);
info!("Waiting until epochs are {target_slots_per_epoch} slots long..");
loop {
if let Ok(epoch_info) = client.get_epoch_info() {
if epoch_info.slots_in_epoch >= target_slots_per_epoch {
info!("Done epoch_info: {:?}", epoch_info);
info!("Done epoch_info: {epoch_info:?}");
break;
}
info!(
Expand All @@ -295,7 +293,7 @@ fn create_sampler_thread<T>(
where
T: 'static + TpsClient + Send + Sync + ?Sized,
{
info!("Sampling TPS every {} second...", sample_period);
info!("Sampling TPS every {sample_period} second...");
let maxes = maxes.clone();
let client = client.clone();
Builder::new()
Expand Down Expand Up @@ -440,12 +438,12 @@ where
match client.get_transaction_count() {
Ok(count) => break count,
Err(err) => {
info!("Couldn't get transaction count: {:?}", err);
info!("Couldn't get transaction count: {err:?}");
sleep(Duration::from_secs(1));
}
}
};
info!("Initial transaction count {}", first_tx_count);
info!("Initial transaction count {first_tx_count}");

let exit_signal = Arc::new(AtomicBool::new(false));

Expand Down Expand Up @@ -516,28 +514,28 @@ where

info!("Waiting for sampler threads...");
if let Err(err) = sample_thread.join() {
info!(" join() failed with: {:?}", err);
info!(" join() failed with: {err:?}");
}

// join the tx send threads
info!("Waiting for transmit threads...");
for t in sender_threads {
if let Err(err) = t.join() {
info!(" join() failed with: {:?}", err);
info!(" join() failed with: {err:?}");
}
}

if let Some(blockhash_thread) = blockhash_thread {
info!("Waiting for blockhash thread...");
if let Err(err) = blockhash_thread.join() {
info!(" join() failed with: {:?}", err);
info!(" join() failed with: {err:?}");
}
}

if let Some(log_transaction_service) = log_transaction_service {
info!("Waiting for log_transaction_service thread...");
if let Err(err) = log_transaction_service.join() {
info!(" join() failed with: {:?}", err);
info!(" join() failed with: {err:?}");
}
}

Expand All @@ -560,7 +558,7 @@ where
}

fn metrics_submit_lamport_balance(lamport_balance: u64) {
info!("Token balance: {}", lamport_balance);
info!("Token balance: {lamport_balance}");
datapoint_info!(
"bench-tps-lamport_balance",
("balance", lamport_balance, i64)
Expand Down Expand Up @@ -700,7 +698,7 @@ fn get_nonce_accounts<T: 'static + TpsClient + Send + Sync + ?Sized>(
return nonce_accounts;
}
Err(err) => {
info!("Couldn't get durable nonce account: {:?}", err);
info!("Couldn't get durable nonce account: {err:?}");
sleep(Duration::from_secs(1));
}
}
Expand Down Expand Up @@ -883,7 +881,7 @@ fn get_new_latest_blockhash<T: TpsClient + ?Sized>(
return Some(new_blockhash);
}
}
debug!("Got same blockhash ({:?}), will retry...", blockhash);
debug!("Got same blockhash ({blockhash:?}), will retry...");

// Retry ~twice during a slot
sleep(Duration::from_millis(DEFAULT_MS_PER_SLOT / 2));
Expand Down Expand Up @@ -962,7 +960,7 @@ fn do_tx_transfers<T: TpsClient + ?Sized>(
if let Some(txs) = txs {
shared_tx_thread_count.fetch_add(1, Ordering::Relaxed);
let num_txs = txs.len();
info!("Transferring 1 unit {} times...", num_txs);
info!("Transferring 1 unit {num_txs} times...");
let transfer_start = Instant::now();
let mut old_transactions = false;
let mut min_timestamp = u64::MAX;
Expand Down Expand Up @@ -1000,13 +998,16 @@ fn do_tx_transfers<T: TpsClient + ?Sized>(
sent_at: Utc::now(),
compute_unit_prices,
}) {
error!("Receiver has been dropped with error `{error}`, stop sending transactions.");
error!(
"Receiver has been dropped with error `{error}`, stop sending \
transactions."
);
break 'thread_loop;
}
}

if let Err(error) = client.send_batch(transactions) {
warn!("send_batch_sync in do_tx_transfers failed: {}", error);
warn!("send_batch_sync in do_tx_transfers failed: {error}");
}

datapoint_info!(
Expand Down Expand Up @@ -1084,10 +1085,7 @@ fn compute_and_report_stats(
if total_maxes > 0.0 {
let num_nodes_with_tps = maxes.read().unwrap().len() - nodes_with_zero_tps;
let average_max = total_maxes / num_nodes_with_tps as f32;
info!(
"\nAverage max TPS: {:.2}, {} nodes had 0 TPS",
average_max, nodes_with_zero_tps
);
info!("\nAverage max TPS: {average_max:.2}, {nodes_with_zero_tps} nodes had 0 TPS");
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if the leading newline should be here but gonna leave for this PR I think

}

let total_tx_send_count = total_tx_send_count as u64;
Expand All @@ -1097,7 +1095,8 @@ fn compute_and_report_stats(
0.0
};
info!(
"\nHighest TPS: {:.2} sampling period {}s max transactions: {} clients: {} drop rate: {:.2}",
"\nHighest TPS: {:.2} sampling period {}s max transactions: {} clients: {} drop rate: \
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this leading newline

{:.2}",
max_of_maxes,
sample_period,
max_tx_count,
Expand All @@ -1121,7 +1120,7 @@ pub fn generate_and_fund_keypairs<T: 'static + TpsClient + Send + Sync + ?Sized>
let rent = client.get_minimum_balance_for_rent_exemption(0)?;
let lamports_per_account = lamports_per_account + rent;

info!("Creating {} keypairs...", keypair_count);
info!("Creating {keypair_count} keypairs...");
let (mut keypairs, extra) = generate_keypairs(funding_key, keypair_count as u64);
fund_keypairs(
client,
Expand Down Expand Up @@ -1181,8 +1180,8 @@ pub fn fund_keypairs<T: 'static + TpsClient + Send + Sync + ?Sized>(

let funding_key_balance = client.get_balance(&funding_key.pubkey()).unwrap_or(0);
info!(
"Funding keypair balance: {} max_fee: {} lamports_per_account: {} extra: {} total: {}",
funding_key_balance, max_fee, lamports_per_account, extra, total
"Funding keypair balance: {funding_key_balance} max_fee: {max_fee} \
lamports_per_account: {lamports_per_account} extra: {extra} total: {total}"
);

if funding_key_balance < total + rent {
Expand Down
83 changes: 49 additions & 34 deletions bench-tps/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ impl Default for Config {

/// Defines and builds the CLI args for a run of the benchmark
pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
App::new(crate_name!()).about(crate_description!())
App::new(crate_name!())
.about(crate_description!())
.version(version)
.arg({
let arg = Arg::with_name("config_file")
Expand All @@ -146,8 +147,8 @@ pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
.global(true)
.validator(is_url_or_moniker)
.help(
"URL for Solana's JSON RPC or moniker (or their first letter): \
[mainnet-beta, testnet, devnet, localhost]",
"URL for Solana's JSON RPC or moniker (or their first letter): [mainnet-beta, \
testnet, devnet, localhost]",
),
)
.arg(
Expand Down Expand Up @@ -176,15 +177,16 @@ pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
.takes_value(true)
.hidden(hidden_unless_forced())
.help("Deprecated. Use --authority instead"),

)
.arg(
Arg::with_name("authority")
.short("a")
.long("authority")
.value_name("PATH")
.takes_value(true)
.help("File containing a client authority (keypair) to fund participating accounts"),
.help(
"File containing a client authority (keypair) to fund participating accounts",
),
)
.arg(
Arg::with_name("threads")
Expand All @@ -201,25 +203,24 @@ pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
.takes_value(true)
.help("Seconds to run benchmark, then exit; default is forever"),
)
.arg(
Arg::with_name("sustained")
.long("sustained")
.help("Use sustained performance mode vs. peak mode. This overlaps the tx generation with transfers."),
)
.arg(Arg::with_name("sustained").long("sustained").help(
"Use sustained performance mode vs. peak mode. This overlaps the tx generation with \
transfers.",
))
.arg(
Arg::with_name("tx_count")
.long("tx-count")
.alias("tx_count")
.value_name("NUM")
.takes_value(true)
.help("Number of transactions to send per batch")
.help("Number of transactions to send per batch"),
)
.arg(
Arg::with_name("keypair_multiplier")
.long("keypair-multiplier")
.value_name("NUM")
.takes_value(true)
.help("Multiply by transaction count to determine number of keypairs to create")
.help("Multiply by transaction count to determine number of keypairs to create"),
)
.arg(
Arg::with_name("thread-batch-sleep-ms")
Expand Down Expand Up @@ -249,60 +250,62 @@ pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
.value_name("LAMPORTS")
.takes_value(true)
.help(
"The cost in lamports that the cluster will charge for signature \
verification when the cluster is operating at target-signatures-per-slot",
"The cost in lamports that the cluster will charge for signature verification \
when the cluster is operating at target-signatures-per-slot",
),
)
.arg(
Arg::with_name("num_lamports_per_account")
.long("num-lamports-per-account")
.value_name("LAMPORTS")
.takes_value(true)
.help(
"Number of lamports per account.",
),
.help("Number of lamports per account."),
)
.arg(
Arg::with_name("target_slots_per_epoch")
.long("target-slots-per-epoch")
.value_name("SLOTS")
.takes_value(true)
.help(
"Wait until epochs are this many slots long.",
),
.help("Wait until epochs are this many slots long."),
)
.arg(
Arg::with_name("rpc_client")
.long("use-rpc-client")
.conflicts_with("tpu_client")
.takes_value(false)
.help("Submit transactions with a RpcClient")
.help("Submit transactions with a RpcClient"),
)
.arg(
Arg::with_name("tpu_client")
.long("use-tpu-client")
.conflicts_with("rpc_client")
.takes_value(false)
.help("Submit transactions with a TpuClient")
.help("Submit transactions with a TpuClient"),
)
.arg(
Arg::with_name("tpu_disable_quic")
.long("tpu-disable-quic")
.takes_value(false)
.help("DEPRECATED: Do not submit transactions via QUIC; only affects TpuClient (default) sends"),
.help(
"DEPRECATED: Do not submit transactions via QUIC; only affects TpuClient \
(default) sends",
),
)
.arg(
Arg::with_name("tpu_connection_pool_size")
.long("tpu-connection-pool-size")
.takes_value(true)
.help("Controls the connection pool size per remote address; only affects TpuClient (default) sends"),
.help(
"Controls the connection pool size per remote address; only affects TpuClient \
(default) sends",
),
)
.arg(
Arg::with_name("compute_unit_price")
.long("compute-unit-price")
.takes_value(true)
.validator(|s| is_within_range(s, 0..))
.help("Sets constant compute-unit-price to transfer transactions"),
.long("compute-unit-price")
.takes_value(true)
.validator(|s| is_within_range(s, 0..))
.help("Sets constant compute-unit-price to transfer transactions"),
)
.arg(
Arg::with_name("use_randomized_compute_unit_price")
Expand All @@ -329,20 +332,29 @@ pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
.requires("instruction_padding_data_size")
.takes_value(true)
.value_name("PUBKEY")
.help("If instruction data is padded, optionally specify the padding program id to target"),
.help(
"If instruction data is padded, optionally specify the padding program id to \
target",
),
)
.arg(
Arg::with_name("instruction_padding_data_size")
.long("instruction-padding-data-size")
.takes_value(true)
.help("If set, wraps all instructions in the instruction padding program, with the given amount of padding bytes in instruction data."),
.help(
"If set, wraps all instructions in the instruction padding program, with the \
given amount of padding bytes in instruction data.",
),
)
.arg(
Arg::with_name("num_conflict_groups")
.long("num-conflict-groups")
.takes_value(true)
.validator(|arg| is_within_range(arg, 1..))
.help("The number of unique destination accounts per transactions 'chunk'. Lower values will result in more transaction conflicts.")
.help(
"The number of unique destination accounts per transactions 'chunk'. Lower \
values will result in more transaction conflicts.",
),
)
.arg(
Arg::with_name("bind_address")
Expand All @@ -360,7 +372,10 @@ pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
.takes_value(true)
.requires("json_rpc_url")
.validator(is_keypair)
.help("File containing the node identity (keypair) of a validator with active stake. This allows communicating with network using staked connection"),
.help(
"File containing the node identity (keypair) of a validator with active \
stake. This allows communicating with network using staked connection",
),
)
.arg(
Arg::with_name("commitment_config")
Expand All @@ -383,8 +398,8 @@ pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
.value_name("FILENAME")
.takes_value(true)
.help(
"File to save details about all the submitted transactions.\
This option is useful for debug purposes."
"File to save details about all the submitted transactions.This option is \
useful for debug purposes.",
),
)
}
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/keypairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ where
let path = Path::new(client_ids_and_stake_file);
let file = File::open(path).unwrap();

info!("Reading {}", client_ids_and_stake_file);
info!("Reading {client_ids_and_stake_file}");
let accounts: HashMap<String, Base64Account> = serde_yaml::from_reader(file).unwrap();
let mut keypairs = vec![];
let mut last_balance = 0;
Expand Down
Loading
Loading