test(raft): smart-routing bench shows 6× speedup over manual rotation#594
Merged
Conversation
The previous TestRaftBench_MultiShardScale bench rotated nodes manually on every retry — it never exercised the 307 redirect or the http.Client redirect-following path, so the headline number (596 cycles/s on a 3-node raft cluster) understated reality by ~6×. This bench reproduces the SAME workload (create → claim → submit, 32 goroutines, 5 s window) with the full smart-routing stack engaged: - RAFT_MUX_ENABLED on every node → 1 TCP listener per node for raft - PeerHTTPAddrs wired pre-bootstrap via httptest.NewUnstartedServer + handler swap (the only way to wire HTTP URLs before NewApplication needs them) - http.Client with default CheckRedirect (follows 307 with POST body preserved per RFC 7231) Numbers on the dev box (WSL2, load ~3.5): 3-node × 1-shard (raft + smart routing): ~3,949 cycles/s 3-node × 4-shard (raft + smart routing): ~3,883 cycles/s multi/single ratio: 0.98x The 6× speedup over manual rotation is the value of server-side 307 redirects. The remaining gap to single-node Pebble (76k tasks/s) is the cost of consensus on 3 writes per cycle through 3 nodes. Multi-shard doesn't speed up further over single-shard at this load because the mux acceptor (one TCP listener per node) serializes connection accepts across shards — the per-shard commit pipelines have plenty of headroom, but the wire layer becomes the bottleneck. Future work: per-shard listeners with mux + a connection pool, OR a gRPC stream-multiplexed transport that doesn't serialize on accept. Test runtime: ~13 s end-to-end (2 subtests × ~6.5 s each).
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The previous `TestRaftBench_MultiShardScale` bench (#588) reported ~596 cycles/s on a 3-node raft cluster — and concluded multi-shard wasn't faster than single-shard. Turns out it never exercised the 307 redirect or the redirect-following client, so manual node rotation was the dominant cost. With smart routing engaged the same workload runs at ~3,949 cycles/s — a 6.6× speedup.
What landed
`pkg/app/raft_smart_routing_bench_test.go` — reproduces the SAME workload (create → claim → submit, 32 goroutines, 5 s window) with the full smart-routing stack:
Numbers (dev box, WSL2, load ~3.5)
Single-shard vs multi-shard ratio stays at ~1.0× — multi-raft doesn't multiply throughput at this workload because the mux acceptor serializes connection accepts across shards. Per-shard commit pipelines have plenty of headroom; the wire layer is the bottleneck. Documented as a follow-up.
Context
Test plan
🤖 Generated with Claude Code