Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-publish-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
id: required
run: |
forklift cargo build --locked --profile testnet --features pyroscope,fast-runtime --bin polkadot --bin polkadot-prepare-worker --bin polkadot-execute-worker
forklift cargo build --locked --profile testnet -p statement-latency-bench
ROCOCO_EPOCH_DURATION=10 ./polkadot/scripts/build-only-wasm.sh rococo-runtime $(pwd)/runtimes/rococo-runtime-10/
ROCOCO_EPOCH_DURATION=100 ./polkadot/scripts/build-only-wasm.sh rococo-runtime $(pwd)/runtimes/rococo-runtime-100/
ROCOCO_EPOCH_DURATION=600 ./polkadot/scripts/build-only-wasm.sh rococo-runtime $(pwd)/runtimes/rococo-runtime-600/
Expand All @@ -59,6 +60,7 @@ jobs:
mv ./target/testnet/polkadot ./artifacts/.
mv ./target/testnet/polkadot-prepare-worker ./artifacts/.
mv ./target/testnet/polkadot-execute-worker ./artifacts/.
mv ./target/testnet/statement-latency-bench ./artifacts/.
mv ./runtimes/ ./artifacts/.
cd artifacts/
sha256sum polkadot | tee polkadot.sha256
Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ members = [
"substrate/client/service/test",
"substrate/client/state-db",
"substrate/client/statement-store",
"substrate/client/statement-store/statement-latency-bench",
"substrate/client/storage-monitor",
"substrate/client/sync-state-rpc",
"substrate/client/sysinfo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN apt-get update && \
ln -s /data /polkadot/.local/share/polkadot

# add polkadot binaries to docker image
COPY ./artifacts/polkadot ./artifacts/polkadot-execute-worker ./artifacts/polkadot-prepare-worker /usr/local/bin
COPY ./artifacts/polkadot ./artifacts/polkadot-execute-worker ./artifacts/polkadot-prepare-worker ./artifacts/statement-latency-bench /usr/local/bin

# add runtime binaries to docker image
COPY ./artifacts/runtimes /polkadot/runtimes/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "statement-latency-bench"
version = "0.1.0"
description = "CLI tool for distributed statement store latency benchmarking"
authors.workspace = true
edition.workspace = true
license.workspace = true
publish = false

[[bin]]
name = "statement-latency-bench"
path = "src/main.rs"

[dependencies]
anyhow = { workspace = true }
clap = { workspace = true, features = ["derive"] }
codec = { workspace = true }
env_logger = { workspace = true }
jsonrpsee = { workspace = true, features = ["ws-client", "client-ws-transport-tls"] }
log = { workspace = true }
serde = { workspace = true, features = ["derive"] }
sp-core = { workspace = true, default-features = true }
sp-statement-store = { workspace = true, default-features = true, features = ["serde"] }
tokio = { workspace = true, features = ["rt-multi-thread", "time", "sync"] }
61 changes: 61 additions & 0 deletions substrate/client/statement-store/statement-latency-bench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Statement Store Latency Benchmark

CLI tool for benchmarking statement store latency at scale. Clients form a ring topology where each subscribes to statements from the next client, measuring propagation latency across the network.

## Building

```bash
cargo build --release -p statement-latency-bench
```

## Usage

Basic example:

```bash
statement-latency-bench \
--rpc-endpoints ws://localhost:9944,ws://localhost:9945 \
--num-clients 10 \
--messages-pattern "5:512"
```

Multi-round with custom settings:

```bash
statement-latency-bench \
--rpc-endpoints ws://node1:9944,ws://node2:9944 \
--num-clients 100 \
--num-rounds 10 \
--interval-ms 5000 \
--messages-pattern "5:512,1:5120"
```

## CLI Arguments

| Argument | Description | Default |
| ---------------------- | --------------------------------------------------- | ------- |
| `--rpc-endpoints` | Comma-separated WebSocket URLs (required) | - |
| `--num-clients` | Number of clients to spawn | 100 |
| `--messages-pattern` | Message pattern "count:size" (e.g., "5:512,3:1024") | "5:512" |
| `--num-rounds` | Number of benchmark rounds | 1 |
| `--interval-ms` | Interval between rounds (ms) | 10000 |
| `--receive-timeout-ms` | Timeout for receiving messages (ms) | 5000 |

## How It Works

1. Clients are distributed round-robin across RPC endpoints
2. Each client sends statements with unique topics
3. Each client subscribes to statements from the next client in the ring
4. Latency is measured from submission to receipt via subscription

## Output

Results are logged with min/avg/max statistics for:
- Send duration
- Receive duration
- Full latency

Example output:
```
Benchmark Results: send_min=0.045s send_avg=0.123s send_max=0.234s receive_min=2.134s receive_avg=3.456s receive_max=5.678s latency_min=2.234s latency_avg=3.567s latency_max=5.789s
```
Loading
Loading