Skip to content

Commit

Permalink
bench-tps: Transition to using spl-instruction-padding (solana-labs#2…
Browse files Browse the repository at this point in the history
…8496)

* bench-tps: Transition to using spl-instruction-padding

* Use macros for conversions
  • Loading branch information
joncinque authored Oct 26, 2022
1 parent 340d3b5 commit 9d7e999
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 131 deletions.
72 changes: 42 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bench-tps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ solana-streamer = { path = "../streamer", version = "=1.15.0" }
solana-thin-client = { path = "../thin-client", version = "=1.15.0" }
solana-tpu-client = { path = "../tpu-client", version = "=1.15.0", default-features = false }
solana-version = { path = "../version", version = "=1.15.0" }
spl-instruction-padding = "0.1"
thiserror = "1.0"

[dev-dependencies]
Expand Down
33 changes: 19 additions & 14 deletions bench-tps/src/bench.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use {
crate::{
bench_tps_client::*,
cli::Config,
inline_instruction_padding_program::{create_padded_instruction, InstructionPaddingConfig},
cli::{Config, InstructionPaddingConfig},
perf_utils::{sample_txs, SampleStats},
send_batch::*,
spl_convert::FromOtherSolana,
},
log::*,
rand::distributions::{Distribution, Uniform},
Expand All @@ -25,6 +25,7 @@ use {
timing::{duration_as_ms, duration_as_s, duration_as_us, timestamp},
transaction::Transaction,
},
spl_instruction_padding::instruction::wrap_instruction,
std::{
collections::{HashSet, VecDeque},
process::exit,
Expand Down Expand Up @@ -552,13 +553,15 @@ fn transfer_with_compute_unit_price_and_padding(
let from_pubkey = from_keypair.pubkey();
let transfer_instruction = system_instruction::transfer(&from_pubkey, to, lamports);
let instruction = if let Some(instruction_padding_config) = instruction_padding_config {
create_padded_instruction(
instruction_padding_config.program_id,
transfer_instruction,
vec![],
instruction_padding_config.data_size,
FromOtherSolana::from(
wrap_instruction(
FromOtherSolana::from(instruction_padding_config.program_id),
FromOtherSolana::from(transfer_instruction),
vec![],
instruction_padding_config.data_size,
)
.expect("Could not create padded instruction"),
)
.expect("Could not create padded instruction")
} else {
transfer_instruction
};
Expand Down Expand Up @@ -645,13 +648,15 @@ fn nonced_transfer_with_padding(
let from_pubkey = from_keypair.pubkey();
let transfer_instruction = system_instruction::transfer(&from_pubkey, to, lamports);
let instruction = if let Some(instruction_padding_config) = instruction_padding_config {
create_padded_instruction(
instruction_padding_config.program_id,
transfer_instruction,
vec![],
instruction_padding_config.data_size,
FromOtherSolana::from(
wrap_instruction(
FromOtherSolana::from(instruction_padding_config.program_id),
FromOtherSolana::from(transfer_instruction),
vec![],
instruction_padding_config.data_size,
)
.expect("Could not create padded instruction"),
)
.expect("Could not create padded instruction")
} else {
transfer_instruction
};
Expand Down
9 changes: 7 additions & 2 deletions bench-tps/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
crate::inline_instruction_padding_program::{self, InstructionPaddingConfig},
crate::spl_convert::FromOtherSolana,
clap::{crate_description, crate_name, App, Arg, ArgMatches},
solana_clap_utils::input_validators::{is_url, is_url_or_moniker},
solana_cli_config::{ConfigInput, CONFIG_FILE},
Expand Down Expand Up @@ -31,6 +31,11 @@ impl Default for ExternalClientType {
}
}

pub struct InstructionPaddingConfig {
pub program_id: Pubkey,
pub data_size: u32,
}

/// Holds the configuration for a single run of the benchmark
pub struct Config {
pub entrypoint_addr: SocketAddr,
Expand Down Expand Up @@ -477,7 +482,7 @@ pub fn extract_args(matches: &ArgMatches) -> Config {
let program_id = matches
.value_of("instruction_padding_program_id")
.map(|target_str| target_str.parse().unwrap())
.unwrap_or(inline_instruction_padding_program::ID);
.unwrap_or_else(|| FromOtherSolana::from(spl_instruction_padding::ID));
args.instruction_padding_config = Some(InstructionPaddingConfig {
program_id,
data_size: data_size
Expand Down
78 changes: 0 additions & 78 deletions bench-tps/src/inline_instruction_padding_program.rs

This file was deleted.

2 changes: 1 addition & 1 deletion bench-tps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pub mod bench;
pub mod bench_tps_client;
pub mod cli;
pub mod inline_instruction_padding_program;
pub mod keypairs;
mod perf_utils;
pub mod send_batch;
pub mod spl_convert;
Loading

0 comments on commit 9d7e999

Please sign in to comment.