feat: venue decoder crates + SPSC benchmark overhaul #143
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
| name: Benchmarks | |
| on: | |
| pull_request: | |
| branches: [main] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| benchmark: | |
| name: Benchmark (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| persist-credentials: false | |
| - uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly | |
| - name: Detect CPU model (cache key + diagnostics) | |
| id: cpu | |
| run: | | |
| if [ "$RUNNER_OS" = "Linux" ]; then | |
| model=$(grep -m1 'model name' /proc/cpuinfo | cut -d: -f2 | xargs) | |
| else | |
| model=$(sysctl -n machdep.cpu.brand_string 2>/dev/null || echo "unknown") | |
| fi | |
| echo "model=$model" | |
| echo "hash=$(echo "$model" | shasum -a 256 | cut -c1-8)" >> "$GITHUB_OUTPUT" | |
| - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 | |
| with: | |
| prefix-key: "bench-${{ steps.cpu.outputs.hash }}" | |
| - name: Allow perf_event_open (Linux) | |
| if: runner.os == 'Linux' | |
| run: sudo sysctl -w kernel.perf_event_paranoid=1 | |
| # ── Seqlock benchmarks (Criterion) ── | |
| # IMPORTANT: Each Criterion bench must be converted IMMEDIATELY after running, | |
| # before the next `rm -rf target/criterion`. The criterion-to-json.sh script | |
| # reads from target/criterion/<group>/ and uses prefix matching on the bench name. | |
| # If conversion runs after a later bench clears + overwrites criterion/, it will | |
| # pick up the wrong bench's data. | |
| - name: Clear Criterion cache before seqlock bench | |
| run: rm -rf target/criterion | |
| - name: Run seqlock benchmarks | |
| run: cargo +nightly bench --bench seqlock | |
| env: | |
| RUSTFLAGS: "-C target-cpu=native" | |
| - name: Convert seqlock Criterion results to JSON report | |
| run: bash .github/scripts/criterion-to-json.sh seqlock | |
| - name: Convert seqlock report for CI tracking | |
| run: | | |
| jq '[.results[] | {name: ("seqlock/" + .workload), unit: "ns/op", value: .ns_per_op}]' \ | |
| target/bench-report-seqlock.json > bench-output-seqlock.json | |
| # ── Fixed-point benchmarks (Criterion) ── | |
| - name: Clear Criterion cache before fixed-point bench | |
| run: rm -rf target/criterion | |
| - name: Run fixed-point benchmarks | |
| run: cargo +nightly bench --bench fixed | |
| env: | |
| RUSTFLAGS: "-C target-cpu=native" | |
| - name: Convert fixed-point Criterion results to JSON report | |
| run: bash .github/scripts/criterion-to-json.sh fixed | |
| - name: Convert fixed-point report for CI tracking | |
| run: | | |
| jq '[.results[] | {name: ("fixed/" + .workload), unit: "ns/op", value: .ns_per_op}]' \ | |
| target/bench-report-fixed.json > bench-output-fixed.json | |
| # ── Market-state benchmarks (Criterion) ── | |
| - name: Clear Criterion cache before market-state bench | |
| run: rm -rf target/criterion | |
| - name: Run market-state benchmarks | |
| run: cargo +nightly bench --bench market_state | |
| env: | |
| RUSTFLAGS: "-C target-cpu=native" | |
| - name: Convert market-state Criterion results to JSON report | |
| run: bash .github/scripts/criterion-to-json.sh market_state | |
| - name: Convert market-state report for CI tracking | |
| run: | | |
| jq '[.results[] | {name: ("market_state/" + .workload), unit: "ns/op", value: .ns_per_op}]' \ | |
| target/bench-report-market_state.json > bench-output-market_state.json | |
| - name: Merge benchmark outputs | |
| run: | | |
| jq -s 'add' bench-output-seqlock.json bench-output-fixed.json bench-output-market_state.json > bench-output.json | |
| - name: Restore Cargo.lock before gh-pages switch | |
| run: git checkout -- Cargo.lock | |
| - name: Store benchmark result | |
| uses: benchmark-action/github-action-benchmark@a7bc2366eda11037936ea57d811a43b3418d3073 # v1.21.0 | |
| with: | |
| name: Mantis Benchmarks (${{ matrix.os }}) | |
| tool: customSmallerIsBetter | |
| output-file-path: bench-output.json | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| auto-push: false | |
| alert-threshold: "105%" | |
| comment-on-alert: true | |
| fail-on-alert: true | |
| alert-comment-cc-users: "@mantis-maintainers" | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: benchmark-results-${{ matrix.os }} | |
| path: | | |
| target/bench-report-seqlock.json | |
| target/bench-report-fixed.json | |
| target/bench-report-market_state.json | |
| bench-output.json | |
| report: | |
| name: Post benchmark report | |
| needs: benchmark | |
| if: always() && github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| persist-credentials: false | |
| - name: Download Linux results | |
| uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4 | |
| with: | |
| name: benchmark-results-ubuntu-latest | |
| path: results/linux | |
| continue-on-error: true | |
| - name: Download macOS results | |
| uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4 | |
| with: | |
| name: benchmark-results-macos-latest | |
| path: results/macos | |
| continue-on-error: true | |
| - name: Generate markdown report | |
| run: | | |
| linux_seqlock="results/linux/target/bench-report-seqlock.json" | |
| macos_seqlock="results/macos/target/bench-report-seqlock.json" | |
| linux_fixed="results/linux/target/bench-report-fixed.json" | |
| macos_fixed="results/macos/target/bench-report-fixed.json" | |
| linux_market_state="results/linux/target/bench-report-market_state.json" | |
| macos_market_state="results/macos/target/bench-report-market_state.json" | |
| bash .github/scripts/bench-report.sh \ | |
| "$linux_seqlock" "$macos_seqlock" \ | |
| "$linux_fixed" "$macos_fixed" \ | |
| "$linux_market_state" "$macos_market_state" > report.md | |
| - name: Post PR comment | |
| uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.1 | |
| with: | |
| header: benchmark-report | |
| path: report.md |