Bench tps add nonce flag (#27030)
* add durable nonce option * make blockhash thread optional * add nonce test to bench-tps
This commit is contained in:
parent
6c796727df
commit
014a926645
|
@ -245,13 +245,20 @@ fn generate_chunked_transfers<T: 'static + BenchTpsClient + Send + Sync + ?Sized
|
||||||
threads: usize,
|
threads: usize,
|
||||||
duration: Duration,
|
duration: Duration,
|
||||||
sustained: bool,
|
sustained: bool,
|
||||||
|
use_durable_nonce: bool,
|
||||||
) {
|
) {
|
||||||
// generate and send transactions for the specified duration
|
// generate and send transactions for the specified duration
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let mut last_generate_txs_time = Instant::now();
|
let mut last_generate_txs_time = Instant::now();
|
||||||
|
|
||||||
while start.elapsed() < duration {
|
while start.elapsed() < duration {
|
||||||
generate_txs(shared_txs, &recent_blockhash, &mut chunk_generator, threads);
|
generate_txs(
|
||||||
|
shared_txs,
|
||||||
|
&recent_blockhash,
|
||||||
|
&mut chunk_generator,
|
||||||
|
threads,
|
||||||
|
use_durable_nonce,
|
||||||
|
);
|
||||||
|
|
||||||
datapoint_info!(
|
datapoint_info!(
|
||||||
"blockhash_stats",
|
"blockhash_stats",
|
||||||
|
@ -318,7 +325,12 @@ where
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn do_bench_tps<T>(client: Arc<T>, config: Config, gen_keypairs: Vec<Keypair>) -> u64
|
pub fn do_bench_tps<T>(
|
||||||
|
client: Arc<T>,
|
||||||
|
config: Config,
|
||||||
|
gen_keypairs: Vec<Keypair>,
|
||||||
|
nonce_keypairs: Option<Vec<Keypair>>,
|
||||||
|
) -> u64
|
||||||
where
|
where
|
||||||
T: 'static + BenchTpsClient + Send + Sync + ?Sized,
|
T: 'static + BenchTpsClient + Send + Sync + ?Sized,
|
||||||
{
|
{
|
||||||
|
@ -331,6 +343,7 @@ where
|
||||||
sustained,
|
sustained,
|
||||||
target_slots_per_epoch,
|
target_slots_per_epoch,
|
||||||
use_randomized_compute_unit_price,
|
use_randomized_compute_unit_price,
|
||||||
|
use_durable_nonce,
|
||||||
..
|
..
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
|
@ -338,7 +351,7 @@ where
|
||||||
let chunk_generator = TransactionChunkGenerator::new(
|
let chunk_generator = TransactionChunkGenerator::new(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
&gen_keypairs,
|
&gen_keypairs,
|
||||||
None, // TODO(klykov): to be added in the follow up PR
|
nonce_keypairs.as_ref(),
|
||||||
tx_count,
|
tx_count,
|
||||||
use_randomized_compute_unit_price,
|
use_randomized_compute_unit_price,
|
||||||
);
|
);
|
||||||
|
@ -368,17 +381,22 @@ where
|
||||||
let shared_tx_active_thread_count = Arc::new(AtomicIsize::new(0));
|
let shared_tx_active_thread_count = Arc::new(AtomicIsize::new(0));
|
||||||
let total_tx_sent_count = Arc::new(AtomicUsize::new(0));
|
let total_tx_sent_count = Arc::new(AtomicUsize::new(0));
|
||||||
|
|
||||||
let blockhash_thread = {
|
// if we use durable nonce, we don't need blockhash thread
|
||||||
|
let blockhash_thread = if !use_durable_nonce {
|
||||||
let exit_signal = exit_signal.clone();
|
let exit_signal = exit_signal.clone();
|
||||||
let blockhash = blockhash.clone();
|
let blockhash = blockhash.clone();
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
let id = id.pubkey();
|
let id = id.pubkey();
|
||||||
Builder::new()
|
Some(
|
||||||
.name("solana-blockhash-poller".to_string())
|
Builder::new()
|
||||||
.spawn(move || {
|
.name("solana-blockhash-poller".to_string())
|
||||||
poll_blockhash(&exit_signal, &blockhash, &client, &id);
|
.spawn(move || {
|
||||||
})
|
poll_blockhash(&exit_signal, &blockhash, &client, &id);
|
||||||
.unwrap()
|
})
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let s_threads = create_sender_threads(
|
let s_threads = create_sender_threads(
|
||||||
|
@ -403,6 +421,7 @@ where
|
||||||
threads,
|
threads,
|
||||||
duration,
|
duration,
|
||||||
sustained,
|
sustained,
|
||||||
|
use_durable_nonce,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Stop the sampling threads so it will collect the stats
|
// Stop the sampling threads so it will collect the stats
|
||||||
|
@ -421,9 +440,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Waiting for blockhash thread...");
|
if let Some(blockhash_thread) = blockhash_thread {
|
||||||
if let Err(err) = blockhash_thread.join() {
|
info!("Waiting for blockhash thread...");
|
||||||
info!(" join() failed with: {:?}", err);
|
if let Err(err) = blockhash_thread.join() {
|
||||||
|
info!(" join() failed with: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(nonce_keypairs) = nonce_keypairs {
|
||||||
|
withdraw_durable_nonce_accounts(client.clone(), &gen_keypairs, &nonce_keypairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
let balance = client.get_balance(&id.pubkey()).unwrap_or(0);
|
let balance = client.get_balance(&id.pubkey()).unwrap_or(0);
|
||||||
|
@ -574,10 +599,14 @@ fn generate_txs<T: 'static + BenchTpsClient + Send + Sync + ?Sized>(
|
||||||
blockhash: &Arc<RwLock<Hash>>,
|
blockhash: &Arc<RwLock<Hash>>,
|
||||||
chunk_generator: &mut TransactionChunkGenerator<'_, '_, T>,
|
chunk_generator: &mut TransactionChunkGenerator<'_, '_, T>,
|
||||||
threads: usize,
|
threads: usize,
|
||||||
|
use_durable_nonce: bool,
|
||||||
) {
|
) {
|
||||||
let blockhash = blockhash.read().map(|x| *x).ok();
|
let transactions = if use_durable_nonce {
|
||||||
|
chunk_generator.generate(None)
|
||||||
let transactions = chunk_generator.generate(blockhash.as_ref());
|
} else {
|
||||||
|
let blockhash = blockhash.read().map(|x| *x).ok();
|
||||||
|
chunk_generator.generate(blockhash.as_ref())
|
||||||
|
};
|
||||||
|
|
||||||
let sz = transactions.len() / threads;
|
let sz = transactions.len() / threads;
|
||||||
let chunks: Vec<_> = transactions.chunks(sz).collect();
|
let chunks: Vec<_> = transactions.chunks(sz).collect();
|
||||||
|
@ -933,7 +962,7 @@ mod tests {
|
||||||
let keypairs =
|
let keypairs =
|
||||||
generate_and_fund_keypairs(client.clone(), &config.id, keypair_count, 20).unwrap();
|
generate_and_fund_keypairs(client.clone(), &config.id, keypair_count, 20).unwrap();
|
||||||
|
|
||||||
do_bench_tps(client, config, keypairs);
|
do_bench_tps(client, config, keypairs, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -55,6 +55,7 @@ pub struct Config {
|
||||||
pub use_quic: bool,
|
pub use_quic: bool,
|
||||||
pub tpu_connection_pool_size: usize,
|
pub tpu_connection_pool_size: usize,
|
||||||
pub use_randomized_compute_unit_price: bool,
|
pub use_randomized_compute_unit_price: bool,
|
||||||
|
pub use_durable_nonce: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
|
@ -83,6 +84,7 @@ impl Default for Config {
|
||||||
use_quic: DEFAULT_TPU_USE_QUIC,
|
use_quic: DEFAULT_TPU_USE_QUIC,
|
||||||
tpu_connection_pool_size: DEFAULT_TPU_CONNECTION_POOL_SIZE,
|
tpu_connection_pool_size: DEFAULT_TPU_CONNECTION_POOL_SIZE,
|
||||||
use_randomized_compute_unit_price: false,
|
use_randomized_compute_unit_price: false,
|
||||||
|
use_durable_nonce: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ use {
|
||||||
bench_tps_client::BenchTpsClient,
|
bench_tps_client::BenchTpsClient,
|
||||||
cli::{self, ExternalClientType},
|
cli::{self, ExternalClientType},
|
||||||
keypairs::get_keypairs,
|
keypairs::get_keypairs,
|
||||||
send_batch::generate_keypairs,
|
send_batch::{generate_durable_nonce_accounts, generate_keypairs},
|
||||||
},
|
},
|
||||||
solana_client::{
|
solana_client::{
|
||||||
connection_cache::ConnectionCache,
|
connection_cache::ConnectionCache,
|
||||||
|
@ -154,6 +154,7 @@ fn main() {
|
||||||
use_quic,
|
use_quic,
|
||||||
tpu_connection_pool_size,
|
tpu_connection_pool_size,
|
||||||
use_randomized_compute_unit_price,
|
use_randomized_compute_unit_price,
|
||||||
|
use_durable_nonce,
|
||||||
..
|
..
|
||||||
} = &cli_config;
|
} = &cli_config;
|
||||||
|
|
||||||
|
@ -230,5 +231,11 @@ fn main() {
|
||||||
client_ids_and_stake_file,
|
client_ids_and_stake_file,
|
||||||
*read_from_client_file,
|
*read_from_client_file,
|
||||||
);
|
);
|
||||||
do_bench_tps(client, cli_config, keypairs);
|
|
||||||
|
let nonce_keypairs = if *use_durable_nonce {
|
||||||
|
Some(generate_durable_nonce_accounts(client.clone(), &keypairs))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
do_bench_tps(client, cli_config, keypairs, nonce_keypairs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#![allow(clippy::integer_arithmetic)]
|
#![allow(clippy::integer_arithmetic)]
|
||||||
|
|
||||||
use {
|
use {
|
||||||
serial_test::serial,
|
serial_test::serial,
|
||||||
solana_bench_tps::{
|
solana_bench_tps::{
|
||||||
bench::{do_bench_tps, generate_and_fund_keypairs},
|
bench::{do_bench_tps, generate_and_fund_keypairs},
|
||||||
cli::Config,
|
cli::Config,
|
||||||
|
send_batch::generate_durable_nonce_accounts,
|
||||||
},
|
},
|
||||||
solana_client::{
|
solana_client::{
|
||||||
connection_cache::ConnectionCache,
|
connection_cache::ConnectionCache,
|
||||||
|
@ -76,7 +78,7 @@ fn test_bench_tps_local_cluster(config: Config) {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _total = do_bench_tps(client, config, keypairs);
|
let _total = do_bench_tps(client, config, keypairs, None);
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
assert!(_total > 100);
|
assert!(_total > 100);
|
||||||
|
@ -110,7 +112,7 @@ fn test_bench_tps_test_validator(config: Config) {
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let lamports_per_account = 100;
|
let lamports_per_account = 1000;
|
||||||
|
|
||||||
let keypair_count = config.tx_count * config.keypair_multiplier;
|
let keypair_count = config.tx_count * config.keypair_multiplier;
|
||||||
let keypairs = generate_and_fund_keypairs(
|
let keypairs = generate_and_fund_keypairs(
|
||||||
|
@ -120,8 +122,13 @@ fn test_bench_tps_test_validator(config: Config) {
|
||||||
lamports_per_account,
|
lamports_per_account,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let nonce_keypairs = if config.use_durable_nonce {
|
||||||
|
Some(generate_durable_nonce_accounts(client.clone(), &keypairs))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let _total = do_bench_tps(client, config, keypairs);
|
let _total = do_bench_tps(client, config, keypairs, nonce_keypairs);
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
assert!(_total > 100);
|
assert!(_total > 100);
|
||||||
|
@ -146,3 +153,14 @@ fn test_bench_tps_tpu_client() {
|
||||||
..Config::default()
|
..Config::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial]
|
||||||
|
fn test_bench_tps_tpu_client_nonce() {
|
||||||
|
test_bench_tps_test_validator(Config {
|
||||||
|
tx_count: 100,
|
||||||
|
duration: Duration::from_secs(10),
|
||||||
|
use_durable_nonce: true,
|
||||||
|
..Config::default()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue