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
14 changes: 13 additions & 1 deletion Cargo.lock

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

19 changes: 17 additions & 2 deletions crates/service-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,41 @@ base64 = { workspace = true }
bs58 = { workspace = true }
bytes = { workspace = true }
bytestring = { workspace = true }
dashmap = { workspace = true }
derive_builder = { workspace = true }
futures = { workspace = true }
h2 = "0.4.12"
http = { workspace = true }
http-body = { workspace = true }
http-body-util = { workspace = true }
http-serde = { workspace = true }
hyper = { workspace = true, features = ["http1", "http2", "client"] }
hyper-rustls = { workspace = true }
hyper-util = { workspace = true, features = ["client-legacy"] }
jsonwebtoken = { workspace = true }
parking_lot = { workspace = true }
pem = { version = "3.0.6" }
pin-project = { workspace = true }
ring = { version = "0.17.14" }
rustls = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_with = { workspace = true }
thiserror = { workspace = true }
tower-service = { version = "0.3" }
tokio = { workspace = true }
tokio-util = { workspace = true }
tokio-rustls = "0.26"
tower = { workspace = true }
tracing = { workspace = true }
zstd = { workspace = true }

[dev-dependencies]
criterion = { workspace = true, features = ["async_tokio"] }
googletest = { workspace = true }
tempfile = { workspace = true }
pprof = { version = "0.15", features = ["criterion", "flamegraph"] }
tempfile = { workspace = true }
tokio-stream = {workspace = true}

[[bench]]
name = "h2_pool_benchmark"
harness = false
73 changes: 73 additions & 0 deletions crates/service-client/benches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Service Client Benchmarks

Compares the custom H2 connection pool against hyper_util's legacy client and the raw h2 client using in-memory duplex streams.

## Benchmark groups

| Group | What it measures |
|-------|-----------------|
| `sequential` | Single request latency |
| `concurrent/{10,50}` | Throughput under H2 multiplexing |
| `body-{1KB,64KB}` | Data echo throughput |

## Running benchmarks

Run all benchmarks:

```bash
cargo bench -p restate-service-client --bench h2_pool_benchmark
```

Dry-run (verify they execute without measuring):

```bash
cargo bench -p restate-service-client --bench h2_pool_benchmark -- --test
```

Run a single benchmark by name filter:

```bash
cargo bench -p restate-service-client --bench h2_pool_benchmark -- "sequential/custom-pool"
```

## CPU profiling with pprof (built-in)

The benchmarks include [pprof](https://github.com/tikv/pprof-rs) integration that generates flamegraph SVGs.

### Prerequisites

On Linux, allow perf events:

```bash
sudo sysctl kernel.perf_event_paranoid=-1
```

### Profile a benchmark

Pass `--profile-time=<seconds>` to activate profiling:

```bash
cargo bench -p restate-service-client --bench h2_pool_benchmark -- "sequential/custom-pool" --profile-time=30
```

The flamegraph is written to:

```
target/criterion/sequential/custom-pool/profile/flamegraph.svg
```

Open it in a browser for an interactive view.

## CPU profiling with samply (external)

[samply](https://github.com/mstange/samply) can profile the benchmark binary without any code changes.

```bash
# Build the benchmark binary (release mode)
cargo bench -p restate-service-client --bench h2_pool_benchmark --no-run

# Find and run with samply
samply record target/release/deps/h2_pool_benchmark-* --bench "sequential/custom-pool" --profile-time=30
```

This opens the Firefox Profiler UI automatically.
Loading
Loading