perf(bench): custom SPSC report transport (cpp-fastchan) — competition bench +22–32%#35
Merged
Conversation
Export engine_get_transport() backing the harness report queue with geseq/cpp-fastchan instead of the harness default boost::lockfree::spsc_queue. The matching-engine-benchmark is transport-bound on the report queue (the engine is ~2x faster than the default queue can drain), so a faster SP/SC channel lifts the end-to-end ceiling. The harness API explicitly permits an engine to substitute its own transport. cpp-fastchan won a 5-way same-run SPSC bake-off (boost default / moodycamel / rigtorp / a hand-rolled batched ring / cpp-fastchan): +22-32% over the boost default across all 5 scenarios, best-of-N. Adapter-only; engine untouched. - bench/cpp_orderbook_adapter.cpp: engine_get_transport() over fastchan::SPSC<me_report_t>. - CMakeLists.txt: CPM dep geseq/cpp-fastchan; bracketed with ENABLE_TESTING save/restore so fastchan's own (shared-named) test suite doesn't join our ctest. - bench/build.sh: fastchan include path. Consensus PASS (byte-identical trade streams) on all 5 scenarios. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0196EKKWudtsg3gButufhDxz
Benchmark PRThroughput on hosted runners is noisy and not performance-calibrated; treat the numbers as informational only. Realistic deep-book throughput (W=50000)
Matching-engine-benchmark (perf mode)Harness pinned at
|
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.
Backs the matching-engine-benchmark report queue with
geseq/cpp-fastchaninstead of the harness's defaultboost::lockfree::spsc_queue, via the API'sengine_get_transport()escape hatch. Adapter-only — the engine is untouched.Why
The competition harness is transport-bound: the engine (single-thread replay) runs ~28–37 M msgs/s, but the end-to-end harness caps at ~14 because every report crosses a SP/SC queue to the drainer thread, and the default
boost::lockfree::spsc_queuedoes a release-store per push. Profiling + an assert-on/off A/B confirmed the queue, not the book, is the limiter. The harness API explicitly permits an engine to substitute its own transport ("e.g. a proprietary lock-free ring").What
bench/cpp_orderbook_adapter.cpp: exportengine_get_transport()backed byfastchan::SPSC<me_report_t, 1<<20>(create/push/drain/flush/destroy).CMakeLists.txt: CPM depgeseq/cpp-fastchan, bracketed with anENABLE_TESTINGsave/restore so fastchan's own (shared-named) test suite doesn't join ourctest.bench/build.sh: fastchan include path.Results — 5-way SPSC bake-off (same engine, same-run best-of-12)
cpp-fastchan wins outright: +22–32% over the boost default across all 5 scenarios (M msgs/s), beating moodycamel, rigtorp, and a hand-rolled batched ring. This is the lever that actually moves the competition number — the engine optimizations (already merged) were transport-capped.
Correctness
Byte-identical consensus hash PASS on all 5 scenarios (boost default and cpp-fastchan produce identical trade streams). Verified from a clean from-scratch build.
ctestunaffected (fastchan's own tests excluded).🤖 Generated with Claude Code
https://claude.ai/code/session_0196EKKWudtsg3gButufhDxz