Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

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 25, 2022
1 parent 750d585 commit f03417e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions bench-tps/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use {
log::*,
rand::distributions::{Distribution, Uniform},
rayon::prelude::*,
solana_client::{nonce_utils, rpc_request::MAX_MULTIPLE_ACCOUNTS},
solana_metrics::{self, datapoint_info},
solana_sdk::{
account::Account,
Expand Down Expand Up @@ -545,7 +546,7 @@ fn get_nonce_accounts<T: 'static + BenchTpsClient + Send + Sync + ?Sized>(
nonce_pubkeys: &[Pubkey],
) -> Vec<Option<Account>> {
loop {
match client.get_multiple_accounts(&nonce_pubkeys) {
match client.get_multiple_accounts(nonce_pubkeys) {
Ok(nonce_account) => {
return nonce_account;
}
Expand All @@ -558,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 @@ -579,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 @@ -613,7 +614,11 @@ 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)
.flat_map(|pubkeys| get_nonce_blockhashes(&client, pubkeys))
.collect();

for i in 0..length {
transactions.push((
Expand All @@ -630,7 +635,10 @@ 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)
.flat_map(|pubkeys| get_nonce_blockhashes(&client, pubkeys))
.collect();

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

0 comments on commit f03417e

Please sign in to comment.