Skip to content

feat(perf): v1.19.0 "Afterburner" - PGO/BOLT pipeline#109

Merged
doublegate merged 2 commits into
mainfrom
feat/v1.19.0-afterburner
Jul 15, 2026
Merged

feat(perf): v1.19.0 "Afterburner" - PGO/BOLT pipeline#109
doublegate merged 2 commits into
mainfrom
feat/v1.19.0-afterburner

Conversation

@doublegate

Copy link
Copy Markdown
Owner

Summary

  • New scripts/pgo/run.sh: instrument → train against the committed permissive ROM corpus (via
    a new crates/rustysnes-test-harness/src/bin/pgo_trainer.rs binary — the gilyon
    CPU-instruction suite plus a handful of undisbeliever HDMA-glitch/INIDISP-hammer ROMs for
    control-flow breadth beyond the single steady-state headless_frame bench ROM) → optimized
    rebuild of the shipping rustysnes binary.
  • New .github/workflows/pgo.yml: workflow_dispatch + release-tag push only — never the PR
    gate, since an instrument+train+rebuild cycle is far too slow for that. Promotion requires
    both: a measured >3% Criterion speedup over the plain release build on the same runner,
    and a byte-identical re-run of the full --features test-roms oracle under the PGO-merged
    profile (cites docs/adr/0004's determinism contract — never promotes on speed alone). An
    optional Linux-only BOLT post-link stage chains onto an already-promoted PGO binary,
    best-effort.
  • Found and fixed a real, latent CI gap while building this: rust-toolchain.toml didn't
    list llvm-tools-preview, and dtolnay/rust-toolchain silently ignores the rust-setup
    composite action's own components: input whenever a rust-toolchain.toml file exists (the
    same class of bug already found and fixed for ios.yml in v1.16.0) — without this fix,
    cargo-pgo's .profraw/.profdata merging would have silently failed to find the component
    on a fresh CI runner.

Test plan

  • cargo test --workspace --exclude rustysnes-android — all green
  • cargo clippy --workspace --exclude rustysnes-android --all-targets -- -D warnings — clean
  • cargo fmt --check — clean
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --exclude rustysnes-android --no-deps — clean
  • cargo build -p rustysnes-core --target thumbv7em-none-eabihf --no-default-features — no_std gate green
  • cargo deny check / cargo audit — clean
  • actionlint .github/workflows/pgo.yml — clean
  • Real, full local pipeline run: scripts/pgo/run.sh 60 produces a genuine, running
    PGO-optimized rustysnes binary (instrument build → pgo_trainer over all 5 committed ROMs →
    optimized rebuild).
  • Real determinism-gate run: cargo pgo optimize test -- -p rustysnes-test-harness --release --features test-roms passes cleanly under the PGO-merged profile (golden
    framebuffers, SA-1/Super FX on-cart boots, save-state determinism/backward-compat, SPC700
    oracle all pass).
  • Real A/B Criterion comparison: plain vs PGO headless_frame_steady_state — documented
    honestly in docs/performance.md (short local training run did not clear the >3% bar; this
    is expected, not a bug — CI's real 3600-frame sweep is what the promotion gate actually
    decides on).

🤖 Generated with Claude Code

Adds scripts/pgo/run.sh (instrument -> train against the committed
permissive ROM corpus via a new pgo_trainer binary -> optimized
rebuild) and .github/workflows/pgo.yml (workflow_dispatch + release-
tag push only; promotion requires both a >3% Criterion speedup and a
byte-identical --features test-roms re-run under the PGO profile, an
optional Linux-only BOLT post-link stage). Also fixes a real latent
CI gap: rust-toolchain.toml was missing llvm-tools-preview, which
dtolnay/rust-toolchain silently ignores as a composite-action input
whenever the toolchain file exists (same class of bug already found
and fixed for ios.yml in v1.16.0).

Verified for real: the full instrument/train/optimized-rebuild
pipeline produces a genuine running rustysnes binary, and the
determinism oracle passes cleanly under the PGO-merged profile.
Copilot AI review requested due to automatic review settings July 14, 2026 23:55

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a Profile-Guided Optimization (PGO) and BOLT pipeline for the shipping rustysnes binary, adding a new training-workload binary (pgo_trainer.rs), a runner script (scripts/pgo/run.sh), documentation updates, and adding llvm-tools-preview to rust-toolchain.toml. The review feedback correctly points out that on standard Rust setups, cargo build compiles binaries directly into target/release/ rather than target//release/, which would cause the runner script to fail with a 'No such file or directory' error. The reviewer provides robust fallback suggestions to dynamically resolve these paths.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread scripts/pgo/run.sh
Comment thread scripts/pgo/run.sh

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in Profile-Guided Optimization (PGO) + optional BOLT pipeline for the shipping rustysnes binary, including a dedicated CI workflow to build, benchmark (A/B), and enforce the project’s byte-identical determinism contract before any optimized artifact is considered promotable.

Changes:

  • Introduces a local PGO driver script (scripts/pgo/run.sh) and a committed-ROM training binary (pgo_trainer) to generate representative profiles deterministically from the permissive ROM corpus.
  • Adds a dedicated GitHub Actions workflow (pgo.yml) that runs only on manual dispatch or release tags and gates promotion on both speedup (>3%) and a full --features test-roms byte-identical oracle.
  • Updates toolchain/docs/changelog to document and support the pipeline (including adding llvm-tools-preview to the pinned toolchain components).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/pgo/run.sh Local instrument → train → optimized rebuild recipe for rustysnes using committed ROMs.
rust-toolchain.toml Adds llvm-tools-preview to the pinned toolchain components for profiling tooling support.
docs/performance.md Documents the new PGO/BOLT pipeline and the CI promotion criteria (speed + determinism).
crates/rustysnes-test-harness/src/bin/pgo_trainer.rs Adds a training workload binary that runs multiple committed permissive ROMs for profile breadth.
CHANGELOG.md Records the new pipeline and the CI/toolchain gap fix under Unreleased.
.github/workflows/pgo.yml Adds the non-PR-gated CI workflow implementing the PGO promotion gate and optional BOLT stage.

Comment thread .github/workflows/pgo.yml
Comment thread .github/workflows/pgo.yml Outdated
Real bug found in review: re-invoking scripts/pgo/run.sh between
cargo pgo bolt build and cargo pgo bolt optimize ran a separate,
non-BOLT PGO cycle that never fed BOLT's profile and could clobber
the bolt-instrumented binary. Fixed per cargo-pgo's own documented
BOLT+PGO workflow: --with-pgo on both calls, profile gathering
skipped (cargo-pgo's own documented fallback) since driving the
frontend's GUI binary for real workload coverage needs a display
this project's frontend has no headless mode for.
@doublegate
doublegate merged commit 1f5d46b into main Jul 15, 2026
12 checks passed
@doublegate
doublegate deleted the feat/v1.19.0-afterburner branch July 15, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants