Skip to content

Commit

Permalink
rename txns -> txs, round -> run
Browse files Browse the repository at this point in the history
  • Loading branch information
grooviegermanikus committed Mar 27, 2024
1 parent 7e4b25b commit 0d93ebf
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 46 deletions.
10 changes: 5 additions & 5 deletions bench/src/benches/confirmation_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ pub struct RpcStat {
tx_unconfirmed: u64,
}

/// TC2 send multiple runs of num_txns, measure the confirmation rate
/// TC2 send multiple runs of num_txs, measure the confirmation rate
pub async fn confirmation_rate(
payer_path: &Path,
rpc_url: String,
tx_params: BenchmarkTransactionParams,
max_timeout: Duration,
txs_per_round: usize,
txs_per_run: usize,
num_of_runs: usize,
) -> anyhow::Result<()> {
warn!("THIS IS WORK IN PROGRESS");
Expand All @@ -46,7 +46,7 @@ pub async fn confirmation_rate(
let mut rpc_results = Vec::with_capacity(num_of_runs);

for _ in 0..num_of_runs {
match send_bulk_txs_and_wait(&rpc, &payer, txs_per_round, &tx_params, max_timeout)
match send_bulk_txs_and_wait(&rpc, &payer, txs_per_run, &tx_params, max_timeout)
.await
.context("send bulk tx and wait")
{
Expand All @@ -73,7 +73,7 @@ pub async fn confirmation_rate(
pub async fn send_bulk_txs_and_wait(
rpc: &RpcClient,
payer: &Keypair,
num_txns: usize,
num_txs: usize,
tx_params: &BenchmarkTransactionParams,
max_timeout: Duration,
) -> anyhow::Result<RpcStat> {
Expand All @@ -83,7 +83,7 @@ pub async fn send_bulk_txs_and_wait(
err
})?;
let mut rng = create_rng(None);
let txs = generate_txs(num_txns, payer, hash, &mut rng, tx_params);
let txs = generate_txs(num_txs, payer, hash, &mut rng, tx_params);

trace!("Sending {} transactions in bulk ..", txs.len());
let tx_and_confirmations_from_rpc: Vec<(Signature, ConfirmationResponseFromRpc)> =
Expand Down
34 changes: 16 additions & 18 deletions bench/src/benches/confirmation_slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ use std::time::Duration;
use crate::benches::rpc_interface::{
create_rpc_client, send_and_confirm_bulk_transactions, ConfirmationResponseFromRpc,
};
use crate::metrics::{PingThing, PingThingTxType};
use crate::metrics::PingThing;
use crate::{create_memo_tx, create_rng, BenchmarkTransactionParams, Rng8};
use anyhow::anyhow;
use itertools::Itertools;
use log::{debug, info};
use solana_lite_rpc_util::obfuscate_rpcurl;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::clock::Slot;
use solana_sdk::signature::{read_keypair_file, Signature, Signer};
use solana_sdk::transaction::Transaction;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use tokio::time::{sleep, Instant};
use tracing::error;
use url::Url;

#[derive(Clone, Copy, Debug, Default)]
Expand All @@ -40,7 +37,6 @@ pub struct ConfirmationSlotSuccess {
pub confirmation_time: Duration,
}


#[allow(clippy::too_many_arguments)]
/// TC1 -- Send 2 txs to separate RPCs and compare confirmation slot.
/// The benchmark attempts to minimize the effect of real-world distance and synchronize the time that each transaction reaches the RPC.
Expand All @@ -53,7 +49,7 @@ pub async fn confirmation_slot(
tx_params: BenchmarkTransactionParams,
max_timeout: Duration,
num_of_runs: usize,
maybe_ping_thing: Option<PingThing>,
_maybe_ping_thing: Option<PingThing>,
) -> anyhow::Result<()> {
info!(
"START BENCHMARK: confirmation_slot (prio_fees={})",
Expand Down Expand Up @@ -98,15 +94,13 @@ pub async fn confirmation_slot(
let a_task = tokio::spawn(async move {
sleep(Duration::from_secs_f64(a_delay)).await;
debug!("(A) sending tx {}", rpc_a_tx.signatures[0]);
send_and_confirm_transaction(&rpc_a, rpc_a_tx, max_timeout)
.await
send_and_confirm_transaction(&rpc_a, rpc_a_tx, max_timeout).await
});

let b_task = tokio::spawn(async move {
sleep(Duration::from_secs_f64(b_delay)).await;
debug!("(B) sending tx {}", rpc_b_tx.signatures[0]);
send_and_confirm_transaction(&rpc_b, rpc_b_tx, max_timeout)
.await
send_and_confirm_transaction(&rpc_b, rpc_b_tx, max_timeout).await
});

let (a, b) = tokio::join!(a_task, b_task);
Expand All @@ -115,16 +109,20 @@ pub async fn confirmation_slot(
let b_result: ConfirmationResponseFromRpc = b??;

if let (
ConfirmationResponseFromRpc::Success(
a_slot_sent, a_slot_confirmed, _, a_confirmation_time),
ConfirmationResponseFromRpc::Success(
b_slot_sent, b_slot_confirmed, _, b_confirmation_time)
) = (a_result, b_result) {
info!("txn A landed after {} slots", a_slot_confirmed - a_slot_sent);
info!("txn B landed after {} slots", b_slot_confirmed - b_slot_sent);
ConfirmationResponseFromRpc::Success(a_slot_sent, a_slot_confirmed, _, _),
ConfirmationResponseFromRpc::Success(b_slot_sent, b_slot_confirmed, _, _),
) = (a_result, b_result)
{
info!(
"txn A landed after {} slots",
a_slot_confirmed - a_slot_sent
);
info!(
"txn B landed after {} slots",
b_slot_confirmed - b_slot_sent
);
}


// if let Some(ping_thing) = maybe_ping_thing.clone() {
// ping_thing_tasks.push(tokio::spawn(async move {
// submit_ping_thing_stats(&a_result, &ping_thing)
Expand Down
16 changes: 11 additions & 5 deletions bench/src/benches/rpc_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{bail, Context, Error};
use futures::future::join_all;
use futures::TryFutureExt;
use itertools::Itertools;
use log::{debug, info, trace, warn};
use log::{debug, trace, warn};
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_rpc_client::rpc_client::SerializableTransaction;
use solana_rpc_client_api::client_error::ErrorKind;
Expand Down Expand Up @@ -54,7 +54,10 @@ pub async fn send_and_confirm_bulk_transactions(
};

let started_at = Instant::now();
trace!("Sending {} transactions via RPC (retries=off) ..", txs.len());
trace!(
"Sending {} transactions via RPC (retries=off) ..",
txs.len()
);
let batch_sigs_or_fails = join_all(txs.iter().map(|tx| {
rpc_client
.send_transaction_with_config(tx, send_config)
Expand All @@ -75,8 +78,7 @@ pub async fn send_and_confirm_bulk_transactions(
} else {
debug!(
"Slot did not advance during sending transactions: {} -> {}",
send_slot,
after_send_slot
send_slot, after_send_slot
);
}

Expand Down Expand Up @@ -201,7 +203,11 @@ pub async fn send_and_confirm_bulk_transactions(
}

if pending_status_set.is_empty() {
debug!("All transactions confirmed after {} iterations / {:?}", iteration, started_at.elapsed());
debug!(
"All transactions confirmed after {} iterations / {:?}",
iteration,
started_at.elapsed()
);
break 'polling_loop;
}

Expand Down
8 changes: 4 additions & 4 deletions bench/src/benchnew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ enum SubCommand {
#[clap(short, long, default_value_t = 15_000)]
max_timeout_ms: u64,
#[clap(short, long)]
txns_per_round: usize,
txs_per_run: usize,
#[clap(short, long)]
num_of_runs: usize,
/// The CU price in micro lamports
#[clap(short, long, default_value_t = 300)]
#[arg(short = 'f')]
cu_price: u64,
},
/// Compares the confirmation slot of txns sent to 2 different RPCs
/// Compares the confirmation slot of txs sent to 2 different RPCs
ConfirmationSlot {
#[clap(short, long)]
payer_path: PathBuf,
Expand Down Expand Up @@ -110,7 +110,7 @@ async fn main() {
rpc_url,
size_tx,
max_timeout_ms,
txns_per_round,
txs_per_run: txs_per_run,

Check failure on line 113 in bench/src/benchnew.rs

View workflow job for this annotation

GitHub Actions / lite-rpc full build

the `txs_per_run:` in this pattern is redundant

Check warning on line 113 in bench/src/benchnew.rs

View workflow job for this annotation

GitHub Actions / lite-rpc full build

the `txs_per_run:` in this pattern is redundant

Check warning on line 113 in bench/src/benchnew.rs

View workflow job for this annotation

GitHub Actions / lite-rpc full build

the `txs_per_run:` in this pattern is redundant

Check warning on line 113 in bench/src/benchnew.rs

View workflow job for this annotation

GitHub Actions / Test lite-rpc against running Validator

the `txs_per_run:` in this pattern is redundant

Check warning on line 113 in bench/src/benchnew.rs

View workflow job for this annotation

GitHub Actions / Test lite-rpc against running Validator

the `txs_per_run:` in this pattern is redundant
num_of_runs,
cu_price,
} => confirmation_rate(
Expand All @@ -121,7 +121,7 @@ async fn main() {
cu_price_micro_lamports: cu_price,
},
Duration::from_millis(max_timeout_ms),
txns_per_round,
txs_per_run,
num_of_runs,
)
.await
Expand Down
30 changes: 16 additions & 14 deletions benchrunner-service/src/postgres/confirmation_slot.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::time::SystemTime;

#[derive(Debug)]
pub struct PostgresConfirmationSlot {
pub signature: String,
Expand All @@ -9,17 +11,17 @@ pub struct PostgresConfirmationSlot {
pub confirmation_time_ms: f32,
}

impl PostgresConfirmationSlot {
pub fn to_values() -> &[&(dyn ToSql + Sync)] {
let values: &[&(dyn ToSql + Sync)] = &[
&self.signature,
&self.bench_datetime,
&(self.slot_sent as i64),
&(self.slot_confirmed as i64),
&self.endpoint,
&self.confirmed,
&self.confirmation_time_ms,
];
values
}
}
// impl PostgresConfirmationSlot {
// pub fn to_values() -> &[&(dyn ToSql + Sync)] {
// let values: &[&(dyn ToSql + Sync)] = &[
// &self.signature,
// &self.bench_datetime,
// &(self.slot_sent as i64),
// &(self.slot_confirmed as i64),
// &self.endpoint,
// &self.confirmed,
// &self.confirmation_time_ms,
// ];
// values
// }
// }

0 comments on commit 0d93ebf

Please sign in to comment.