accounts-cluster-bench, close all accounts in a sliding window (#17993) (#18026)

(cherry picked from commit ed18add7d3)

Co-authored-by: carllin <carl@solana.com>
This commit is contained in:
mergify[bot]
2021-06-16 23:53:31 +00:00
committed by GitHub
parent 4df9da5c48
commit bacf1b9acc

View File

@ -363,7 +363,7 @@ fn run_accounts_bench(
iterations: usize, iterations: usize,
maybe_space: Option<u64>, maybe_space: Option<u64>,
batch_size: usize, batch_size: usize,
close_nth: u64, close_nth_batch: u64,
maybe_lamports: Option<u64>, maybe_lamports: Option<u64>,
num_instructions: usize, num_instructions: usize,
mint: Option<Pubkey>, mint: Option<Pubkey>,
@ -441,6 +441,7 @@ fn run_accounts_bench(
} }
} }
// Create accounts
let sigs_len = executor.num_outstanding(); let sigs_len = executor.num_outstanding();
if sigs_len < batch_size { if sigs_len < batch_size {
let num_to_create = batch_size - sigs_len; let num_to_create = batch_size - sigs_len;
@ -475,10 +476,14 @@ fn run_accounts_bench(
} }
} }
if close_nth > 0 { if close_nth_batch > 0 {
let expected_closed = total_accounts_created as u64 / close_nth; let num_batches_to_close =
if expected_closed > total_accounts_closed { total_accounts_created as u64 / (close_nth_batch * batch_size as u64);
let txs: Vec<_> = (0..expected_closed - total_accounts_closed) let expected_closed = num_batches_to_close * batch_size as u64;
let max_closed_seed = seed_tracker.max_closed.load(Ordering::Relaxed);
// Close every account we've created with seed between max_closed_seed..expected_closed
if max_closed_seed < expected_closed {
let txs: Vec<_> = (0..expected_closed - max_closed_seed)
.into_par_iter() .into_par_iter()
.map(|_| { .map(|_| {
let message = make_close_message( let message = make_close_message(
@ -572,14 +577,14 @@ fn main() {
.help("Number of transactions to send per batch"), .help("Number of transactions to send per batch"),
) )
.arg( .arg(
Arg::with_name("close_nth") Arg::with_name("close_nth_batch")
.long("close-frequency") .long("close-frequency")
.takes_value(true) .takes_value(true)
.value_name("BYTES") .value_name("BYTES")
.help( .help(
"Send close transactions after this many accounts created. \ "Every `n` batches, create a batch of close transactions for
Note: a `close-frequency` value near or below `batch-size` \ the earliest remaining batch of accounts created.
may result in transaction-simulation errors, as the close \ Note: Should be > 1 to avoid situations where the close \
transactions will be submitted before the corresponding \ transactions will be submitted before the corresponding \
create transactions have been confirmed", create transactions have been confirmed",
), ),
@ -632,7 +637,7 @@ fn main() {
let space = value_t!(matches, "space", u64).ok(); let space = value_t!(matches, "space", u64).ok();
let lamports = value_t!(matches, "lamports", u64).ok(); let lamports = value_t!(matches, "lamports", u64).ok();
let batch_size = value_t!(matches, "batch_size", usize).unwrap_or(4); let batch_size = value_t!(matches, "batch_size", usize).unwrap_or(4);
let close_nth = value_t!(matches, "close_nth", u64).unwrap_or(0); let close_nth_batch = value_t!(matches, "close_nth_batch", u64).unwrap_or(0);
let iterations = value_t!(matches, "iterations", usize).unwrap_or(10); let iterations = value_t!(matches, "iterations", usize).unwrap_or(10);
let num_instructions = value_t!(matches, "num_instructions", usize).unwrap_or(1); let num_instructions = value_t!(matches, "num_instructions", usize).unwrap_or(1);
if num_instructions == 0 || num_instructions > 500 { if num_instructions == 0 || num_instructions > 500 {
@ -685,7 +690,7 @@ fn main() {
iterations, iterations,
space, space,
batch_size, batch_size,
close_nth, close_nth_batch,
lamports, lamports,
num_instructions, num_instructions,
mint, mint,
@ -720,7 +725,7 @@ pub mod test {
let iterations = 10; let iterations = 10;
let maybe_space = None; let maybe_space = None;
let batch_size = 100; let batch_size = 100;
let close_nth = 100; let close_nth_batch = 100;
let maybe_lamports = None; let maybe_lamports = None;
let num_instructions = 2; let num_instructions = 2;
let mut start = Measure::start("total accounts run"); let mut start = Measure::start("total accounts run");
@ -731,7 +736,7 @@ pub mod test {
iterations, iterations,
maybe_space, maybe_space,
batch_size, batch_size,
close_nth, close_nth_batch,
maybe_lamports, maybe_lamports,
num_instructions, num_instructions,
None, None,