Skip to content

Commit

Permalink
split accounts request into chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Lykov committed Aug 24, 2022
1 parent 79c6d4e commit 19de07a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions bench-tps/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
log::*,
rand::distributions::{Distribution, Uniform},
rayon::prelude::*,
solana_client::nonce_utils,
solana_client::{nonce_utils, rpc_request::MAX_MULTIPLE_ACCOUNTS},
solana_metrics::{self, datapoint_info},
solana_sdk::{
account::Account,
Expand Down Expand Up @@ -559,7 +559,7 @@ fn get_nonce_accounts<T: 'static + BenchTpsClient + Send + Sync + ?Sized>(
}

fn get_nonce_blockhashes<T: 'static + BenchTpsClient + Send + Sync + ?Sized>(
client: Arc<T>,
client: &Arc<T>,
nonce_pubkeys: &[Pubkey],
) -> Vec<Hash> {
let num_accounts = nonce_pubkeys.len();
Expand All @@ -580,7 +580,7 @@ fn get_nonce_blockhashes<T: 'static + BenchTpsClient + Send + Sync + ?Sized>(

let num_unprocessed_before = unprocessed.len();
info!("Request {} durable nonce accounts", num_unprocessed_before);
let accounts = get_nonce_accounts(&client, nonce_pubkeys);
let accounts = get_nonce_accounts(client, nonce_pubkeys);
for (account, index) in accounts.iter().zip(request_indexes.iter()) {
if let Some(nonce_account) = account {
let nonce_data = nonce_utils::data_from_account(nonce_account).unwrap();
Expand Down Expand Up @@ -614,7 +614,12 @@ fn generate_nonced_system_txs<T: 'static + BenchTpsClient + Send + Sync + ?Sized
.iter()
.map(|keypair| keypair.pubkey())
.collect();
let blockhashes = get_nonce_blockhashes(client, &pubkeys);

let blockhashes: Vec<Hash> = pubkeys
.chunks(MAX_MULTIPLE_ACCOUNTS)
.map(|pubkeys| get_nonce_blockhashes(&client, &pubkeys))
.flatten()
.collect();

for i in 0..length {
transactions.push((
Expand All @@ -631,7 +636,11 @@ fn generate_nonced_system_txs<T: 'static + BenchTpsClient + Send + Sync + ?Sized
}
} else {
let pubkeys: Vec<Pubkey> = dest_nonce.iter().map(|keypair| keypair.pubkey()).collect();
let blockhashes = get_nonce_blockhashes(client, &pubkeys);
let blockhashes: Vec<Hash> = pubkeys
.chunks(MAX_MULTIPLE_ACCOUNTS)
.map(|pubkeys| get_nonce_blockhashes(&client, &pubkeys))
.flatten()
.collect();

for i in 0..length {
transactions.push((
Expand Down

0 comments on commit 19de07a

Please sign in to comment.