From fabef12167207c3d7f3da98f2abaec9f903b327d Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 11 Jul 2018 23:21:51 -0600 Subject: [PATCH] Sequence client outgoing and incoming txs --- src/bin/client-demo.rs | 52 ++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/src/bin/client-demo.rs b/src/bin/client-demo.rs index 36b3455813cf48..d1cd5b344c1535 100644 --- a/src/bin/client-demo.rs +++ b/src/bin/client-demo.rs @@ -83,19 +83,23 @@ fn generate_and_send_txs( txs: i64, last_id: &mut Hash, threads: usize, + reclaim: bool, ) { - println!("Signing transactions... {}", txs,); + println!("Signing transactions... {}", txs / 2,); let signing_start = Instant::now(); - let mut transactions: Vec<_> = keypairs - .par_iter() - .map(|keypair| Transaction::new(&id.keypair(), keypair.pubkey(), 1, *last_id)) - .collect(); - let mut transactions1: Vec<_> = keypairs - .par_iter() - .map(|keypair| Transaction::new(keypair, id.pubkey(), 1, *last_id)) - .collect(); - transactions.append(&mut transactions1); + let transactions: Vec<_>; + if !reclaim { + transactions = keypairs + .par_iter() + .map(|keypair| Transaction::new(&id.keypair(), keypair.pubkey(), 1, *last_id)) + .collect(); + } else { + transactions = keypairs + .par_iter() + .map(|keypair| Transaction::new(keypair, id.pubkey(), 1, *last_id)) + .collect(); + } let duration = signing_start.elapsed(); let ns = duration.as_secs() * 1_000_000_000 + u64::from(duration.subsec_nanos()); @@ -108,7 +112,11 @@ fn generate_and_send_txs( duration_as_ms(&duration), ); - println!("Transfering {} transactions in {} batches", txs, threads); + println!( + "Transfering {} transactions in {} batches", + txs / 2, + threads + ); let transfer_start = Instant::now(); let sz = transactions.len() / threads; let chunks: Vec<_> = transactions.chunks(sz).collect(); @@ -145,7 +153,7 @@ fn main() { env_logger::init(); let mut threads = 4usize; let mut num_nodes = 1usize; - let mut time_sec = 60; + let mut time_sec = 90; let matches = App::new("solana-client-demo") .arg( @@ -284,8 +292,23 @@ fn main() { let clients = (0..threads).map(|_| mk_client(&leader)).collect(); // generate and send transactions for the specified duration - let time = Duration::new(time_sec, 0); - let now = Instant::now(); + let time = Duration::new(time_sec / 2, 0); + let mut now = Instant::now(); + while now.elapsed() < time { + generate_and_send_txs( + &mut client, + &clients, + &id, + &keypairs, + &leader, + txs, + &mut last_id, + threads, + false, + ); + } + last_id = client.get_last_id(); + now = Instant::now(); while now.elapsed() < time { generate_and_send_txs( &mut client, @@ -296,6 +319,7 @@ fn main() { txs, &mut last_id, threads, + true, ); }