aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/development.md3
-rw-r--r--src/simtest/bench.rs25
2 files changed, 19 insertions, 9 deletions
diff --git a/docs/development.md b/docs/development.md
index c121e95..0640355 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -24,7 +24,8 @@ bytes per write by kind, propagation delays, for a full mesh, a writer behind NA
transports, partial meshes of 50 and 100 nodes, lossy links (with delays at random,
and with Mycelium's round trips, each link its own; and Tor's, with some slow circuits), a member away for a while, and
members joining during the writes; several minutes, or one scenario alone
-with `BENCH_SCENARIO`, part of its name: `BENCH_SCENARIO=Tor`; all at once with
+with `BENCH_SCENARIO`, part of its name: `BENCH_SCENARIO=Tor`; 100 writes per workload
+unless `BENCH_WRITES` says otherwise (more, to see what grows with them); all at once with
`BENCH_PARALLEL=1`, faster on many cores, though sharing them makes delays come out
somewhat higher; and in `bench_bridge`, large values from a writer on a fast transport
through a bridge to a node on a slow one: what that node gets as sync messages and as
diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs
index da8e322..d8c08e2 100644
--- a/src/simtest/bench.rs
+++ b/src/simtest/bench.rs
@@ -27,7 +27,7 @@ use crate::swarm::stats::{Propagation, Relay};
use crate::transport::sim::{DELIVERY_LIMIT, LinkParams};
use crate::transport::traffic::{ByKind, Counter};
-/// Writes per workload, and how many a second.
+/// Writes per workload, unless `BENCH_WRITES` says otherwise, and how many a second.
const WRITES: usize = 100;
const WRITE_EVERY: Duration = Duration::from_millis(200);
/// Longer than the tests' (`simtest::KEEPALIVE`), so that keepalives don't drown what
@@ -35,6 +35,15 @@ const WRITE_EVERY: Duration = Duration::from_millis(200);
const KEEPALIVE: Duration = Duration::from_secs(5);
/// The quiet phase: long enough to see the keepalives' rate (a STATUS every third, 15 s).
const QUIET: Duration = Duration::from_secs(20);
+/// Writes per workload: `WRITES`, or `BENCH_WRITES` (longer, to see what grows with them).
+fn writes() -> usize {
+ std::env::var("BENCH_WRITES")
+ .ok()
+ .and_then(|value| value.parse().ok())
+ .filter(|writes| *writes > 0)
+ .unwrap_or(WRITES)
+}
+
/// Only the scenarios whose names contain this, if set: `BENCH_SCENARIO=NAT`.
const ONLY: &str = "BENCH_SCENARIO";
/// If set, all scenarios at once (`BENCH_PARALLEL=1`): several times faster on many
@@ -514,7 +523,7 @@ async fn run(seed: u64, scenario: &'static Scenario) -> String {
out,
"\n{} ({} writes at {} a second each)",
scenario.name,
- WRITES,
+ writes(),
1000 / WRITE_EVERY.as_millis()
);
let mut joined = initial;
@@ -528,9 +537,9 @@ async fn run(seed: u64, scenario: &'static Scenario) -> String {
let start = Totals::of(&nodes).await;
// Before which writes the members joining in this workload start.
let joins: Vec<usize> = (1..=scenario.joining)
- .map(|k| WRITES * k / (scenario.joining + 1))
+ .map(|k| writes() * k / (scenario.joining + 1))
.collect();
- for i in 0..WRITES {
+ for i in 0..writes() {
if joins.contains(&i) {
let id = &ids[joined];
nodes.push(sim.start_on_with(
@@ -544,14 +553,14 @@ async fn run(seed: u64, scenario: &'static Scenario) -> String {
}
// The middle half, the node that goes away is gone (writing nothing).
if let Some(away) = scenario.away {
- if i == WRITES / 4 {
+ if i == writes() / 4 {
sim.net.take_down(&ids[away]);
- } else if i == WRITES * 3 / 4 {
+ } else if i == writes() * 3 / 4 {
sim.net.bring_up(&ids[away]);
}
}
let gone = scenario.away.is_some_and(|away| {
- (WRITES / 4..WRITES * 3 / 4).contains(&i) && away == i % initial
+ (writes() / 4..writes() * 3 / 4).contains(&i) && away == i % initial
});
if writer.is_none() && gone {
tokio::time::sleep(WRITE_EVERY).await;
@@ -873,7 +882,7 @@ fn report(
) {
let took = during.1.at - during.0.at;
let scale = took.as_secs_f64() / (quiet.1.at - quiet.0.at).as_secs_f64();
- let writes = WRITES as f64;
+ let writes = writes() as f64;
let _ = writeln!(
out,
" {workload}: {:.1} s, converged {} ms after the last write",