Skip to content

Commit 6a8c92a

Browse files
authored
Merge pull request #1271 from input-output-hk/jpraynaud/1220-benchmark-aggregator-performances
Benchmark aggregator performances
2 parents cc3b1ea + 109ab39 commit 6a8c92a

File tree

5 files changed

+125
-7
lines changed

5 files changed

+125
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-test-lab/mithril-end-to-end/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-end-to-end"
3-
version = "0.2.16"
3+
version = "0.2.17"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
documentation = { workspace = true }

mithril-test-lab/mithril-end-to-end/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ make build
3434
./mithril-end-to-end --db-directory db/ --bin-directory ../../target/release
3535
```
3636

37-
## Build and run the stress tester
37+
## Build and run an aggregator stress test
3838

3939
```bash
4040
# Build
@@ -50,6 +50,16 @@ make build
5050
./load-aggregator -vvv --cardano-cli-path script/mock-cardano-cli --aggregator-dir ../../target/release --num-signers=100 --num-clients=200
5151
```
5252

53+
## Benchmark aggregator performances
54+
55+
```bash
56+
# Build the load aggregator tool
57+
make build
58+
59+
# Run a benchmark for [10, 20, 30 40, 50] signers x [100, 200, 300] clients
60+
MIN_SIGNERS=10 MAX_SIGNERS=50 STEP_SIGNERS=10 MIN_CLIENTS=100 MAX_CLIENTS=300 STEP_CLIENTS=100 ./benchmark-aggregator.sh
61+
```
62+
5363
## Launch a monitor
5464

5565
```bash
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Debug mode
6+
if [ -v DEBUG ]; then
7+
set -x
8+
fi
9+
10+
# Check if all env vars are set
11+
if [ -z "${MIN_SIGNERS}" ]; then
12+
MIN_SIGNERS=1
13+
fi
14+
15+
if [ -z "${MAX_SIGNERS}" ]; then
16+
echo "Missing environment variable: MAX_SIGNERS" >/dev/stderr
17+
exit 1
18+
fi
19+
20+
if [ -z "${STEP_SIGNERS}" ]; then
21+
echo "Missing environment variable: STEP_SIGNERS" >/dev/stderr
22+
exit 1
23+
fi
24+
25+
if [ -z "${MIN_CLIENTS}" ]; then
26+
MIN_CLIENTS=0
27+
fi
28+
29+
if [ -z "${MAX_CLIENTS}" ]; then
30+
echo "Missing environment variable: MAX_CLIENTS" >/dev/stderr
31+
exit 1
32+
fi
33+
34+
if [ -z "${STEP_CLIENTS}" ]; then
35+
echo "Missing environment variable: STEP_CLIENTS" >/dev/stderr
36+
exit 1
37+
fi
38+
39+
if [ -z "${AGGREGATOR_DIR}" ]; then
40+
AGGREGATOR_DIR=../../target/release
41+
echo "Using the default AGGREGATOR_DIR: $AGGREGATOR_DIR"
42+
fi
43+
44+
if [ -z "${OUT_FILE}" ]; then
45+
OUT_FILE="benchmark/benchmark-data-[$MIN_SIGNERS,$MAX_SIGNERS;$STEP_SIGNERS]Sx[$MIN_CLIENTS,$MAX_CLIENTS;$STEP_CLIENTS]C-$(date +%Y-%m-%d-%H-%M-%S).tsv"
46+
echo "Using the default OUT_FILE: $OUT_FILE"
47+
fi
48+
mkdir -p $(dirname "$OUT_FILE")
49+
OUT_FILE_TMP=${OUT_FILE}.tmp
50+
51+
# Run stress test
52+
RUN_STRESS_TEST() {
53+
NUM_SIGNERS=$1
54+
NUM_SIGNERS=$(( NUM_SIGNERS > 0 ? NUM_SIGNERS : 1 ))
55+
NUM_CLIENTS=$2
56+
OUT_FILE=$3
57+
INDEX_RUN=$4
58+
TOTAL_RUN=$5
59+
echo ">> [#$INDEX_RUN/$TOTAL_RUN] Running stress test with $NUM_SIGNERS signers and $NUM_CLIENTS clients"
60+
COMMAND="./load-aggregator --cardano-cli-path ./script/mock-cardano-cli --aggregator-dir $AGGREGATOR_DIR --num-signers=$NUM_SIGNERS --num-clients=$NUM_CLIENTS"
61+
if $($COMMAND >> $OUT_FILE_TMP) ; then
62+
echo ">>>> Success"
63+
else
64+
echo "signers clients phase duration/ms" >> $OUT_FILE_TMP
65+
echo "$NUM_SIGNERS $NUM_CLIENTS failure 10" >> $OUT_FILE_TMP
66+
echo ">>>> Failure"
67+
fi
68+
if [[ $INDEX_RUN -gt 1 ]] ; then
69+
tail -n +2 $OUT_FILE_TMP >> $OUT_FILE
70+
else
71+
cat $OUT_FILE_TMP >> $OUT_FILE
72+
fi
73+
rm -f $OUT_FILE_TMP
74+
echo ""
75+
}
76+
77+
# Run aggregator benchmark over a range of signers and clients
78+
SIGNERS_RANGE=$(seq -s ' ' $MIN_SIGNERS $STEP_SIGNERS $MAX_SIGNERS)
79+
CLIENTS_RANGE=$(seq -s ' ' $MIN_CLIENTS $STEP_CLIENTS $MAX_CLIENTS)
80+
SIGNERS_RANGE_LENGTH=$(echo $SIGNERS_RANGE | grep -o " " | wc -l)
81+
CLIENTS_RANGE_LENGTH=$(echo $CLIENTS_RANGE | grep -o " " | wc -l)
82+
echo ""
83+
echo "Run aggregator benchmark over the range:"
84+
echo ">> Signers: [$SIGNERS_RANGE]"
85+
echo ">> Clients: [$CLIENTS_RANGE]"
86+
echo ""
87+
88+
INDEX_RUN=1
89+
TOTAL_RUN=$(( $SIGNERS_RANGE_LENGTH * CLIENTS_RANGE_LENGTH ))
90+
for NUM_SIGNERS in $SIGNERS_RANGE; do
91+
for NUM_CLIENTS in $CLIENTS_RANGE; do
92+
RUN_STRESS_TEST $NUM_SIGNERS $NUM_CLIENTS $OUT_FILE $INDEX_RUN $TOTAL_RUN
93+
INDEX_RUN=$(( ${INDEX_RUN} + 1))
94+
done
95+
done
96+
97+
# Clean directory
98+
rm -f $OUT_FILE_TMP
99+

mithril-test-lab/mithril-end-to-end/src/stress_test/entities.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ impl Reporter {
157157
pub fn stop(&mut self) {
158158
match &self.current_timing {
159159
Some((phase, instant)) => {
160+
let phase = if self.number_of_clients == 0 {
161+
format!("{phase} - without clients")
162+
} else {
163+
format!("{phase} - with clients")
164+
};
160165
let timing = Timing {
161166
phase: phase.clone(),
162167
duration: instant.elapsed(),
@@ -170,11 +175,15 @@ impl Reporter {
170175
}
171176

172177
pub fn print_report(&self) {
173-
println!("number_of_signers\t{}", self.number_of_signers);
174-
println!("number_of_clients\t{}", self.number_of_clients);
175-
println!("phase\tduration/ms");
178+
println!("signers\tclients\tphase\tduration/ms");
176179
for t in &self.timings {
177-
println!("{}\t{}", t.phase, t.duration.as_millis());
180+
println!(
181+
"{}\t{}\t{}\t{}",
182+
self.number_of_signers,
183+
self.number_of_clients,
184+
t.phase,
185+
t.duration.as_millis()
186+
);
178187
}
179188
}
180189
}

0 commit comments

Comments
 (0)