Skip to content

Commit

Permalink
Add a workload that randomly generates different transaction shape
Browse files Browse the repository at this point in the history
  • Loading branch information
halfprice committed Nov 23, 2024
1 parent 8da294b commit 151832b
Show file tree
Hide file tree
Showing 15 changed files with 593 additions and 19 deletions.
23 changes: 17 additions & 6 deletions crates/sui-benchmark/src/drivers/bench_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::drivers::driver::Driver;
use crate::drivers::HistogramWrapper;
use crate::system_state_observer::SystemStateObserver;
use crate::workloads::payload::Payload;
use crate::workloads::workload::ExpectedFailureType;
use crate::workloads::{GroupID, WorkloadInfo};
use crate::{ExecutionEffects, ValidatorProxy};
use std::collections::{BTreeMap, VecDeque};
Expand Down Expand Up @@ -737,7 +738,10 @@ async fn run_bench_worker(
-> NextOp {
match result {
Ok(effects) => {
assert!(payload.get_failure_type().is_none());
assert!(
payload.get_failure_type().is_none()
|| payload.get_failure_type() == Some(ExpectedFailureType::NoFailure)
);
let latency = start.elapsed();
let time_from_start = total_benchmark_start_time.elapsed();

Expand Down Expand Up @@ -796,8 +800,15 @@ async fn run_bench_worker(
}
}
Err(err) => {
error!("{}", err);
tracing::error!(
"Transaction execution got error: {}. Transaction digest: {:?}",
err,
transaction.digest()
);
match payload.get_failure_type() {
Some(ExpectedFailureType::NoFailure) => {
panic!("Transaction failed unexpectedly");
}
Some(_) => {
metrics_cloned
.num_expected_error
Expand Down Expand Up @@ -917,10 +928,10 @@ async fn run_bench_worker(
if let Some(b) = retry_queue.pop_front() {
let tx = b.0;
let payload = b.1;
if payload.get_failure_type().is_some() {
num_expected_error_txes += 1;
} else {
num_error_txes += 1;
match payload.get_failure_type() {
Some(ExpectedFailureType::NoFailure) => num_error_txes += 1,
Some(_) => num_expected_error_txes += 1,
None => num_error_txes += 1,
}
num_submitted += 1;
metrics_cloned.num_submitted.with_label_values(&[&payload.to_string()]).inc();
Expand Down
3 changes: 3 additions & 0 deletions crates/sui-benchmark/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ pub enum RunSpec {
// relative weight of expected failure transactions in the benchmark workload
#[clap(long, num_args(1..), value_delimiter = ',', default_values_t = [0])]
expected_failure: Vec<u32>,
// relative weight of randomized transaction in the benchmark workload
#[clap(long, num_args(1..), value_delimiter = ',', default_values_t = [0])]
randomized_transaction: Vec<u32>,

// --- workload-specific options --- (TODO: use subcommands or similar)
// 100 for max hotness i.e all requests target
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-benchmark/src/workloads/adversarial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl AdversarialWorkloadBuilder {
duration: Interval,
group: u32,
) -> Option<WorkloadBuilderInfo> {
let target_qps = (workload_weight * target_qps as f32) as u64;
let target_qps = (workload_weight * target_qps as f32).ceil() as u64;
let num_workers = (workload_weight * num_workers as f32).ceil() as u64;
let max_ops = target_qps * in_flight_ratio;
if max_ops == 0 || num_workers == 0 {
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-benchmark/src/workloads/batch_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl BatchPaymentWorkloadBuilder {
duration: Interval,
group: u32,
) -> Option<WorkloadBuilderInfo> {
let target_qps = (workload_weight * target_qps as f32) as u64;
let target_qps = (workload_weight * target_qps as f32).ceil() as u64;
let num_workers = (workload_weight * num_workers as f32).ceil() as u64;
let max_ops = target_qps * in_flight_ratio;
if max_ops == 0 || num_workers == 0 {
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-benchmark/src/workloads/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl DelegationWorkloadBuilder {
duration: Interval,
group: u32,
) -> Option<WorkloadBuilderInfo> {
let target_qps = (workload_weight * target_qps as f32) as u64;
let target_qps = (workload_weight * target_qps as f32).ceil() as u64;
let num_workers = (workload_weight * num_workers as f32).ceil() as u64;
let max_ops = target_qps * in_flight_ratio;
if max_ops == 0 || num_workers == 0 {
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-benchmark/src/workloads/expected_failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl ExpectedFailurePayload {
tx
}
ExpectedFailureType::Random => unreachable!(),
ExpectedFailureType::NoFailure => unreachable!(),
}
}
}
Expand Down Expand Up @@ -112,7 +113,7 @@ impl ExpectedFailureWorkloadBuilder {
duration: Interval,
group: u32,
) -> Option<WorkloadBuilderInfo> {
let target_qps = (workload_weight * target_qps as f32) as u64;
let target_qps = (workload_weight * target_qps as f32).ceil() as u64;
let num_workers = (workload_weight * num_workers as f32).ceil() as u64;
let max_ops = target_qps * in_flight_ratio;
if max_ops == 0 || num_workers == 0 {
Expand Down
1 change: 1 addition & 0 deletions crates/sui-benchmark/src/workloads/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod batch_payment;
pub mod delegation;
pub mod expected_failure;
pub mod payload;
pub mod randomized_transaction;
pub mod randomness;
pub mod shared_counter;
pub mod shared_object_deletion;
Expand Down
Loading

0 comments on commit 151832b

Please sign in to comment.