Skip to content

Commit

Permalink
consumer bench same number of txs per iteration (#34752)
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored Jan 12, 2024
1 parent be5337a commit 98a2873
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions core/benches/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ fn bench_process_and_record_transactions(
batch_size: usize,
apply_cost_tracker_during_replay: bool,
) {
const TRANSACTIONS_PER_ITERATION: usize = 64;
assert_eq!(
TRANSACTIONS_PER_ITERATION % batch_size,
0,
"batch_size must be a factor of \
`TRANSACTIONS_PER_ITERATION` ({TRANSACTIONS_PER_ITERATION}) \
so that bench results are easily comparable"
);
let batches_per_iteration = TRANSACTIONS_PER_ITERATION / batch_size;

let BenchFrame {
bank,
ledger_path: _ledger_path,
Expand All @@ -152,12 +162,17 @@ fn bench_process_and_record_transactions(
let mut transaction_iter = transactions.chunks(batch_size);

bencher.iter(move || {
let summary =
consumer.process_and_record_transactions(&bank, transaction_iter.next().unwrap(), 0);
assert!(summary
.execute_and_commit_transactions_output
.commit_transactions_result
.is_ok());
for _ in 0..batches_per_iteration {
let summary = consumer.process_and_record_transactions(
&bank,
transaction_iter.next().unwrap(),
0,
);
assert!(summary
.execute_and_commit_transactions_output
.commit_transactions_result
.is_ok());
}
});

exit.store(true, Ordering::Relaxed);
Expand Down

0 comments on commit 98a2873

Please sign in to comment.