2021-02-16 13:48:20 -08:00
|
|
|
#![allow(clippy::integer_arithmetic)]
|
2018-08-22 07:57:07 -07:00
|
|
|
#![feature(test)]
|
2018-12-08 21:44:20 -08:00
|
|
|
|
2018-08-22 07:57:07 -07:00
|
|
|
extern crate test;
|
2018-07-10 19:33:16 -07:00
|
|
|
|
2021-12-03 09:00:31 -08:00
|
|
|
use {
|
2022-01-11 02:44:46 -08:00
|
|
|
crossbeam_channel::{unbounded, Receiver},
|
2021-12-03 09:00:31 -08:00
|
|
|
log::*,
|
|
|
|
rand::{thread_rng, Rng},
|
|
|
|
rayon::prelude::*,
|
2022-11-18 11:21:45 -08:00
|
|
|
solana_client::connection_cache::ConnectionCache,
|
2021-12-03 09:00:31 -08:00
|
|
|
solana_core::{
|
|
|
|
banking_stage::{BankingStage, BankingStageStats},
|
2023-01-25 04:54:38 -08:00
|
|
|
banking_trace::{BankingPacketBatch, BankingTracer},
|
2022-02-11 00:07:45 -08:00
|
|
|
leader_slot_banking_stage_metrics::LeaderSlotMetricsTracker,
|
2021-12-03 09:00:31 -08:00
|
|
|
qos_service::QosService,
|
2022-03-10 10:47:46 -08:00
|
|
|
unprocessed_packet_batches::*,
|
2022-10-20 14:10:48 -07:00
|
|
|
unprocessed_transaction_storage::{ThreadType, UnprocessedTransactionStorage},
|
2021-12-03 09:00:31 -08:00
|
|
|
},
|
|
|
|
solana_entry::entry::{next_hash, Entry},
|
|
|
|
solana_gossip::cluster_info::{ClusterInfo, Node},
|
|
|
|
solana_ledger::{
|
|
|
|
blockstore::Blockstore,
|
|
|
|
blockstore_processor::process_entries_for_tests,
|
|
|
|
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
|
|
|
get_tmp_ledger_path,
|
|
|
|
},
|
2021-12-11 06:44:15 -08:00
|
|
|
solana_perf::{packet::to_packet_batches, test_tx::test_tx},
|
2021-12-03 09:00:31 -08:00
|
|
|
solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry},
|
2022-11-22 09:55:56 -08:00
|
|
|
solana_runtime::{bank::Bank, bank_forks::BankForks},
|
2021-12-03 09:00:31 -08:00
|
|
|
solana_sdk::{
|
|
|
|
genesis_config::GenesisConfig,
|
|
|
|
hash::Hash,
|
|
|
|
message::Message,
|
|
|
|
pubkey,
|
|
|
|
signature::{Keypair, Signature, Signer},
|
|
|
|
system_instruction, system_transaction,
|
|
|
|
timing::{duration_as_us, timestamp},
|
|
|
|
transaction::{Transaction, VersionedTransaction},
|
|
|
|
},
|
|
|
|
solana_streamer::socket::SocketAddrSpace,
|
2022-09-27 12:12:22 -07:00
|
|
|
solana_vote_program::{
|
|
|
|
vote_state::VoteStateUpdate, vote_transaction::new_vote_state_update_transaction,
|
|
|
|
},
|
2021-12-03 09:00:31 -08:00
|
|
|
std::{
|
2023-01-06 09:32:26 -08:00
|
|
|
iter::repeat_with,
|
2022-01-11 02:44:46 -08:00
|
|
|
sync::{atomic::Ordering, Arc, RwLock},
|
2021-12-03 09:00:31 -08:00
|
|
|
time::{Duration, Instant},
|
|
|
|
},
|
|
|
|
test::Bencher,
|
|
|
|
};
|
2018-07-10 19:33:16 -07:00
|
|
|
|
2019-09-18 12:16:22 -07:00
|
|
|
fn check_txs(receiver: &Arc<Receiver<WorkingBankEntry>>, ref_tx_count: usize) {
|
2018-07-10 19:33:16 -07:00
|
|
|
let mut total = 0;
|
2019-06-17 19:04:21 -07:00
|
|
|
let now = Instant::now();
|
2018-08-12 10:04:21 -07:00
|
|
|
loop {
|
2019-09-18 12:16:22 -07:00
|
|
|
if let Ok((_bank, (entry, _tick_height))) = receiver.recv_timeout(Duration::new(1, 0)) {
|
|
|
|
total += entry.transactions.len();
|
2018-09-24 10:40:42 -07:00
|
|
|
}
|
|
|
|
if total >= ref_tx_count {
|
|
|
|
break;
|
2018-07-10 19:33:16 -07:00
|
|
|
}
|
2019-06-17 19:04:21 -07:00
|
|
|
if now.elapsed().as_secs() > 60 {
|
|
|
|
break;
|
|
|
|
}
|
2018-07-10 19:33:16 -07:00
|
|
|
}
|
|
|
|
assert_eq!(total, ref_tx_count);
|
|
|
|
}
|
|
|
|
|
2019-05-20 09:15:00 -07:00
|
|
|
#[bench]
|
|
|
|
fn bench_consume_buffered(bencher: &mut Bencher) {
|
2019-11-08 20:56:57 -08:00
|
|
|
let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(100_000);
|
2021-08-04 15:30:43 -07:00
|
|
|
let bank = Arc::new(Bank::new_for_benches(&genesis_config));
|
2019-05-20 09:15:00 -07:00
|
|
|
let ledger_path = get_tmp_ledger_path!();
|
|
|
|
{
|
2020-01-13 13:13:52 -08:00
|
|
|
let blockstore = Arc::new(
|
|
|
|
Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"),
|
2019-05-20 09:15:00 -07:00
|
|
|
);
|
|
|
|
let (exit, poh_recorder, poh_service, _signal_receiver) =
|
2022-02-07 18:28:28 -08:00
|
|
|
create_test_recorder(&bank, &blockstore, None, None);
|
2019-05-20 09:15:00 -07:00
|
|
|
|
2022-07-05 07:29:44 -07:00
|
|
|
let recorder = poh_recorder.read().unwrap().recorder();
|
2022-12-02 08:07:01 -08:00
|
|
|
let bank_start = poh_recorder.read().unwrap().bank_start().unwrap();
|
2021-03-23 07:10:04 -07:00
|
|
|
|
2019-05-20 09:15:00 -07:00
|
|
|
let tx = test_tx();
|
2022-05-04 19:50:56 -07:00
|
|
|
let transactions = vec![tx; 4194304];
|
|
|
|
let batches = transactions_to_deserialized_packets(&transactions).unwrap();
|
|
|
|
let batches_len = batches.len();
|
2022-10-20 14:10:48 -07:00
|
|
|
let mut transaction_buffer = UnprocessedTransactionStorage::new_transaction_storage(
|
|
|
|
UnprocessedPacketBatches::from_iter(batches.into_iter(), 2 * batches_len),
|
|
|
|
ThreadType::Transactions,
|
|
|
|
);
|
2020-08-07 11:21:35 -07:00
|
|
|
let (s, _r) = unbounded();
|
2019-05-20 09:15:00 -07:00
|
|
|
// This tests the performance of buffering packets.
|
|
|
|
// If the packet buffers are copied, performance will be poor.
|
|
|
|
bencher.iter(move || {
|
2022-05-22 09:17:59 -07:00
|
|
|
BankingStage::consume_buffered_packets(
|
2022-12-02 08:07:01 -08:00
|
|
|
&bank_start,
|
2022-05-04 19:50:56 -07:00
|
|
|
&mut transaction_buffer,
|
2022-10-20 14:10:48 -07:00
|
|
|
&None,
|
2020-08-07 11:21:35 -07:00
|
|
|
&s,
|
2021-02-12 03:27:37 -08:00
|
|
|
None::<Box<dyn Fn()>>,
|
2021-04-12 23:28:08 -07:00
|
|
|
&BankingStageStats::default(),
|
2021-03-23 07:10:04 -07:00
|
|
|
&recorder,
|
2022-11-22 09:55:56 -08:00
|
|
|
&QosService::new(1),
|
2022-02-11 00:07:45 -08:00
|
|
|
&mut LeaderSlotMetricsTracker::new(0),
|
2022-07-11 08:53:18 -07:00
|
|
|
None,
|
2019-06-28 01:55:24 -07:00
|
|
|
);
|
2019-05-20 09:15:00 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
exit.store(true, Ordering::Relaxed);
|
|
|
|
poh_service.join().unwrap();
|
|
|
|
}
|
2020-01-13 13:13:52 -08:00
|
|
|
let _unused = Blockstore::destroy(&ledger_path);
|
2019-05-20 09:15:00 -07:00
|
|
|
}
|
|
|
|
|
2019-07-16 18:28:18 -07:00
|
|
|
fn make_accounts_txs(txes: usize, mint_keypair: &Keypair, hash: Hash) -> Vec<Transaction> {
|
2020-10-19 12:23:14 -07:00
|
|
|
let to_pubkey = pubkey::new_rand();
|
2019-07-16 18:28:18 -07:00
|
|
|
let dummy = system_transaction::transfer(mint_keypair, &to_pubkey, 1, hash);
|
|
|
|
(0..txes)
|
|
|
|
.into_par_iter()
|
|
|
|
.map(|_| {
|
|
|
|
let mut new = dummy.clone();
|
2021-09-22 14:10:35 -07:00
|
|
|
let sig: Vec<_> = (0..64).map(|_| thread_rng().gen::<u8>()).collect();
|
2020-10-19 12:23:14 -07:00
|
|
|
new.message.account_keys[0] = pubkey::new_rand();
|
|
|
|
new.message.account_keys[1] = pubkey::new_rand();
|
2019-07-16 18:28:18 -07:00
|
|
|
new.signatures = vec![Signature::new(&sig[0..64])];
|
|
|
|
new
|
|
|
|
})
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make_programs_txs(txes: usize, hash: Hash) -> Vec<Transaction> {
|
|
|
|
let progs = 4;
|
|
|
|
(0..txes)
|
|
|
|
.map(|_| {
|
|
|
|
let from_key = Keypair::new();
|
2023-01-06 09:32:26 -08:00
|
|
|
let instructions: Vec<_> = repeat_with(|| {
|
2020-10-19 12:23:14 -07:00
|
|
|
let to_key = pubkey::new_rand();
|
2023-01-06 09:32:26 -08:00
|
|
|
system_instruction::transfer(&from_key.pubkey(), &to_key, 1)
|
|
|
|
})
|
|
|
|
.take(progs)
|
|
|
|
.collect();
|
2020-06-24 13:52:38 -07:00
|
|
|
let message = Message::new(&instructions, Some(&from_key.pubkey()));
|
|
|
|
Transaction::new(&[&from_key], message, hash)
|
2019-07-16 18:28:18 -07:00
|
|
|
})
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
|
2022-09-27 12:12:22 -07:00
|
|
|
fn make_vote_txs(txes: usize) -> Vec<Transaction> {
|
|
|
|
// 1000 voters
|
|
|
|
let num_voters = 1000;
|
|
|
|
let (keypairs, vote_keypairs): (Vec<_>, Vec<_>) = (0..num_voters)
|
|
|
|
.map(|_| (Keypair::new(), Keypair::new()))
|
|
|
|
.unzip();
|
|
|
|
(0..txes)
|
|
|
|
.map(|i| {
|
|
|
|
// Quarter of the votes should be filtered out
|
|
|
|
let vote = if i % 4 == 0 {
|
|
|
|
VoteStateUpdate::from(vec![(2, 1)])
|
|
|
|
} else {
|
|
|
|
VoteStateUpdate::from(vec![(i as u64, 1)])
|
|
|
|
};
|
|
|
|
new_vote_state_update_transaction(
|
|
|
|
vote,
|
|
|
|
Hash::new_unique(),
|
|
|
|
&keypairs[i % num_voters],
|
|
|
|
&vote_keypairs[i % num_voters],
|
|
|
|
&vote_keypairs[i % num_voters],
|
|
|
|
None,
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
|
2019-07-16 18:28:18 -07:00
|
|
|
enum TransactionType {
|
|
|
|
Accounts,
|
|
|
|
Programs,
|
2022-09-27 12:12:22 -07:00
|
|
|
AccountsAndVotes,
|
|
|
|
ProgramsAndVotes,
|
2019-07-16 18:28:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bench_banking(bencher: &mut Bencher, tx_type: TransactionType) {
|
2019-05-09 11:20:26 -07:00
|
|
|
solana_logger::setup();
|
2018-12-21 13:55:45 -08:00
|
|
|
let num_threads = BankingStage::num_threads() as usize;
|
2019-07-16 18:28:18 -07:00
|
|
|
// a multiple of packet chunk duplicates to avoid races
|
2019-06-27 01:37:33 -07:00
|
|
|
const CHUNKS: usize = 8;
|
|
|
|
const PACKETS_PER_BATCH: usize = 192;
|
|
|
|
let txes = PACKETS_PER_BATCH * num_threads * CHUNKS;
|
2018-07-10 19:33:16 -07:00
|
|
|
let mint_total = 1_000_000_000_000;
|
2019-11-08 20:56:57 -08:00
|
|
|
let GenesisConfigInfo {
|
|
|
|
mut genesis_config,
|
2019-05-22 20:39:00 -07:00
|
|
|
mint_keypair,
|
|
|
|
..
|
2019-11-08 20:56:57 -08:00
|
|
|
} = create_genesis_config(mint_total);
|
2019-05-09 11:20:26 -07:00
|
|
|
|
|
|
|
// Set a high ticks_per_slot so we don't run out of ticks
|
|
|
|
// during the benchmark
|
2019-11-08 20:56:57 -08:00
|
|
|
genesis_config.ticks_per_slot = 10_000;
|
2018-07-10 19:33:16 -07:00
|
|
|
|
2023-01-25 04:54:38 -08:00
|
|
|
let banking_tracer = BankingTracer::new_disabled();
|
|
|
|
let (non_vote_sender, non_vote_receiver) = banking_tracer.create_channel_non_vote();
|
|
|
|
let (tpu_vote_sender, tpu_vote_receiver) = banking_tracer.create_channel_tpu_vote();
|
|
|
|
let (gossip_vote_sender, gossip_vote_receiver) = banking_tracer.create_channel_gossip_vote();
|
2023-01-18 17:04:55 -08:00
|
|
|
|
2021-08-04 15:30:43 -07:00
|
|
|
let mut bank = Bank::new_for_benches(&genesis_config);
|
2021-03-15 17:11:15 -07:00
|
|
|
// Allow arbitrary transaction processing time for the purposes of this bench
|
2022-01-11 20:25:21 -08:00
|
|
|
bank.ns_per_slot = u128::MAX;
|
2022-07-05 21:24:58 -07:00
|
|
|
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
|
|
|
|
let bank = bank_forks.read().unwrap().get(0).unwrap();
|
2019-07-16 18:28:18 -07:00
|
|
|
|
2021-10-19 12:37:33 -07:00
|
|
|
// set cost tracker limits to MAX so it will not filter out TXs
|
|
|
|
bank.write_cost_tracker()
|
|
|
|
.unwrap()
|
2022-01-12 21:27:19 -08:00
|
|
|
.set_limits(std::u64::MAX, std::u64::MAX, std::u64::MAX);
|
2021-10-19 12:37:33 -07:00
|
|
|
|
2019-06-27 01:37:33 -07:00
|
|
|
debug!("threads: {} txs: {}", num_threads, txes);
|
2019-07-16 18:28:18 -07:00
|
|
|
|
|
|
|
let transactions = match tx_type {
|
2022-09-27 12:12:22 -07:00
|
|
|
TransactionType::Accounts | TransactionType::AccountsAndVotes => {
|
|
|
|
make_accounts_txs(txes, &mint_keypair, genesis_config.hash())
|
|
|
|
}
|
|
|
|
TransactionType::Programs | TransactionType::ProgramsAndVotes => {
|
|
|
|
make_programs_txs(txes, genesis_config.hash())
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let vote_txs = match tx_type {
|
|
|
|
TransactionType::AccountsAndVotes | TransactionType::ProgramsAndVotes => {
|
|
|
|
Some(make_vote_txs(txes))
|
|
|
|
}
|
|
|
|
_ => None,
|
2019-07-16 18:28:18 -07:00
|
|
|
};
|
|
|
|
|
2018-09-26 05:52:13 -07:00
|
|
|
// fund all the accounts
|
|
|
|
transactions.iter().for_each(|tx| {
|
2019-04-03 08:45:57 -07:00
|
|
|
let fund = system_transaction::transfer(
|
2019-01-24 12:04:04 -08:00
|
|
|
&mint_keypair,
|
2019-03-29 09:05:06 -07:00
|
|
|
&tx.message.account_keys[0],
|
2018-11-05 08:36:22 -08:00
|
|
|
mint_total / txes as u64,
|
2019-11-08 20:56:57 -08:00
|
|
|
genesis_config.hash(),
|
2018-09-26 05:52:13 -07:00
|
|
|
);
|
2018-11-02 14:32:05 -07:00
|
|
|
let x = bank.process_transaction(&fund);
|
2019-01-28 14:52:35 -08:00
|
|
|
x.unwrap();
|
2018-07-10 19:33:16 -07:00
|
|
|
});
|
2018-09-26 05:52:13 -07:00
|
|
|
//sanity check, make sure all the transactions can execute sequentially
|
|
|
|
transactions.iter().for_each(|tx| {
|
2021-06-18 06:34:46 -07:00
|
|
|
let res = bank.process_transaction(tx);
|
2018-09-26 05:52:13 -07:00
|
|
|
assert!(res.is_ok(), "sanity test transactions");
|
|
|
|
});
|
|
|
|
bank.clear_signatures();
|
|
|
|
//sanity check, make sure all the transactions can execute in parallel
|
2021-07-15 20:51:27 -07:00
|
|
|
let res = bank.process_transactions(transactions.iter());
|
2018-09-26 05:52:13 -07:00
|
|
|
for r in res {
|
|
|
|
assert!(r.is_ok(), "sanity parallel execution");
|
2018-07-10 19:33:16 -07:00
|
|
|
}
|
2018-09-26 05:52:13 -07:00
|
|
|
bank.clear_signatures();
|
2021-12-11 06:44:15 -08:00
|
|
|
let verified: Vec<_> = to_packet_batches(&transactions, PACKETS_PER_BATCH);
|
2022-09-27 12:12:22 -07:00
|
|
|
let vote_packets = vote_txs.map(|vote_txs| {
|
|
|
|
let mut packet_batches = to_packet_batches(&vote_txs, PACKETS_PER_BATCH);
|
|
|
|
for batch in packet_batches.iter_mut() {
|
|
|
|
for packet in batch.iter_mut() {
|
2022-12-06 03:54:49 -08:00
|
|
|
packet.meta_mut().set_simple_vote(true);
|
2022-09-27 12:12:22 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
packet_batches
|
|
|
|
});
|
|
|
|
|
2019-03-29 20:00:36 -07:00
|
|
|
let ledger_path = get_tmp_ledger_path!();
|
|
|
|
{
|
2020-01-13 13:13:52 -08:00
|
|
|
let blockstore = Arc::new(
|
|
|
|
Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"),
|
2019-03-29 20:00:36 -07:00
|
|
|
);
|
|
|
|
let (exit, poh_recorder, poh_service, signal_receiver) =
|
2022-02-07 18:28:28 -08:00
|
|
|
create_test_recorder(&bank, &blockstore, None, None);
|
2023-01-24 08:57:55 -08:00
|
|
|
let cluster_info = {
|
|
|
|
let keypair = Arc::new(Keypair::new());
|
|
|
|
let node = Node::new_localhost_with_pubkey(&keypair.pubkey());
|
|
|
|
ClusterInfo::new(node.info, keypair, SocketAddrSpace::Unspecified)
|
|
|
|
};
|
2020-04-21 12:54:45 -07:00
|
|
|
let cluster_info = Arc::new(cluster_info);
|
2020-08-07 11:21:35 -07:00
|
|
|
let (s, _r) = unbounded();
|
2021-07-06 08:41:25 -07:00
|
|
|
let _banking_stage = BankingStage::new(
|
2019-04-17 21:07:45 -07:00
|
|
|
&cluster_info,
|
|
|
|
&poh_recorder,
|
2023-01-18 17:04:55 -08:00
|
|
|
non_vote_receiver,
|
2021-10-07 02:38:23 -07:00
|
|
|
tpu_vote_receiver,
|
2023-01-18 17:04:55 -08:00
|
|
|
gossip_vote_receiver,
|
2019-11-20 15:43:10 -08:00
|
|
|
None,
|
2020-08-07 11:21:35 -07:00
|
|
|
s,
|
2022-07-11 08:53:18 -07:00
|
|
|
None,
|
2022-06-08 04:57:12 -07:00
|
|
|
Arc::new(ConnectionCache::default()),
|
2022-07-05 21:24:58 -07:00
|
|
|
bank_forks,
|
2019-04-17 21:07:45 -07:00
|
|
|
);
|
2022-07-05 07:29:44 -07:00
|
|
|
poh_recorder.write().unwrap().set_bank(&bank, false);
|
2018-10-17 16:28:26 -07:00
|
|
|
|
2019-06-17 19:04:21 -07:00
|
|
|
let chunk_len = verified.len() / CHUNKS;
|
2019-03-29 20:00:36 -07:00
|
|
|
let mut start = 0;
|
2019-05-09 11:20:26 -07:00
|
|
|
|
|
|
|
// This is so that the signal_receiver does not go out of scope after the closure.
|
|
|
|
// If it is dropped before poh_service, then poh_service will error when
|
|
|
|
// calling send() on the channel.
|
|
|
|
let signal_receiver = Arc::new(signal_receiver);
|
2020-06-08 17:38:14 -07:00
|
|
|
let signal_receiver2 = signal_receiver;
|
2019-03-29 20:00:36 -07:00
|
|
|
bencher.iter(move || {
|
2019-05-09 11:20:26 -07:00
|
|
|
let now = Instant::now();
|
2019-06-17 19:04:21 -07:00
|
|
|
let mut sent = 0;
|
2022-09-27 12:12:22 -07:00
|
|
|
if let Some(vote_packets) = &vote_packets {
|
|
|
|
tpu_vote_sender
|
2023-01-25 04:54:38 -08:00
|
|
|
.send(BankingPacketBatch::new((
|
|
|
|
vote_packets[start..start + chunk_len].to_vec(),
|
|
|
|
None,
|
|
|
|
)))
|
2022-09-27 12:12:22 -07:00
|
|
|
.unwrap();
|
2023-01-18 17:04:55 -08:00
|
|
|
gossip_vote_sender
|
2023-01-25 04:54:38 -08:00
|
|
|
.send(BankingPacketBatch::new((
|
|
|
|
vote_packets[start..start + chunk_len].to_vec(),
|
|
|
|
None,
|
|
|
|
)))
|
2022-09-27 12:12:22 -07:00
|
|
|
.unwrap();
|
|
|
|
}
|
2019-06-27 01:37:33 -07:00
|
|
|
for v in verified[start..start + chunk_len].chunks(chunk_len / num_threads) {
|
|
|
|
debug!(
|
|
|
|
"sending... {}..{} {} v.len: {}",
|
2019-06-17 19:04:21 -07:00
|
|
|
start,
|
|
|
|
start + chunk_len,
|
2019-06-27 01:37:33 -07:00
|
|
|
timestamp(),
|
|
|
|
v.len(),
|
2019-06-17 19:04:21 -07:00
|
|
|
);
|
|
|
|
for xv in v {
|
2022-05-23 13:30:15 -07:00
|
|
|
sent += xv.len();
|
2019-06-17 19:04:21 -07:00
|
|
|
}
|
2023-01-25 04:54:38 -08:00
|
|
|
non_vote_sender
|
|
|
|
.send(BankingPacketBatch::new((v.to_vec(), None)))
|
|
|
|
.unwrap();
|
2019-03-29 20:00:36 -07:00
|
|
|
}
|
2022-09-27 12:12:22 -07:00
|
|
|
|
2019-06-17 19:04:21 -07:00
|
|
|
check_txs(&signal_receiver2, txes / CHUNKS);
|
|
|
|
|
|
|
|
// This signature clear may not actually clear the signatures
|
2019-07-16 18:28:18 -07:00
|
|
|
// in this chunk, but since we rotate between CHUNKS then
|
2019-06-17 19:04:21 -07:00
|
|
|
// we should clear them by the time we come around again to re-use that chunk.
|
|
|
|
bank.clear_signatures();
|
2019-05-09 11:20:26 -07:00
|
|
|
trace!(
|
2019-06-17 19:04:21 -07:00
|
|
|
"time: {} checked: {} sent: {}",
|
|
|
|
duration_as_us(&now.elapsed()),
|
|
|
|
txes / CHUNKS,
|
|
|
|
sent,
|
2019-05-09 11:20:26 -07:00
|
|
|
);
|
2019-06-17 19:04:21 -07:00
|
|
|
start += chunk_len;
|
2019-03-29 20:00:36 -07:00
|
|
|
start %= verified.len();
|
|
|
|
});
|
|
|
|
exit.store(true, Ordering::Relaxed);
|
|
|
|
poh_service.join().unwrap();
|
|
|
|
}
|
2020-01-13 13:13:52 -08:00
|
|
|
let _unused = Blockstore::destroy(&ledger_path);
|
2018-07-10 19:33:16 -07:00
|
|
|
}
|
2018-09-28 16:16:35 -07:00
|
|
|
|
|
|
|
#[bench]
|
2019-07-16 18:28:18 -07:00
|
|
|
fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {
|
|
|
|
bench_banking(bencher, TransactionType::Accounts);
|
|
|
|
}
|
2019-03-29 20:00:36 -07:00
|
|
|
|
2019-07-16 18:28:18 -07:00
|
|
|
#[bench]
|
|
|
|
fn bench_banking_stage_multi_programs(bencher: &mut Bencher) {
|
|
|
|
bench_banking(bencher, TransactionType::Programs);
|
2018-09-28 16:16:35 -07:00
|
|
|
}
|
2019-08-28 08:38:32 -07:00
|
|
|
|
2022-09-27 12:12:22 -07:00
|
|
|
#[bench]
|
|
|
|
fn bench_banking_stage_multi_accounts_with_voting(bencher: &mut Bencher) {
|
|
|
|
bench_banking(bencher, TransactionType::AccountsAndVotes);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_banking_stage_multi_programs_with_voting(bencher: &mut Bencher) {
|
|
|
|
bench_banking(bencher, TransactionType::ProgramsAndVotes);
|
|
|
|
}
|
|
|
|
|
2019-08-28 08:38:32 -07:00
|
|
|
fn simulate_process_entries(
|
|
|
|
randomize_txs: bool,
|
|
|
|
mint_keypair: &Keypair,
|
2021-08-17 15:17:56 -07:00
|
|
|
mut tx_vector: Vec<VersionedTransaction>,
|
2019-11-08 20:56:57 -08:00
|
|
|
genesis_config: &GenesisConfig,
|
2020-06-08 17:38:14 -07:00
|
|
|
keypairs: &[Keypair],
|
2019-08-28 08:38:32 -07:00
|
|
|
initial_lamports: u64,
|
|
|
|
num_accounts: usize,
|
|
|
|
) {
|
2021-08-04 15:30:43 -07:00
|
|
|
let bank = Arc::new(Bank::new_for_benches(genesis_config));
|
2019-08-28 08:38:32 -07:00
|
|
|
|
|
|
|
for i in 0..(num_accounts / 2) {
|
|
|
|
bank.transfer(initial_lamports, mint_keypair, &keypairs[i * 2].pubkey())
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
for i in (0..num_accounts).step_by(2) {
|
2021-08-17 15:17:56 -07:00
|
|
|
tx_vector.push(
|
|
|
|
system_transaction::transfer(
|
|
|
|
&keypairs[i],
|
|
|
|
&keypairs[i + 1].pubkey(),
|
|
|
|
initial_lamports,
|
|
|
|
bank.last_blockhash(),
|
|
|
|
)
|
|
|
|
.into(),
|
|
|
|
);
|
2019-08-28 08:38:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Transfer lamports to each other
|
|
|
|
let entry = Entry {
|
|
|
|
num_hashes: 1,
|
|
|
|
hash: next_hash(&bank.last_blockhash(), 1, &tx_vector),
|
|
|
|
transactions: tx_vector,
|
|
|
|
};
|
2021-11-17 11:53:40 -08:00
|
|
|
process_entries_for_tests(&bank, vec![entry], randomize_txs, None, None).unwrap();
|
2019-08-28 08:38:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bench_process_entries(randomize_txs: bool, bencher: &mut Bencher) {
|
|
|
|
// entropy multiplier should be big enough to provide sufficient entropy
|
|
|
|
// but small enough to not take too much time while executing the test.
|
|
|
|
let entropy_multiplier: usize = 25;
|
|
|
|
let initial_lamports = 100;
|
|
|
|
|
|
|
|
// number of accounts need to be in multiple of 4 for correct
|
|
|
|
// execution of the test.
|
|
|
|
let num_accounts = entropy_multiplier * 4;
|
2019-11-08 20:56:57 -08:00
|
|
|
let GenesisConfigInfo {
|
|
|
|
genesis_config,
|
2019-08-28 08:38:32 -07:00
|
|
|
mint_keypair,
|
|
|
|
..
|
2019-11-08 20:56:57 -08:00
|
|
|
} = create_genesis_config((num_accounts + 1) as u64 * initial_lamports);
|
2019-08-28 08:38:32 -07:00
|
|
|
|
2023-01-06 09:32:26 -08:00
|
|
|
let keypairs: Vec<Keypair> = repeat_with(Keypair::new).take(num_accounts).collect();
|
2021-08-17 15:17:56 -07:00
|
|
|
let tx_vector: Vec<VersionedTransaction> = Vec::with_capacity(num_accounts / 2);
|
2019-08-28 08:38:32 -07:00
|
|
|
|
|
|
|
bencher.iter(|| {
|
|
|
|
simulate_process_entries(
|
|
|
|
randomize_txs,
|
|
|
|
&mint_keypair,
|
|
|
|
tx_vector.clone(),
|
2019-11-08 20:56:57 -08:00
|
|
|
&genesis_config,
|
2019-08-28 08:38:32 -07:00
|
|
|
&keypairs,
|
|
|
|
initial_lamports,
|
|
|
|
num_accounts,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_process_entries_without_order_shuffeling(bencher: &mut Bencher) {
|
|
|
|
bench_process_entries(false, bencher);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_process_entries_with_order_shuffeling(bencher: &mut Bencher) {
|
|
|
|
bench_process_entries(true, bencher);
|
|
|
|
}
|