Repository navigation
Compile the generated code with loop-head checkpoints only - #259
Merged
Merged
Conversation
The 2026-10-20 work showed that checkpointing only loop heads takes about 8% off an undrawn race frame on the AYN Thor, but releases kept compiling the shipped generated directory, whose label checkpoints are mostly at labels reached only forwards (143,424 of 172,524). The build now converts each ppc_recomp.*.cpp into the build directory through scripts/loop_head_checkpoints.py --file (CMake option SFR_LOOP_HEAD_CHECKPOINTS, on by default) and compiles the copies; the generated directory is untouched and current generator output passes through unchanged. The result is byte-identical .text to a build pointed at a hand-made copy. AYN Thor, forced skipping, three runs each: undrawn_ms 7.11 -> 6.76 ms, the main thread's own work in an undrawn frame 5.74 -> 4.92 ms, its CPU per frame 8.77 -> 7.95 ms. Windows unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
The build now applies
scripts/loop_head_checkpoints.pyitself. With the new CMake optionSFR_LOOP_HEAD_CHECKPOINTS(on by default), eachppc_recomp.*.cppis converted into<build>/loop-head-checkpoints/(loop_head_checkpoints.py --file, a custom command per file) and the game compiles those copies. The generated directory is not touched, and output from the current generator, which already checkpoints only loop heads, comes through unchanged.Why
PR #222 measured that checkpointing only loop heads cuts about 8% from an undrawn race frame on the AYN Thor. Shipping that needed the release's generated directory converted by hand, and that step was never done: up to 0.10.25, releases compiled the shipped code with all 172,524 label checkpoints, and 143,424 of those are at labels that are only reached forwards.
Checked
.textthat is byte-identical to a build pointed at a copy converted by hand (43.8 MB, down from 52.6 MB). Windows (clang-cl, D3D12 and Vulkan) races ran to the present limit. A secondninjarun with nothing changed does no work.SFR_RACE_FRAMESKIP=2 SFR_TEST_RACE_DRAW_MS=20), frames 14,000-20,500, three interleaved runs each:The main thread's own work in an undrawn frame drops by 14% and its CPU per frame by 9%. The undrawn frame itself drops by 5%: the main thread now gets to its waits for the job workers sooner, and it waits there longer.
build_tools.ps1doesn't build); Python 357 OK (11 skipped).The numbers and a variant that was tried and dropped (packed entry-flag reads) are in
docs/performance.md, under "2026-10-23".Releases need Python 3 at build time while the option is on. They already use it for packaging.
🤖 Generated with Claude Code