-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
487 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ | |
.vscode/ | ||
# Ignore downloaded consensus specs test data | ||
testing/ef-tests/mainnet* | ||
|
||
bin/trin-bench/logs |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[package] | ||
name = "trin-bench" | ||
authors.workspace = true | ||
categories.workspace = true | ||
edition.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
readme.workspace = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
clap.workspace = true | ||
ethportal-api.workspace = true | ||
e2store.workspace = true | ||
futures.workspace = true | ||
humanize-duration.workspace = true | ||
jsonrpsee.workspace = true | ||
portal-bridge.workspace = true | ||
reqwest.workspace = true | ||
tokio.workspace = true | ||
tracing.workspace = true | ||
tracing-subscriber.workspace = true | ||
trin-execution.workspace = true | ||
trin-utils.workspace = true | ||
trin-validation.workspace = true | ||
url.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test: | ||
@echo "Running Trin Bench" | ||
@./run-bench.sh | ||
@echo "Down running Trin Bench" | ||
|
||
clean: | ||
sudo rm -r logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Trin Bench | ||
Trin bench is for testing Trin performance and being able to recreate situations reliably to verify if performance improvements or regressions happen | ||
|
||
## To run | ||
```sh | ||
make run | ||
``` | ||
|
||
## Clean results | ||
```sh | ||
make clean | ||
``` | ||
|
||
## View the results | ||
|
||
The results will be available in the logs folder. After running the test there will be 2 svg's containing flamegraphs `trin_sender.svg` and `trin_receiver.svg`, please open in it a web browser for the best experience. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#!/bin/bash | ||
|
||
# Define log directories | ||
LOG_DIR="logs" | ||
mkdir -p "$LOG_DIR" | ||
|
||
# Create data directories for trin instances | ||
DATA_DIR_SENDER="./data_sender" | ||
DATA_DIR_RECEIVER="./data_receiver" | ||
mkdir -p "$LOG_DIR/$DATA_DIR_SENDER" "$LOG_DIR/$DATA_DIR_RECEIVER" | ||
|
||
# Clone portal-accumulators repository if not already present | ||
if [ ! -d "../../portal-accumulators" ]; then | ||
git clone https://github.com/ethereum/portal-accumulators ../../portal-accumulators || { echo "Failed to clone portal-accumulators"; exit 1; } | ||
fi | ||
|
||
# Build trin-benchmark-cordinator with release profile | ||
pushd ../.. || { echo "Failed to change directory"; exit 1; } | ||
cargo build --release -p trin-bench || { echo "Failed to build trin-benchmark-cordinator"; exit 1; } | ||
popd || { echo "Failed to return to original directory"; exit 1; } | ||
|
||
# Define process PIDs | ||
PIDS=() | ||
|
||
# Find available ports dynamically and ensure they are unique | ||
find_unused_port() { | ||
local port=$1 | ||
while ss -tuln | awk '{print $4}' | grep -q ":$port$"; do | ||
port=$((port + 1)) | ||
done | ||
echo $port | ||
} | ||
|
||
PORT_SENDER=$(find_unused_port 9050) | ||
PORT_RECEIVER=$(find_unused_port $((PORT_SENDER + 10))) | ||
EXT_PORT_SENDER=$(find_unused_port 9100) | ||
EXT_PORT_RECEIVER=$(find_unused_port $((EXT_PORT_SENDER + 10))) | ||
|
||
# Run trin sender with perf profiling | ||
cargo flamegraph --profile profiling -c "record -F 97 --call-graph dwarf,64000 -g -o $LOG_DIR/trin_sender.perf" --root --output "$LOG_DIR/trin_sender.svg" -p trin -- \ | ||
--web3-transport http \ | ||
--web3-http-address http://127.0.0.1:$PORT_SENDER/ \ | ||
--mb 0 \ | ||
--bootnodes none \ | ||
--external-address 127.0.0.1:$EXT_PORT_SENDER \ | ||
--discovery-port $EXT_PORT_SENDER \ | ||
--data-dir "$LOG_DIR/$DATA_DIR_SENDER" \ | ||
> "$LOG_DIR/trin_sender.log" 2>&1 & | ||
PIDS+=("$!") | ||
|
||
# Run trin receiver with perf profiling | ||
cargo flamegraph --profile profiling -c "record -F 97 --call-graph dwarf,64000 -g -o $LOG_DIR/trin_receiver.perf" --root --output "$LOG_DIR/trin_receiver.svg" -p trin -- \ | ||
--web3-transport http \ | ||
--web3-http-address http://127.0.0.1:$PORT_RECEIVER/ \ | ||
--mb 10000 \ | ||
--bootnodes none \ | ||
--external-address 127.0.0.1:$EXT_PORT_RECEIVER \ | ||
--discovery-port $EXT_PORT_RECEIVER \ | ||
--data-dir "$LOG_DIR/$DATA_DIR_RECEIVER" \ | ||
> "$LOG_DIR/trin_receiver.log" 2>&1 & | ||
PIDS+=("$!") | ||
|
||
# Run trin benchmark coordinator without perf profiling | ||
../../target/release/trin-bench \ | ||
--web3-http-address-node-1 http://127.0.0.1:$PORT_SENDER/ \ | ||
--web3-http-address-node-2 http://127.0.0.1:$PORT_RECEIVER/ \ | ||
--epoch-accumulator-path ../../portal-accumulators \ | ||
--start-era1 1000 \ | ||
--end-era1 1002 \ | ||
> "$LOG_DIR/trin_benchmark.log" 2>&1 & | ||
TRIN_BENCH_PID=$! | ||
|
||
echo "Started Benchmark" | ||
|
||
CLEANED_UP=false | ||
# Function to clean up processes on SIGINT and SIGTERM | ||
cleanup() { | ||
if $CLEANED_UP; then | ||
return | ||
fi | ||
CLEANED_UP=true | ||
echo "Finished benchmark. Stopping processes..." | ||
|
||
# Stop trin sender and receiver | ||
for PID in "${PIDS[@]}"; do | ||
if kill -0 "$PID" 2>/dev/null; then | ||
echo "Killing process with PID $PID..." | ||
pkill -SIGINT -P "$PID" | ||
fi | ||
done | ||
|
||
# Wait for trin sender and receiver to finish | ||
for PID in "${PIDS[@]}"; do | ||
if kill -0 "$PID" 2>/dev/null; then | ||
echo "Waiting process with PID $PID..." | ||
wait "$PID" 2>/dev/null | ||
fi | ||
done | ||
|
||
# Stop trin-bench process separately | ||
if kill -0 "$TRIN_BENCH_PID" 2>/dev/null; then | ||
echo "Stopping trin-bench with PID $TRIN_BENCH_PID..." | ||
kill -SIGINT "$TRIN_BENCH_PID" | ||
wait "$TRIN_BENCH_PID" 2>/dev/null | ||
fi | ||
|
||
echo "All processes stopped." | ||
|
||
# Remove data directories | ||
sudo rm -rf "$LOG_DIR/$DATA_DIR_SENDER" "$LOG_DIR/$DATA_DIR_RECEIVER" "$LOG_DIR/trin_sender.perf" "$LOG_DIR/trin_receiver.perf" | ||
} | ||
|
||
# Trap signals | ||
trap cleanup SIGINT SIGTERM ERR | ||
|
||
# Wait for trin-bench to finish | ||
wait "$TRIN_BENCH_PID" | ||
|
||
# unset the trap | ||
trap - SIGINT SIGTERM ERR | ||
|
||
cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::path::PathBuf; | ||
|
||
use clap::Parser; | ||
use url::Url; | ||
|
||
pub const APP_NAME: &str = "trin-bench"; | ||
const DEFAULT_EPOCH_ACC_PATH: &str = "./portal-accumulators"; | ||
|
||
#[derive(Parser, Debug, Clone)] | ||
#[command( | ||
name = "Trin Bench", | ||
about = "Benchmarks sending blocks from one trin client to another" | ||
)] | ||
pub struct TrinBenchConfig { | ||
#[arg( | ||
long = "web3-http-address-node-1", | ||
help = "address to accept json-rpc http connections" | ||
)] | ||
pub web3_http_address_node_1: Url, | ||
|
||
#[arg( | ||
long = "web3-http-address-node-2", | ||
help = "address to accept json-rpc http connections" | ||
)] | ||
pub web3_http_address_node_2: Url, | ||
|
||
#[arg( | ||
long, | ||
help = "The first era to start sending blocks from", | ||
default_value = "1" | ||
)] | ||
pub start_era1: u16, | ||
|
||
#[arg(long, help = "The last era to send blocks from", default_value = "5")] | ||
pub end_era1: u16, | ||
|
||
#[arg( | ||
long = "epoch-accumulator-path", | ||
help = "Path to epoch accumulator repo for bridge mode", | ||
default_value = DEFAULT_EPOCH_ACC_PATH | ||
)] | ||
pub epoch_acc_path: PathBuf, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod cli; |
Oops, something went wrong.