This commit is contained in:
GroovieGermanikus 2024-03-27 19:00:35 +01:00
parent f3657d7db1
commit 1f502a3a57
No known key found for this signature in database
GPG Key ID: 5B6EB831A5CD2015
4 changed files with 56 additions and 67 deletions

View File

@ -1,13 +1,12 @@
use std::sync::Arc;
use std::time::Duration;
use crate::benches::confirmation_rate;
use crate::benches::confirmation_rate::send_bulk_txs_and_wait;
use crate::service_adapter1::BenchConfig;
use crate::BenchmarkTransactionParams;
use log::error;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::signature::Keypair;
use crate::benches::confirmation_rate;
use crate::benches::confirmation_rate::{send_bulk_txs_and_wait};
use crate::BenchmarkTransactionParams;
use crate::service_adapter1::BenchConfig;
use crate::tx_size::TxSize;
use std::sync::Arc;
use std::time::Duration;
pub async fn benchnew_confirmation_rate_servicerunner(
bench_config: &BenchConfig,
@ -20,7 +19,14 @@ pub async fn benchnew_confirmation_rate_servicerunner(
cu_price_micro_lamports: bench_config.cu_price_micro_lamports,
};
let max_timeout = Duration::from_secs(60);
let result = send_bulk_txs_and_wait(&rpc, &funded_payer, bench_config.tx_count, &tx_params, max_timeout).await;
let result = send_bulk_txs_and_wait(
&rpc,
&funded_payer,
bench_config.tx_count,
&tx_params,
max_timeout,
)
.await;
result.unwrap_or_else(|err| {
error!("Failed to send bulk txs and wait: {}", err);
confirmation_rate::Metric::default()

View File

@ -5,29 +5,24 @@ mod prometheus;
use crate::args::{get_funded_payer_from_env, read_tenant_configs, TenantConfig};
use crate::cli::Args;
use crate::postgres::metrics_dbstore::{
upsert_benchrun_status, BenchRunStatus,
};
use crate::postgres::metrics_dbstore::{upsert_benchrun_status, BenchRunStatus};
use crate::postgres::postgres_session::PostgresSessionConfig;
use crate::postgres::postgres_session_cache::PostgresSessionCache;
use crate::prometheus::metrics_prometheus::publish_metrics_on_prometheus;
use crate::prometheus::prometheus_sync::PrometheusSync;
use async_trait::async_trait;
use bench::benches::confirmation_rate;
use bench::metrics;
use bench::service_adapter1::BenchConfig;
use clap::Parser;
use futures_util::future::join_all;
use itertools::Itertools;
use log::{debug, error, info, warn};
use solana_sdk::signature::Keypair;
use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
use std::time::{Duration, SystemTime};
use async_trait::async_trait;
use postgres_types::ToSql;
use solana_sdk::signature::Keypair;
use tokio::sync::OnceCell;
use bench::metrics;
use bench::benches::confirmation_rate;
use bench::tx_size::TxSize;
#[tokio::main]
async fn main() {
@ -105,26 +100,20 @@ async fn main() {
let bench_config = bench_configs[permutation[1]].clone();
let bench_impl: Box<dyn BenchTrait> = match permutation[0] {
0 => {
Box::new(BenchRunnerConfirmationRateImpl {
benchrun_at,
tenant_config: tenant_config.clone(),
bench_config: bench_config.clone(),
funded_payer: funded_payer.clone(),
size_tx,
metric: OnceCell::new(),
})
}
1 => {
Box::new(BenchRunnerBench1Impl {
benchrun_at,
tenant_config: tenant_config.clone(),
bench_config: bench_config.clone(),
funded_payer: funded_payer.clone(),
size_tx,
metric: OnceCell::new(),
})
}
0 => Box::new(BenchRunnerConfirmationRateImpl {
benchrun_at,
tenant_config: tenant_config.clone(),
bench_config: bench_config.clone(),
funded_payer: funded_payer.clone(),
metric: OnceCell::new(),
}),
1 => Box::new(BenchRunnerBench1Impl {
benchrun_at,
tenant_config: tenant_config.clone(),
bench_config: bench_config.clone(),
funded_payer: funded_payer.clone(),
metric: OnceCell::new(),
}),
_ => unreachable!(),
};
@ -144,14 +133,16 @@ async fn main() {
.await;
}
let metric = bench_impl.run_bench().await;
bench_impl.run_bench().await;
if let Some(postgres_session) = postgres_session.as_ref() {
let save_result = bench_impl.try_save_results_postgres(postgres_session).await;
if let Err(err) = save_result {
warn!("Failed to save metrics to postgres (err {:?}) - continue", err);
warn!(
"Failed to save metrics to postgres (err {:?}) - continue",
err
);
}
}
// publish_metrics_on_prometheus(&tenant_config, &bench_config).await;
@ -180,8 +171,6 @@ async fn main() {
join_all(jh_tenant_task).await;
}
// dimensions: least-significant first
fn factorize(i: usize, dimensions: &[usize]) -> Vec<usize> {
let mut i = i;
@ -214,7 +203,10 @@ trait BenchTrait: BenchRunner + BenchMetricsPostgresSaver {}
// R: result
#[async_trait]
trait BenchMetricsPostgresSaver: Send + Sync + 'static {
async fn try_save_results_postgres(&self, postgres_session: &PostgresSessionCache) -> anyhow::Result<()>;
async fn try_save_results_postgres(
&self,
postgres_session: &PostgresSessionCache,
) -> anyhow::Result<()>;
}
struct BenchRunnerBench1Impl {
@ -222,13 +214,11 @@ struct BenchRunnerBench1Impl {
pub tenant_config: TenantConfig,
pub bench_config: BenchConfig,
pub funded_payer: Arc<Keypair>,
pub size_tx: TxSize,
pub metric: OnceCell<metrics::Metric>,
}
impl BenchTrait for BenchRunnerBench1Impl {}
#[async_trait]
impl BenchRunner for BenchRunnerBench1Impl {
async fn run_bench(&self) {
@ -242,7 +232,6 @@ impl BenchRunner for BenchRunnerBench1Impl {
}
}
impl BenchTrait for BenchRunnerConfirmationRateImpl {}
struct BenchRunnerConfirmationRateImpl {
@ -250,7 +239,6 @@ struct BenchRunnerConfirmationRateImpl {
pub tenant_config: TenantConfig,
pub bench_config: BenchConfig,
pub funded_payer: Arc<Keypair>,
pub size_tx: TxSize,
pub metric: OnceCell<confirmation_rate::Metric>,
}
@ -262,10 +250,7 @@ impl BenchRunner for BenchRunnerConfirmationRateImpl {
self.tenant_config.rpc_addr.clone(),
self.funded_payer.insecure_clone(),
)
.await;
.await;
self.metric.set(metric).unwrap();
}
}

View File

@ -1,13 +1,11 @@
use crate::args::TenantConfig;
use crate::postgres::postgres_session_cache::PostgresSessionCache;
use bench::metrics;
use bench::benches::confirmation_rate;
use crate::{BenchMetricsPostgresSaver, BenchRunnerBench1Impl, BenchRunnerConfirmationRateImpl};
use async_trait::async_trait;
use bench::service_adapter1::BenchConfig;
use log::warn;
use postgres_types::ToSql;
use std::time::SystemTime;
use async_trait::async_trait;
use crate::{BenchMetricsPostgresSaver, BenchRunner, BenchRunnerBench1Impl, BenchRunnerConfirmationRateImpl};
#[allow(clippy::upper_case_acronyms)]
pub enum BenchRunStatus {
@ -60,11 +58,12 @@ pub async fn upsert_benchrun_status(
Ok(())
}
#[async_trait]
impl BenchMetricsPostgresSaver for BenchRunnerBench1Impl {
async fn try_save_results_postgres(&self, postgres_session: &PostgresSessionCache) -> anyhow::Result<()> {
async fn try_save_results_postgres(
&self,
postgres_session: &PostgresSessionCache,
) -> anyhow::Result<()> {
let metric = self.metric.get().expect("metric not set");
let metricjson = serde_json::to_value(metric).unwrap();
let values: &[&(dyn ToSql + Sync)] = &[
@ -98,15 +97,16 @@ impl BenchMetricsPostgresSaver for BenchRunnerBench1Impl {
)
.await?;
Ok(())
}
}
#[async_trait]
impl BenchMetricsPostgresSaver for BenchRunnerConfirmationRateImpl {
async fn try_save_results_postgres(&self, postgres_session: &PostgresSessionCache) -> anyhow::Result<()> {
async fn try_save_results_postgres(
&self,
postgres_session: &PostgresSessionCache,
) -> anyhow::Result<()> {
let metric = self.metric.get().expect("metric not set");
let metricjson = serde_json::to_value(metric).unwrap();
let values: &[&(dyn ToSql + Sync)] = &[
@ -116,8 +116,8 @@ impl BenchMetricsPostgresSaver for BenchRunnerConfirmationRateImpl {
&(metric.txs_sent as i64),
&(metric.txs_confirmed as i64),
&(metric.txs_un_confirmed as i64),
&(metric.average_confirmation_time as f32),
&(metric.average_slot_confirmation_time as f32),
&(metric.average_confirmation_time),
&(metric.average_slot_confirmation_time),
&metricjson,
];
postgres_session
@ -143,8 +143,6 @@ impl BenchMetricsPostgresSaver for BenchRunnerConfirmationRateImpl {
)
.await?;
Ok(())
}
}

View File

@ -15,7 +15,7 @@ lazy_static::lazy_static! {
}
// TODO implement
pub async fn publish_metrics_on_prometheus(
pub async fn _publish_metrics_on_prometheus(
tenant_config: &TenantConfig,
_bench_config: &BenchConfig,
metric: &Metric,