WIP: perf(lift): RX_LOOP_SINK=1, a loop's guest-register stores sunk to its exits (compile only, off) #1978

Draft
siantm wants to merge 5 commits from siantm/Longshot:perf/lift-loop-sink into main
Contributor

Summary

LLVM keeps a lifted loop's stores of its guest registers inside the loop while the loop holds a call it cannot prove
returns: the interrupt poll's a64_poll_cur. With RX_LOOP_SINK=1 the native lifted code and the shared A64 helpers
are built with -mllvm -force-attribute=a64_poll_cur:willreturn (true: the poll returns when the thread runs again),
so the stores move to the loop's exits. The page marks stay main's release stores, each after the guest store it
marks; the context is the thread's own (restrict, noescape), never read by the collector or the checkpoint. The
emulator-hosted DLL keeps main's flags. Off by default: main's flags, and a64.h is main's in either mode. Compile
only; the build's log names the mode, and dev.py pack builds the game when it is on. From 7d85292a on a local
performance branch, reworked in review: the switch first also made the marks plain byte stores on x86-64; the reviewers
asked to keep release marks (a plain mark racing with the collector's acquire exchange is a data race the compiler may
exploit), so that half is dropped.

Read first: loop_sink_flags and native_flags in nx2/build.py, docs/dev/reference/loop-stores.md,
tests/test_loop_sink.py.

Testing

Tested: Windows 11, i7-9700, RTX 4060, llvm-mingw clang 23.1.5, Python 3.14.7 (the Builder's); game-free checks
only. This change has not run in the game on this PC yet, with the switch on or off (Still to test). Each check ran in
a hidden console of its own, through the PC's job queue (job fb2-1978-probe3), on this change's tree before its
rebase onto main @ f1f2dc5b (whose one commit touches none of its files) and before comment and doc edits (head
5114aeae after them), the test run with no arguments (its compiler found through LONGSHOT_MINGW, as
tests/run_all.py gives it):

  • python -I -B tests/test_loop_sink.py: exit 0, "all passed": the flags for every off and on value, read at each
    build, the DLL's unchanged, the header the same either way, the pack routes; in the IR at O1 and O2, bitmap off and
    on, "copy CCGMMCC, load-only CCC" with the switch off and "copy GMM, load-only" (no context store) with it on (G a
    guest store, M a release mark, C a context store); seeds 1 to 3, O1 and O2, bitmap off and on, the same digest,
    polls and marks either way (e.g. "seed 3, O2, bitmap on: off 3b699ce7951861dc 7657 3701, on 3b699ce7951861dc 7657
    3701"), the exact marks and polls checked in every round.

The same test with tests/test_vk_pgo.py and tests/test_light_passes.py is queued on 5114aeae itself (job
fb2-1978-final); its result goes in a comment.

git diff --quiet origin/main HEAD -- nx2/rtgen.py holds: the generated header is main's.

Earlier, at 89531648 (the first form, plain marks), python -I -B tests/run_all.py --strict --changed origin/main on
main @ 2e1f6c32: 98 passed, 17 failed (named in that run's comment as failing on main too; two of them, test_pipeline_states.py and test_recorder_sync.py, had found no Vulkan headers in that run (RX_CPM unset) and compiled nothing on either side), 7 skipped. That run was
not repeated on this head. Those two, run again with the headers at 5114aeae and on main @ f1f2dc5b: test_pipeline_states.py passes on both; test_recorder_sync.py fails on main too with the same lines.

Round 2 (dev.py base and the shared base): the base is keyed by its commit alone, and dev.py base passed the
caller's environment to its build, so a base first built with RX_LOOP_SINK=1 became the off side of every later A/B. Now
the shared base's build leaves the switch out (scripts/devtools/build.py cmd_base, packs.GAME_COMPILE_SWITCHES). The IR order check now also covers the bitmap-on loop: each mark block runs after the guest store (the store's block dominates it).
The branch was rebased unchanged onto main @ 9dd41326 (git range-diff: "=" for the PR's commit). Through the PC's job
queue (job fb2-lift-r2, RX_CPM set, each check in a hidden console of its own, 20 minutes at most):

  • python -I -B tests/test_loop_sink.py at the test commit db1993b4: exit 1, "1 failed": "dev.py base, RX_LOOP_SINK=1 then unset: its
    build leaves RX_LOOP_SINK out, as main builds it"; at the fix, head 57ae9f39: exit 0, "all passed" (both orders, one base build,
    without the switch).
  • tests/test_vk_pgo.py and tests/test_light_passes.py at 57ae9f39: exit 0 each.

Round 3 (dev.py packs base and a base you name): round 2 left the switch out only in dev.py base. The
documented dev.py packs base runs packs.cmd_base directly, whose build still took RX_LOOP_SINK from the caller's
environment, so a named base built with it on was what a later dev.py packs rt with it unset copied. Now
packs.cmd_base, where both commands converge, builds with the game's compile-only experiments
(GAME_COMPILE_SWITCHES) taken out of the environment after packs.run merges the caller's; the wrapper's own strip is
gone. A pack with the switch on still builds its own game in that mode. On main @ 9dd41326 (main has not moved; the
earlier commits are unchanged), through the PC's job queue (job fb2-lift-r3b, light, two checks at once at most,
RX_CPM set, each check in a hidden console of its own, 20 minutes at most):

  • python -I -B tests/test_loop_sink.py at the test commit 0100d3c5: exit 1, "2 failed": "dev.py packs base, RX_LOOP_SINK=1 first,
    unset second: the base's build (make_game.py's environment) has no RX_LOOP_SINK, as main builds it" and "...: dev.py packs
    rt with the switch unset and no pack runs a game built off (got on)"; at the fix, head 947af7d2: exit 0, "all passed"
    (dev.py packs base and dev.py base, each with the switch on first and unset second and the other way round, then
    dev.py packs rt with no pack, and dev.py packs pack and rt with the switch on).
  • tests/test_dev_packs.py and tests/test_dev_build.py at 947af7d2: one failure each, the same on main @ 9dd41326
    in the same job ("every file the renderer keeps beside the game is classified (unknown:
    ['longshot_fsr4_pipelines.bin'])"; Linux.test_folders: C:\Users\User\Games against C:\Users\User/Games).

In the game, on this PC (Windows 11, i7-9700, RTX 4060), 2026-11-22: Kokiri Forest 800x600, RX_LOOP_SINK unset against
set at build, both at 947af7d2, a warm-up a side then 8 interleaved runs a side, every run in the same scene state: median
calm game time a frame 10.26 against 10.10 ms with it on, 1.6 % lower, no gain shown (Measurements).

Still to test:

  • Windows 11, this PC (i7-9700): a clean build of the game with RX_LOOP_SINK unset and with it set, its build time and the
    executable's size, expecting figures for Measurements (by hand)
  • Linux: python3 -I -B tests/test_loop_sink.py, expecting it to pass; and the game built with the switch unset and set, played in
    Kokiri Forest, expecting no crash and frame times alike (by hand)
  • Steam Deck: the game with RX_LOOP_SINK unset and set, Kokiri Forest or the Market, a few interleaved runs a side, expecting
    no crash and frame times alike (by hand)
  • Windows and Linux (Test Farm): the existing request, default lifted C and lift timing with the switch unset against
    main @ 9dd41326, expecting the same lifted code; held until the farm pairs this head with 9dd41326 (the Test Farm request already on this PR)

Measurements

Verdict: RX_LOOP_SINK ships off (the maintainer's request, while the enabled and disabled results are gathered). In play,
no loss, and no gain shown: the median calm game time a frame is 1.6 % lower with the switch on (10.10 against 10.26 ms), inside the spread. Eight runs a side resolve roughly 1.5 to 2 % on the median (an estimate: identical runs of one build spread
about 5 % end to end in calm game time). The switch stays off.

In play: Kokiri Forest, off against on at 947af7d2, 8 runs a side (the current reading)

Setup: Windows 11, i7-9700, RTX 4060, run alone on the PC on 2026-11-22, 06:05 to 06:48 UTC; Kokiri Forest (child), 800x600
(CPU-paced), frame cap off, 60 s a run; a warm-up a side, then 8 interleaved runs a side (off on on off, four times). The
teleport into the scene checked as taken in every run, so every run is in the same (light) scene state; the GPU cooled
to 70 °C before each run, its median clock over each measured stretch its full 2,745 to 2,760 MHz (the few dips are in
the clk_min column). Calm game time: the measured 60 s in six
10 s windows, each window whose median game time is more than 20 % above the run's lowest dropped (a burst), then the
median game time of the frames left; blocked: the game thread's wait over the same frames.

Baseline: this PR with RX_LOOP_SINK unset (off), which builds with main's flags and header, so it stands for main @ 9dd41326
(the merge base); on = set at build.

Kokiri Forest, 8 runs a side, median (range) Before, switch unset: this PR @ 947af7d2 After, RX_LOOP_SINK=1: this PR @ 947af7d2
calm game ms a frame 10.26 (9.97 to 10.45) 10.10 (9.97 to 10.33)
fps 87.4 (74.7 to 90.6) 88.3 (77.2 to 90.1)
p99 frame ms 17.2 (15.7 to 44.9) 17.3 (15.8 to 44.0)
blocked ms a frame 8.46 (8.23 to 8.80) 8.34 (8.27 to 8.71)
burst windows dropped 2 runs, 4 windows 1 run, 2 windows

Each run (the run's table; game and calm in ms a frame; clock in MHz over the measured stretch):

tag           runtime    fps   med_ms  p99_ms  low1  class  game   calm   bursts  blocked  gpu_start  gpu_max  slowed  cool_wait  clock  clk_min  idle_s
ls4-warm-off  lsink-off  81.6  10.62   49.19   20.3  light  9.95   9.95   0       8.13     70         82       0.00    0 s        2760   2760     0
ls4-warm-on   lsink-on   80.8  11.35   35.85   27.9  light  10.64  10.50  1       8.60     71         79       0.00    5 s        2760   2760     0
ls4-off1      lsink-off  86.5  11.18   16.84   59.4  light  10.45  10.45  0       8.50     73         75       0.00    5 s        2760   2760     0
ls4-on2       lsink-on   85.4  10.92   42.42   23.6  light  10.05  10.05  0       8.36     72         81       0.00    5 s        2760   2520     1
ls4-on3       lsink-on   88.4  10.84   17.34   57.7  light  10.25  10.25  0       8.27     73         84       0.01    5 s        2745   2745     0
ls4-off4      lsink-off  74.7  11.59   44.90   22.3  light  10.75  10.40  2       8.80     73         81       0.00    5 s        2760   2145     5
ls4-off5      lsink-off  87.8  10.99   17.02   58.8  light  10.25  10.25  0       8.48     73         84       0.00    5 s        2745   2745     0
ls4-on6       lsink-on   89.4  10.79   16.29   61.4  light  9.97   9.97   0       8.29     73         81       0.00    5 s        2760   2760     0
ls4-on7       lsink-on   88.2  10.86   17.10   58.5  light  10.05  10.05  0       8.41     74         81       0.00    10 s       2760   2760     0
ls4-off8      lsink-off  89.0  10.79   17.39   57.5  light  9.97   9.97   0       8.27     74         82       0.00    10 s       2760   2760     0
ls4-off9      lsink-off  79.7  11.27   37.02   27.0  light  10.57  10.27  2       8.62     74         84       0.00    10 s       2760   2760     0
ls4-on10      lsink-on   88.7  10.83   17.16   58.3  light  10.14  10.14  0       8.31     73         82       0.00    5 s        2760   2760     0
ls4-on11      lsink-on   90.1  10.75   15.82   63.2  light  10.04  10.04  0       8.36     74         84       0.00    10 s       2745   2745     0
ls4-off12     lsink-off  90.6  10.70   15.70   63.7  light  10.12  10.12  0       8.23     72         80       0.00    5 s        2760   2760     0
ls4-off13     lsink-off  89.6  10.75   16.62   60.2  light  10.00  10.00  0       8.24     73         84       0.00    10 s       2760   2760     0
ls4-on14      lsink-on   77.2  11.49   44.03   22.7  light  10.84  10.33  2       8.71     73         82       0.00    5 s        2760   2760     0
ls4-on15      lsink-on   88.1  10.86   18.02   55.5  light  10.19  10.19  0       8.31     73         83       0.00    5 s        2760   2760     0
ls4-off16     lsink-off  86.9  11.02   19.04   52.5  light  10.29  10.29  0       8.44     73         82       0.00    5 s        2760   2760     0

Clean build time and size, Linux and the Steam Deck are not measured.

Earlier: 4 runs a side, before the wrapper checked the teleport (2026-11-22, 00:15 to 01:03 UTC)

Reading then: not decided, no loss seen. Every run sits in one of two scene states, and both sides land in both.

Setup: Windows 11, i7-9700, RTX 4060, run alone on the PC on 2026-11-22; Kokiri Forest (child), 800x600 (CPU-paced),
frame cap off, 60 s a run; one warm-up a side, then 4 interleaved runs a side (off on on off off on on off). off = RX_LOOP_SINK
unset, whose lifted code, object keys and executable are those of main @ 9dd41326 (the merge base); on = set at build.

run side fps median frame ms p99 frame ms state
off1 off 67.60 14.20 36.37 heavy
on2 on 82.34 11.75 19.30 light
on3 on 81.50 12.14 17.42 light
off4 off 75.91 12.91 43.83 light
off5 off 69.44 13.54 28.20 heavy
on6 on 70.32 13.27 32.30 heavy
on7 on 72.63 13.19 20.82 heavy
off8 off 76.40 13.03 27.48 light

Range: off 67.6 to 76.4 fps, on 70.3 to 82.3. The two states: light about 1,100 textures a frame and 76 to 83 fps, heavy
about 1,380 and 67 to 73. The run wrapper asks the Debug teleport into Kokiri Forest, where the save already puts Link; asked
within about 22 frames of entering play, the game refuses it and nothing reloads (heavy), asked later it is taken (light).
Within one state the on side leads in each pairing (heavy: off 67.6 and 69.4 fps, on 70.3 and 72.6; light: off 75.9 and 76.4, on 81.5 and 82.3), but that is two runs a cell, too few to call a gain.

Game-free checks

Setup: Windows 11, i7-9700, llvm-mingw clang 23.1.5; tests/test_loop_sink.py through the PC's job queue

Baseline: this head with the switch unset, which builds the lifted code with main's flags and main's a64.h, so it
stands for main in the fixture's IR.

Before: this PR @ 5114aeae, switch off (as main) After: this PR @ 5114aeae, RX_LOOP_SINK=1
Context stores in the fixture's loops (IR, -O1 and -O2, bitmap off and on) copy loop 4, load-only loop 3, every iteration none in either loop; the copy loop's release marks kept

Risks

The marks keep main's release order; only the poll's call is declared to return. With the switch on, a loop's context stores move to its exits, also in loops that
contain marked guest stores, so during such a loop the context in memory lags the loop's registers. Not verified: what
a fault, an interrupt or a sampler reading the context in the middle of such a loop sees. Off by default: unset, the build is
main's. Turning it off is unsetting it and building again: an executable keeps what it was built with. Changing it
compiles the lifted code again, and translates the game again where the translated C is gone (a player's build folder;
a development checkout and LONGSHOT_KEEP_BUILD_FILES=1 keep it). Nothing a player keeps (saves,
longshot_options.ini) changes.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary LLVM keeps a lifted loop's stores of its guest registers inside the loop while the loop holds a call it cannot prove returns: the interrupt poll's `a64_poll_cur`. With `RX_LOOP_SINK=1` the native lifted code and the shared A64 helpers are built with `-mllvm -force-attribute=a64_poll_cur:willreturn` (true: the poll returns when the thread runs again), so the stores move to the loop's exits. The page marks stay main's release stores, each after the guest store it marks; the context is the thread's own (`restrict`, `noescape`), never read by the collector or the checkpoint. The emulator-hosted DLL keeps main's flags. Off by default: main's flags, and `a64.h` is main's in either mode. Compile only; the build's log names the mode, and `dev.py pack` builds the game when it is on. From 7d85292a on a local performance branch, reworked in review: the switch first also made the marks plain byte stores on x86-64; the reviewers asked to keep release marks (a plain mark racing with the collector's acquire exchange is a data race the compiler may exploit), so that half is dropped. Read first: `loop_sink_flags` and `native_flags` in `nx2/build.py`, `docs/dev/reference/loop-stores.md`, `tests/test_loop_sink.py`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060, llvm-mingw clang 23.1.5, Python 3.14.7 (the Builder's); game-free checks only. This change has not run in the game on this PC yet, with the switch on or off (Still to test). Each check ran in a hidden console of its own, through the PC's job queue (job fb2-1978-probe3), on this change's tree before its rebase onto `main` @ f1f2dc5b (whose one commit touches none of its files) and before comment and doc edits (head 5114aeae after them), the test run with no arguments (its compiler found through `LONGSHOT_MINGW`, as `tests/run_all.py` gives it): - `python -I -B tests/test_loop_sink.py`: exit 0, "all passed": the flags for every off and on value, read at each build, the DLL's unchanged, the header the same either way, the pack routes; in the IR at O1 and O2, bitmap off and on, "copy CCGMMCC, load-only CCC" with the switch off and "copy GMM, load-only" (no context store) with it on (G a guest store, M a release mark, C a context store); seeds 1 to 3, O1 and O2, bitmap off and on, the same digest, polls and marks either way (e.g. "seed 3, O2, bitmap on: off 3b699ce7951861dc 7657 3701, on 3b699ce7951861dc 7657 3701"), the exact marks and polls checked in every round. The same test with `tests/test_vk_pgo.py` and `tests/test_light_passes.py` is queued on 5114aeae itself (job fb2-1978-final); its result goes in a comment. `git diff --quiet origin/main HEAD -- nx2/rtgen.py` holds: the generated header is main's. Earlier, at 89531648 (the first form, plain marks), `python -I -B tests/run_all.py --strict --changed origin/main` on `main` @ 2e1f6c32: 98 passed, 17 failed (named in that run's comment as failing on `main` too; two of them, `test_pipeline_states.py` and `test_recorder_sync.py`, had found no Vulkan headers in that run (`RX_CPM` unset) and compiled nothing on either side), 7 skipped. That run was not repeated on this head. Those two, run again with the headers at 5114aeae and on `main` @ f1f2dc5b: `test_pipeline_states.py` passes on both; `test_recorder_sync.py` fails on `main` too with the same lines. **Round 2** (`dev.py base` and the shared base): the base is keyed by its commit alone, and `dev.py base` passed the caller's environment to its build, so a base first built with `RX_LOOP_SINK=1` became the off side of every later A/B. Now the shared base's build leaves the switch out (`scripts/devtools/build.py` `cmd_base`, `packs.GAME_COMPILE_SWITCHES`). The IR order check now also covers the bitmap-on loop: each mark block runs after the guest store (the store's block dominates it). The branch was rebased unchanged onto `main` @ 9dd41326 (`git range-diff`: "=" for the PR's commit). Through the PC's job queue (job fb2-lift-r2, `RX_CPM` set, each check in a hidden console of its own, 20 minutes at most): - `python -I -B tests/test_loop_sink.py` at the test commit db1993b4: exit 1, "1 failed": "dev.py base, RX_LOOP_SINK=1 then unset: its build leaves RX_LOOP_SINK out, as main builds it"; at the fix, head 57ae9f39: exit 0, "all passed" (both orders, one base build, without the switch). - `tests/test_vk_pgo.py` and `tests/test_light_passes.py` at 57ae9f39: exit 0 each. **Round 3** (`dev.py packs base` and a base you name): round 2 left the switch out only in `dev.py base`. The documented `dev.py packs base` runs `packs.cmd_base` directly, whose build still took `RX_LOOP_SINK` from the caller's environment, so a named base built with it on was what a later `dev.py packs rt` with it unset copied. Now `packs.cmd_base`, where both commands converge, builds with the game's compile-only experiments (`GAME_COMPILE_SWITCHES`) taken out of the environment after `packs.run` merges the caller's; the wrapper's own strip is gone. A pack with the switch on still builds its own game in that mode. On `main` @ 9dd41326 (main has not moved; the earlier commits are unchanged), through the PC's job queue (job fb2-lift-r3b, light, two checks at once at most, `RX_CPM` set, each check in a hidden console of its own, 20 minutes at most): - `python -I -B tests/test_loop_sink.py` at the test commit 0100d3c5: exit 1, "2 failed": "dev.py packs base, RX_LOOP_SINK=1 first, unset second: the base's build (make_game.py's environment) has no RX_LOOP_SINK, as main builds it" and "...: dev.py packs rt with the switch unset and no pack runs a game built off (got on)"; at the fix, head 947af7d2: exit 0, "all passed" (`dev.py packs base` and `dev.py base`, each with the switch on first and unset second and the other way round, then `dev.py packs rt` with no pack, and `dev.py packs pack` and `rt` with the switch on). - `tests/test_dev_packs.py` and `tests/test_dev_build.py` at 947af7d2: one failure each, the same on `main` @ 9dd41326 in the same job ("every file the renderer keeps beside the game is classified (unknown: ['longshot_fsr4_pipelines.bin'])"; `Linux.test_folders`: `C:\Users\User\Games` against `C:\Users\User/Games`). In the game, on this PC (Windows 11, i7-9700, RTX 4060), 2026-11-22: Kokiri Forest 800x600, `RX_LOOP_SINK` unset against set at build, both at 947af7d2, a warm-up a side then 8 interleaved runs a side, every run in the same scene state: median calm game time a frame 10.26 against 10.10 ms with it on, 1.6 % lower, no gain shown (Measurements). **Still to test:** - Windows 11, this PC (i7-9700): a clean build of the game with `RX_LOOP_SINK` unset and with it set, its build time and the executable's size, expecting figures for Measurements (by hand) - Linux: `python3 -I -B tests/test_loop_sink.py`, expecting it to pass; and the game built with the switch unset and set, played in Kokiri Forest, expecting no crash and frame times alike (by hand) - Steam Deck: the game with `RX_LOOP_SINK` unset and set, Kokiri Forest or the Market, a few interleaved runs a side, expecting no crash and frame times alike (by hand) - Windows and Linux (Test Farm): the existing request, default lifted C and lift timing with the switch unset against `main` @ 9dd41326, expecting the same lifted code; held until the farm pairs this head with 9dd41326 (the Test Farm request already on this PR) ## Measurements **Verdict:** `RX_LOOP_SINK` ships off (the maintainer's request, while the enabled and disabled results are gathered). In play, no loss, and no gain shown: the median calm game time a frame is 1.6 % lower with the switch on (10.10 against 10.26 ms), inside the spread. Eight runs a side resolve roughly 1.5 to 2 % on the median (an estimate: identical runs of one build spread about 5 % end to end in calm game time). The switch stays off. **In play: Kokiri Forest, off against on at 947af7d2, 8 runs a side (the current reading)** Setup: Windows 11, i7-9700, RTX 4060, run alone on the PC on 2026-11-22, 06:05 to 06:48 UTC; Kokiri Forest (child), 800x600 (CPU-paced), frame cap off, 60 s a run; a warm-up a side, then 8 interleaved runs a side (off on on off, four times). The teleport into the scene checked as taken in every run, so every run is in the same (light) scene state; the GPU cooled to 70 °C before each run, its median clock over each measured stretch its full 2,745 to 2,760 MHz (the few dips are in the clk_min column). Calm game time: the measured 60 s in six 10 s windows, each window whose median game time is more than 20 % above the run's lowest dropped (a burst), then the median game time of the frames left; blocked: the game thread's wait over the same frames. Baseline: this PR with `RX_LOOP_SINK` unset (off), which builds with `main`'s flags and header, so it stands for `main` @ 9dd41326 (the merge base); on = set at build. | Kokiri Forest, 8 runs a side, median (range) | Before, switch unset: this PR @ 947af7d2 | After, RX_LOOP_SINK=1: this PR @ 947af7d2 | |---|---|---| | calm game ms a frame | 10.26 (9.97 to 10.45) | 10.10 (9.97 to 10.33) | | fps | 87.4 (74.7 to 90.6) | 88.3 (77.2 to 90.1) | | p99 frame ms | 17.2 (15.7 to 44.9) | 17.3 (15.8 to 44.0) | | blocked ms a frame | 8.46 (8.23 to 8.80) | 8.34 (8.27 to 8.71) | | burst windows dropped | 2 runs, 4 windows | 1 run, 2 windows | Each run (the run's table; game and calm in ms a frame; clock in MHz over the measured stretch): ``` tag runtime fps med_ms p99_ms low1 class game calm bursts blocked gpu_start gpu_max slowed cool_wait clock clk_min idle_s ls4-warm-off lsink-off 81.6 10.62 49.19 20.3 light 9.95 9.95 0 8.13 70 82 0.00 0 s 2760 2760 0 ls4-warm-on lsink-on 80.8 11.35 35.85 27.9 light 10.64 10.50 1 8.60 71 79 0.00 5 s 2760 2760 0 ls4-off1 lsink-off 86.5 11.18 16.84 59.4 light 10.45 10.45 0 8.50 73 75 0.00 5 s 2760 2760 0 ls4-on2 lsink-on 85.4 10.92 42.42 23.6 light 10.05 10.05 0 8.36 72 81 0.00 5 s 2760 2520 1 ls4-on3 lsink-on 88.4 10.84 17.34 57.7 light 10.25 10.25 0 8.27 73 84 0.01 5 s 2745 2745 0 ls4-off4 lsink-off 74.7 11.59 44.90 22.3 light 10.75 10.40 2 8.80 73 81 0.00 5 s 2760 2145 5 ls4-off5 lsink-off 87.8 10.99 17.02 58.8 light 10.25 10.25 0 8.48 73 84 0.00 5 s 2745 2745 0 ls4-on6 lsink-on 89.4 10.79 16.29 61.4 light 9.97 9.97 0 8.29 73 81 0.00 5 s 2760 2760 0 ls4-on7 lsink-on 88.2 10.86 17.10 58.5 light 10.05 10.05 0 8.41 74 81 0.00 10 s 2760 2760 0 ls4-off8 lsink-off 89.0 10.79 17.39 57.5 light 9.97 9.97 0 8.27 74 82 0.00 10 s 2760 2760 0 ls4-off9 lsink-off 79.7 11.27 37.02 27.0 light 10.57 10.27 2 8.62 74 84 0.00 10 s 2760 2760 0 ls4-on10 lsink-on 88.7 10.83 17.16 58.3 light 10.14 10.14 0 8.31 73 82 0.00 5 s 2760 2760 0 ls4-on11 lsink-on 90.1 10.75 15.82 63.2 light 10.04 10.04 0 8.36 74 84 0.00 10 s 2745 2745 0 ls4-off12 lsink-off 90.6 10.70 15.70 63.7 light 10.12 10.12 0 8.23 72 80 0.00 5 s 2760 2760 0 ls4-off13 lsink-off 89.6 10.75 16.62 60.2 light 10.00 10.00 0 8.24 73 84 0.00 10 s 2760 2760 0 ls4-on14 lsink-on 77.2 11.49 44.03 22.7 light 10.84 10.33 2 8.71 73 82 0.00 5 s 2760 2760 0 ls4-on15 lsink-on 88.1 10.86 18.02 55.5 light 10.19 10.19 0 8.31 73 83 0.00 5 s 2760 2760 0 ls4-off16 lsink-off 86.9 11.02 19.04 52.5 light 10.29 10.29 0 8.44 73 82 0.00 5 s 2760 2760 0 ``` Clean build time and size, Linux and the Steam Deck are not measured. **Earlier: 4 runs a side, before the wrapper checked the teleport (2026-11-22, 00:15 to 01:03 UTC)** Reading then: not decided, no loss seen. Every run sits in one of two scene states, and both sides land in both. Setup: Windows 11, i7-9700, RTX 4060, run alone on the PC on 2026-11-22; Kokiri Forest (child), 800x600 (CPU-paced), frame cap off, 60 s a run; one warm-up a side, then 4 interleaved runs a side (off on on off off on on off). off = `RX_LOOP_SINK` unset, whose lifted code, object keys and executable are those of `main` @ 9dd41326 (the merge base); on = set at build. | run | side | fps | median frame ms | p99 frame ms | state | |---|---|---|---|---|---| | off1 | off | 67.60 | 14.20 | 36.37 | heavy | | on2 | on | 82.34 | 11.75 | 19.30 | light | | on3 | on | 81.50 | 12.14 | 17.42 | light | | off4 | off | 75.91 | 12.91 | 43.83 | light | | off5 | off | 69.44 | 13.54 | 28.20 | heavy | | on6 | on | 70.32 | 13.27 | 32.30 | heavy | | on7 | on | 72.63 | 13.19 | 20.82 | heavy | | off8 | off | 76.40 | 13.03 | 27.48 | light | Range: off 67.6 to 76.4 fps, on 70.3 to 82.3. The two states: light about 1,100 textures a frame and 76 to 83 fps, heavy about 1,380 and 67 to 73. The run wrapper asks the Debug teleport into Kokiri Forest, where the save already puts Link; asked within about 22 frames of entering play, the game refuses it and nothing reloads (heavy), asked later it is taken (light). Within one state the on side leads in each pairing (heavy: off 67.6 and 69.4 fps, on 70.3 and 72.6; light: off 75.9 and 76.4, on 81.5 and 82.3), but that is two runs a cell, too few to call a gain. **Game-free checks** Setup: Windows 11, i7-9700, llvm-mingw clang 23.1.5; `tests/test_loop_sink.py` through the PC's job queue Baseline: this head with the switch unset, which builds the lifted code with main's flags and main's `a64.h`, so it stands for main in the fixture's IR. | | Before: this PR @ 5114aeae, switch off (as main) | After: this PR @ 5114aeae, RX_LOOP_SINK=1 | |---|---|---| | Context stores in the fixture's loops (IR, -O1 and -O2, bitmap off and on) | copy loop 4, load-only loop 3, every iteration | none in either loop; the copy loop's release marks kept | ## Risks The marks keep main's release order; only the poll's call is declared to return. With the switch on, a loop's context stores move to its exits, also in loops that contain marked guest stores, so during such a loop the context in memory lags the loop's registers. Not verified: what a fault, an interrupt or a sampler reading the context in the middle of such a loop sees. Off by default: unset, the build is main's. Turning it off is unsetting it and building again: an executable keeps what it was built with. Changing it compiles the lifted code again, and translates the game again where the translated C is gone (a player's build folder; a development checkout and `LONGSHOT_KEEP_BUILD_FILES=1` keep it). Nothing a player keeps (saves, `longshot_options.ini`) changes. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [ ] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
perf(lift): RX_LOOP_SINK=1, a loop's guest-register stores sunk to its exits (compile only, off)
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 6s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
8ffcba44d1
LLVM's LICM keeps a lifted loop's stores of its guest registers inside the loop while the loop holds an ordered atomic
store (each page mark is a release store) or a call it cannot prove returns (the interrupt poll's a64_poll_cur): both
causes keep the stores alone. With RX_LOOP_SINK=1 the marks are plain byte stores on x86-64 (-DA64_MARK_PLAIN: the
data-then-mark order the renderer's scan needs still holds, as x86-64 keeps stores in program order and the compiler
cannot prove a guest pointer does not alias a64_dirty) and the poll's call is willreturn (-force-attribute), which is
true: it returns when the thread runs again. Off by default (the flags and the code main has); compile only, so a
build that sets it keeps the lift (make_game.py and dev.py's COMPILE_ONLY_ENV). docs/dev/reference/loop-stores.md
explains the causes and carries the branch's measurements, labelled as such.

tests/test_loop_sink.py: the flags and header text, a lifted-shaped loop's IR at -O1/-O2 (on: no context store left in
the loop, plain marks after the guest store; off: release marks, the stores in the loop), and the loop built into a
program run from the same random states with the switch off and on: same registers, memory, marks and polls taken.

From 7d85292a on exp/x86-asm-sync (where it was on by default), as split from the local trial 7326db9f/92123e22.

Assisted-by: Claude Code
BeanBot left a comment

Recommendation: Request changes. The opt-in build removes the atomic publication the renderer relies on, and the default build invalidates every cached lifted object on update. The reported Windows fixture shows loop-store sinking, but the performance gain in play is unproven.

The build experiment can keep guest registers in host registers until eligible loops exit, reducing stores during play. It changes the write-watch protocol across lifted and host code and adds a full lifted-code rebuild on the first update even for players who leave it off.

@fix will do (12)

  1. L1 nx2/rtgen.py:71: A plain dirty-byte store can race with another writer or the atomic acquire exchange in host/rx_backend.c. (more on the line)
  2. L2 nx2/rtgen.py:64: The generated a64.h changes with RX_LOOP_SINK unset. (more on the line)
  3. L3 docs/dev/reference/loop-stores.md:83: The table reports outputs counted from IR and assembly lifted from the game's hottest functions. (more on the line)
  4. L4 (minor) docs/dev/reference/loop-stores.md:61: Changing the switch keeps the lift key, but a normal player build may already have discarded code_*.c. (more on the line)
  5. L5 (minor) nx2/build.py:1757: The emulator-hosted DLL gets the experimental mark flag, but A64_POLL_CTX routes its polls through a64_poll(c), so the forced attribute on a64_poll_cur cannot help that path. Keep the DLL on its existing mark and poll flags unless that mode has its own supported optimization and coverage.
  6. L6 tests/test_loop_sink.py:176: The stand-in writes c.poll through cur_ while the lifted function accesses the same field through its restrict-qualified argument. (more on the line)
  7. L7 tests/test_loop_sink.py:155: The IR check only compares the first guest store with the first mark in textual block order. (more on the line)
  8. L8 tests/test_loop_sink.py:37: The suite hardcodes --cc clang, which bypasses the fixture's CC and llvm-mingw fallback. (more on the line)
  9. L9 tests/test_loop_sink.py:34: Importing build before setting up the fixture captures the ambient RX_MARK_BITMAP, RX_MARCH, RX_TARGET, and LONGSHOT_SYSROOT. (more on the line)
  10. L10 (minor) tests/test_loop_sink.py:115: The IR parser requires the exact prefix define dso_local void. (more on the line)
  11. L11 (its part an edit can do): Add the effective build mode to the build log so the A/B results identify which executable had the optimization.
  12. L12 (minor): The reported check was a changed-file run, and the seven skips are unnamed. The totals also sum to 122 while Testing says 121 checks were selected. Reconcile the counts with the job output, name the skips, and record the required full check and lint results. Add the Linux and Windows host-build coverage to the checklist once it is available.

For the author (1) (a run, a measurement or a decision)

  • L11 (minor): The project requires an in-game run before opening this type of PR and a measured gain before merging. After the fixes, compare the merge base with the PR off and on using matching saves, scenes, settings, hardware and build type. Report interleaved average FPS, 1% lows, median and p99 frame times, and clean build time and size. Cover Windows, Linux and the affected Tier 1 configurations, including Steam Deck. Include gameplay that exercises dirty-page capture and virtual-core polling.

Checks: Still running: PR description / Description follows the template (pull_request_target), CI / Conventional Commit title (pull_request), CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request), CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request), CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request), CI / Workflow lint (actionlint) (pull_request), CI / Website build and checks (pull_request), Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request), Third-party parts / The same as upstream (pull_request).

More: does it help, other systems, switches, what was read

Does it help: Unproven. The reported Windows run at 89531648 matched digests and poll counts for six synthetic comparisons, covering three seeds at each of O1 and O2. The base fixture stopped at a missing Python helper. The historical experimental-branch figures use a different base and a scratch workload. There are no interleaved gameplay results against 6e1521a70a or clean build time and size results.

Other systems: The dirty-byte changes reach Vulkan replay and submit-time capture on every GPU vendor, including Steam Deck. Native polls reach the virtual-core scheduler on Windows and Linux. The emulator-hosted DLL still uses its context-taking callback. Both native builders hash the changed header in their object keys. The diff leaves the renderer API, shaders, save and options formats, audio, and input code untouched. Gameplay coverage for the affected systems is pending.

Switches: RX_LOOP_SINK is a build-only developer switch. Unset, empty, 0, false, off, and no disable it. Enabling it adds A64_MARK_PLAIN, effective on x86-64, and asks LLVM to mark a64_poll_cur willreturn for polling builds. Off is the safe runtime default for this patch, and the default build must also preserve cached objects. The build-switch reference has a row. The runtime switches.def table does not cover build-only variables.

Reviewed: 8ffcba44d1 against 6e1521a70a: Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, the standards, the commit and complete diff, both changed documentation files, nx2/rtgen.py, and tests/test_loop_sink.py in full. Read the changed sections and relevant callers in nx2/build.py, nx2/make_game.py, and scripts/devtools/build.py. Traced dirty marks, capture and replay, the poll and scheduler, the DLL shim, toolchain selection, object and lift caching, and test discovery. Skimmed recorded results and nearby fixtures. No local review checklist or sibling Tooling checkout was available. There were no changed translations or checked-in generated files.; nothing run (a code review).

Checked and fine:

  • The commit carries the required AI assistance trailer. No vendored sources, renderer API layouts, or shader sources changed.
  • The existing page mask still bounds both dirty-table indexes, and the test driver's randomized copy ranges fit its synthetic buffer.
  • The developer-build list suppresses the lift-key warning for the compile-only switch. The make_game lift key also excludes it, and enabled and disabled objects have distinct compile keys.
  • The production poll passes no Ctx pointer and the checkpoint's scheduler path is documented to leave guest registers alone.
  • The new test's compiler invocations, temporary programs, and cleanup are within the described fixture workflow. The diff passed the whitespace check.

Testing: Read-only review. The author reported a passing Windows fixture on 89531648 and 17 changed-suite failures also seen on the base. The supplied CI checks are pending. Linux fixture results, gameplay, and build measurements are outstanding.

Overlaps and merge order: None found in local history. Forgejo was unavailable for overlap checks.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The opt-in build removes the atomic publication the renderer relies on, and the default build invalidates every cached lifted object on update. The reported Windows fixture shows loop-store sinking, but the performance gain in play is unproven. The build experiment can keep guest registers in host registers until eligible loops exit, reducing stores during play. It changes the write-watch protocol across lifted and host code and adds a full lifted-code rebuild on the first update even for players who leave it off. **`@fix` will do (12)** 1. **L1** `nx2/rtgen.py:71`: A plain dirty-byte store can race with another writer or the atomic acquire exchange in host/rx_backend.c. (more on the line) 2. **L2** `nx2/rtgen.py:64`: The generated a64.h changes with RX_LOOP_SINK unset. (more on the line) 3. **L3** `docs/dev/reference/loop-stores.md:83`: The table reports outputs counted from IR and assembly lifted from the game's hottest functions. (more on the line) 4. **L4** (minor) `docs/dev/reference/loop-stores.md:61`: Changing the switch keeps the lift key, but a normal player build may already have discarded code_*.c. (more on the line) 5. **L5** (minor) `nx2/build.py:1757`: The emulator-hosted DLL gets the experimental mark flag, but A64_POLL_CTX routes its polls through a64_poll(c), so the forced attribute on a64_poll_cur cannot help that path. Keep the DLL on its existing mark and poll flags unless that mode has its own supported optimization and coverage. 6. **L6** `tests/test_loop_sink.py:176`: The stand-in writes c.poll through cur_ while the lifted function accesses the same field through its restrict-qualified argument. (more on the line) 7. **L7** `tests/test_loop_sink.py:155`: The IR check only compares the first guest store with the first mark in textual block order. (more on the line) 8. **L8** `tests/test_loop_sink.py:37`: The suite hardcodes --cc clang, which bypasses the fixture's CC and llvm-mingw fallback. (more on the line) 9. **L9** `tests/test_loop_sink.py:34`: Importing build before setting up the fixture captures the ambient RX_MARK_BITMAP, RX_MARCH, RX_TARGET, and LONGSHOT_SYSROOT. (more on the line) 10. **L10** (minor) `tests/test_loop_sink.py:115`: The IR parser requires the exact prefix define dso_local void. (more on the line) 11. **L11** (its part an edit can do): Add the effective build mode to the build log so the A/B results identify which executable had the optimization. 12. **L12** (minor): The reported check was a changed-file run, and the seven skips are unnamed. The totals also sum to 122 while Testing says 121 checks were selected. Reconcile the counts with the job output, name the skips, and record the required full check and lint results. Add the Linux and Windows host-build coverage to the checklist once it is available. **For the author (1)** (a run, a measurement or a decision) - **L11** (minor): The project requires an in-game run before opening this type of PR and a measured gain before merging. After the fixes, compare the merge base with the PR off and on using matching saves, scenes, settings, hardware and build type. Report interleaved average FPS, 1% lows, median and p99 frame times, and clean build time and size. Cover Windows, Linux and the affected Tier 1 configurations, including Steam Deck. Include gameplay that exercises dirty-page capture and virtual-core polling. **Checks:** Still running: `PR description / Description follows the template (pull_request_target)`, `CI / Conventional Commit title (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request)`, `CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request)`, `CI / Workflow lint (actionlint) (pull_request)`, `CI / Website build and checks (pull_request)`, `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`, `Third-party parts / The same as upstream (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The reported Windows run at 89531648 matched digests and poll counts for six synthetic comparisons, covering three seeds at each of O1 and O2. The base fixture stopped at a missing Python helper. The historical experimental-branch figures use a different base and a scratch workload. There are no interleaved gameplay results against 6e1521a70a32 or clean build time and size results. **Other systems:** The dirty-byte changes reach Vulkan replay and submit-time capture on every GPU vendor, including Steam Deck. Native polls reach the virtual-core scheduler on Windows and Linux. The emulator-hosted DLL still uses its context-taking callback. Both native builders hash the changed header in their object keys. The diff leaves the renderer API, shaders, save and options formats, audio, and input code untouched. Gameplay coverage for the affected systems is pending. **Switches:** RX_LOOP_SINK is a build-only developer switch. Unset, empty, 0, false, off, and no disable it. Enabling it adds A64_MARK_PLAIN, effective on x86-64, and asks LLVM to mark a64_poll_cur willreturn for polling builds. Off is the safe runtime default for this patch, and the default build must also preserve cached objects. The build-switch reference has a row. The runtime switches.def table does not cover build-only variables. **Reviewed:** 8ffcba44d195 against 6e1521a70a32: Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, the standards, the commit and complete diff, both changed documentation files, nx2/rtgen.py, and tests/test_loop_sink.py in full. Read the changed sections and relevant callers in nx2/build.py, nx2/make_game.py, and scripts/devtools/build.py. Traced dirty marks, capture and replay, the poll and scheduler, the DLL shim, toolchain selection, object and lift caching, and test discovery. Skimmed recorded results and nearby fixtures. No local review checklist or sibling Tooling checkout was available. There were no changed translations or checked-in generated files.; nothing run (a code review). **Checked and fine:** - The commit carries the required AI assistance trailer. No vendored sources, renderer API layouts, or shader sources changed. - The existing page mask still bounds both dirty-table indexes, and the test driver's randomized copy ranges fit its synthetic buffer. - The developer-build list suppresses the lift-key warning for the compile-only switch. The make_game lift key also excludes it, and enabled and disabled objects have distinct compile keys. - The production poll passes no Ctx pointer and the checkpoint's scheduler path is documented to leave guest registers alone. - The new test's compiler invocations, temporary programs, and cleanup are within the described fixture workflow. The diff passed the whitespace check. **Testing:** Read-only review. The author reported a passing Windows fixture on 89531648 and 17 changed-suite failures also seen on the base. The supplied CI checks are pending. Linux fixture results, gameplay, and build measurements are outstanding. **Overlaps and merge order:** None found in local history. Forgejo was unavailable for overlap checks. </details> --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -0,0 +58,4 @@
- At a poll, the context in memory may now be older than the loop's registers. `hos_vcore_checkpoint` is already
required never to read it (`host/hos_thread.c`); loop loads were already kept in host registers across polls.
Unset, `0` or `off`: release marks and the plain poll, the flags main has. The switch is compile-only: a build that
Member

L4 (minor): Changing the switch keeps the lift key, but a normal player build may already have discarded code_*.c. Its retained objects cannot be reused after a compiler flag change, so the builder can translate again. Qualify the promise here, in the build reference, and in the PR summary. For an A/B, explain how to keep the translated C and build both variants before launching them.

**L4** (minor): Changing the switch keeps the lift key, but a normal player build may already have discarded code_*.c. Its retained objects cannot be reused after a compiler flag change, so the builder can translate again. Qualify the promise here, in the build reference, and in the PR summary. For an A/B, explain how to keep the translated C and build both variants before launching them.
@ -0,0 +80,4 @@
Each half alone, at `-O2`, in dynamic instructions: plain marks alone -0.3%, the poll's `willreturn` alone 0.0%,
both -5.3%.
Static counts for the game's 46 hottest functions under 150 KB of C (context loads and stores counted in the IR,
Member

L3: The table reports outputs counted from IR and assembly lifted from the game's hottest functions. The hot-function trial below also quotes derived outputs. Remove the game-derived figures and use a fixture authored independently of the dump. Correct the PR's no-game-output checklist entry accordingly.

**L3**: The table reports outputs counted from IR and assembly lifted from the game's hottest functions. The hot-function trial below also quotes derived outputs. Remove the game-derived figures and use a fixture authored independently of the dump. Correct the PR's no-game-output checklist entry accordingly.
nx2/rtgen.py Outdated
@ -61,18 +61,27 @@ MARK_NATIVE_64 = r"""extern uint8_t a64_dirty[A64_DIRTY_PAGES];
/* (Tried 2026-10-21: reading a mark first and writing it only when clear, against cache lines moving between cores:
game threads +1.1 ms a frame, the code 18 MB bigger. Not kept.) */
#define A64_DIRTY_AT(a) (((uint64_t)(a) >> 12) & (A64_DIRTY_PAGES - 1))
/* (nx2/rtgen.py) A64_MARK_PLAIN (nx2/build.py loop_sink_flags) on x86-64: a mark is a plain byte store. LLVM's LICM takes an
Member

L2: The generated a64.h changes with RX_LOOP_SINK unset. build.py includes its bytes in every lifted object's dependencies. An ordinary player update with only retained objects returns KEPT_STALE, then make_game.py translates the game again and recompiles every lifted chunk. Generate the base header byte for byte on the off path and select the experimental header only for the enabled build.

**L2**: The generated a64.h changes with RX_LOOP_SINK unset. build.py includes its bytes in every lifted object's dependencies. An ordinary player update with only retained objects returns KEPT_STALE, then make_game.py translates the game again and recompiles every lifted chunk. Generate the base header byte for byte on the off path and select the experimental header only for the enabled build.
nx2/rtgen.py Outdated
@ -64,0 +68,4 @@
stores, because the data's address is a guest integer made into a pointer, which it cannot prove does not point into
a64_dirty. Without the switch, or on other CPUs, the release store as before. */
#if defined(A64_MARK_PLAIN) && (defined(__x86_64__) || defined(_M_X64))
#define A64_MARK_ONE(p) (*(p) = 1)
Member

L1: A plain dirty-byte store can race with another writer or the atomic acquire exchange in host/rx_backend.c. x86 store ordering applies to emitted instructions, and possible aliasing does not prevent the compiler from eliminating a repeated plain mark to the same page. If the renderer clears the byte between two guest stores, an eliminated publication can leave a capture using stale data. Keep release-atomic marks on shared pages and restrict register promotion to paths where it can preserve that publication.

**L1**: A plain dirty-byte store can race with another writer or the atomic acquire exchange in host/rx_backend.c. x86 store ordering applies to emitted instructions, and possible aliasing does not prevent the compiler from eliminating a repeated plain mark to the same page. If the renderer clears the byte between two guest stores, an eliminated publication can leave a capture using stale data. Keep release-atomic marks on shared pages and restrict register promotion to paths where it can preserve that publication.
@ -0,0 +31,4 @@
sys.path.insert(0, os.path.join(ROOT, "nx2"))
sys.path.insert(0, HERE)
import kit # noqa: E402,F401 (a64-kit on the path)
import build # noqa: E402
Member

L9: Importing build before setting up the fixture captures the ambient RX_MARK_BITMAP, RX_MARCH, RX_TARGET, and LONGSHOT_SYSROOT. For example, RX_MARK_BITMAP=0 removes all coverage of the bitmap branch and can still pass, while RX_TARGET=windows with llvm-mingw on Linux can produce a PE file that the fixture tries to execute. Use a controlled native target and baseline CPU, and run both bitmap variants explicitly.

**L9**: Importing build before setting up the fixture captures the ambient RX_MARK_BITMAP, RX_MARCH, RX_TARGET, and LONGSHOT_SYSROOT. For example, RX_MARK_BITMAP=0 removes all coverage of the bitmap branch and can still pass, while RX_TARGET=windows with llvm-mingw on Linux can produce a PE file that the fixture tries to execute. Use a controlled native target and baseline CPU, and run both bitmap variants explicitly.
@ -0,0 +34,4 @@
import build # noqa: E402
import rtgen # noqa: E402
RUN_ALL_ARGS = ["--cc", "clang"]
Member

L8: The suite hardcodes --cc clang, which bypasses the fixture's CC and llvm-mingw fallback. With LLVM-MinGW installed through LONGSHOT_MINGW and no clang on PATH, the strict suite fails before the fixture can run. Let the fixture resolve an explicit compiler, a compatible CC, or the configured toolchain, and derive its target from the chosen compiler so the generated program runs on the test host.

**L8**: The suite hardcodes --cc clang, which bypasses the fixture's CC and llvm-mingw fallback. With LLVM-MinGW installed through LONGSHOT_MINGW and no clang on PATH, the strict suite fails before the fixture can run. Let the fixture resolve an explicit compiler, a compatible CC, or the configured toolchain, and derive its target from the chosen compiler so the generated program runs on the test host.
@ -0,0 +112,4 @@
def loop_blocks(ir):
"""the IR of f_80000000's loop: its blocks from the first one a branch goes back to, to the last such branch"""
body = ir[ir.index("define dso_local void @f_80000000"):]
Member

L10 (minor): The IR parser requires the exact prefix define dso_local void. Clang on Linux can omit dso_local for a preemptible definition, for example with the fixture's --cflags set to -fPIC. Locate the definition by symbol, tolerate optional linkage and visibility attributes, and report a failed assertion if the function or loop is missing.

**L10** (minor): The IR parser requires the exact prefix define dso_local void. Clang on Linux can omit dso_local for a preemptible definition, for example with the fixture's --cflags set to -fPIC. Locate the definition by symbol, tolerate optional linkage and visibility attributes, and report a failed assertion if the function or loop is missing.
@ -0,0 +152,4 @@
check("willreturn" not in attrs, "%s: a64_poll_cur as declared" % what)
check(marks and all(o == "release" for _, o in marks), "%s: release marks: %s" % (what, marks))
check(ctx_st >= 2, "%s: the loop stores its registers (%d)" % (what, ctx_st))
guest = re.search(r"store i64 [^\n]*, align 1\n", loop)
Member

L7: The IR check only compares the first guest store with the first mark in textual block order. The executable checks final state after a single writer finishes, and every eight-byte destination is aligned, so no write crosses a page and no collector clears a mark during the loop. Add a cross-page case with expected marks and exercise a clear between writes to the same page. Check that each publication follows the data it covers.

**L7**: The IR check only compares the first guest store with the first mark in textual block order. The executable checks final state after a single writer finishes, and every eight-byte destination is aligned, so no write crosses a page and no collector clears a mark during the loop. Add a cross-page case with expected marks and exercise a clear between writes to the same page. Check that each publication follows the data it covers.
@ -0,0 +173,4 @@
void a64_poll_cur(void) {
polls_++;
(void)rand(); /* (a C library call) */
if (++npoll_ %% 3) __atomic_store_n(&cur_->poll, 1, __ATOMIC_RELAXED);
Member

L6: The stand-in writes c.poll through cur_ while the lifted function accesses the same field through its restrict-qualified argument. That violates the restrict contract during the call and makes the poll-count comparison unreliable under optimization. Have the stand-in record the call without accessing Ctx. Test repeated requests through the scheduler's atomic request path.

**L6**: The stand-in writes c.poll through cur_ while the lifted function accesses the same field through its restrict-qualified argument. That violates the restrict contract during the call and makes the poll-count comparison unreliable under optimization. Have the stand-in record the call without accessing Ctx. Test repeated requests through the scheduler's atomic request path.
futondestroyer left a comment

Recommendation: Request changes. Preserve atomic dirty-page publication in the enabled build and preserve retained-object reuse in the default build.

  • The opt-in store in nx2/rtgen.py:71 races with the collector’s acquire exchange. The compiler can remove a repeated plain mark that a concurrent collector would have cleared between guest writes. Keep release publications for pages the collector can clear and test that interleaving. Existing inline finding
  • With the switch unset, nx2/build.py still hashes the changed generated header into every lifted object. A player update that retained only objects falls back to translating and compiling again. Preserve the off-mode header bytes and test retained-object reuse. Existing inline finding
  • Replace the game-derived compiler-output counts with results from an independently authored fixture. The current fixture also compares final states after the writer completes, so it cannot catch a publication lost during collection. Existing documentation finding, existing fixture finding

Does it help? Unproven. The author reported six matching Windows synthetic comparisons before rebasing. The same-head CI snapshot showed the description check passing and source checks pending. Gameplay, Linux, and clean build time and size are outstanding. Compare the merge base, PR default, and PR enabled builds on Windows and Linux, including Steam Deck, with interleaved gameplay that exercises Vulkan capture and virtual-core polling.

Switch and farm. RX_LOOP_SINK is build-only and defaults to off. The stock farm plan cannot inject it at compile time, so enabling it takes a separately built executable. The current head has no farm approval or plan. After the code blockers are resolved, any farm run needs two distinct BigBeans approvals for the exact head because the diff touches nx2/. Farm state

Overlaps. The current patches conflict with the dirty-page mask PR and the poll calling-convention PR. Recheck the shared generator and compile flags if either lands first.

Reviewed 8ffcba44d195 against 6e1521a70a32. Read all seven changed files and verified the write-watch, scheduler, DLL callback, and build-cache paths using revision-matched local Graphify maps and source. No PR code ran. Existing full review

**Recommendation: Request changes.** Preserve atomic dirty-page publication in the enabled build and preserve retained-object reuse in the default build. - The opt-in store in `nx2/rtgen.py:71` races with the collector’s acquire exchange. The compiler can remove a repeated plain mark that a concurrent collector would have cleared between guest writes. Keep release publications for pages the collector can clear and test that interleaving. [Existing inline finding](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62550) - With the switch unset, `nx2/build.py` still hashes the changed generated header into every lifted object. A player update that retained only objects falls back to translating and compiling again. Preserve the off-mode header bytes and test retained-object reuse. [Existing inline finding](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62551) - Replace the game-derived compiler-output counts with results from an independently authored fixture. The current fixture also compares final states after the writer completes, so it cannot catch a publication lost during collection. [Existing documentation finding](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62552), [existing fixture finding](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62555) **Does it help?** Unproven. The author reported six matching Windows synthetic comparisons before rebasing. The same-head CI snapshot showed the description check passing and source checks pending. Gameplay, Linux, and clean build time and size are outstanding. Compare the merge base, PR default, and PR enabled builds on Windows and Linux, including Steam Deck, with interleaved gameplay that exercises Vulkan capture and virtual-core polling. **Switch and farm.** `RX_LOOP_SINK` is build-only and defaults to off. The stock farm plan cannot inject it at compile time, so enabling it takes a separately built executable. The current head has no farm approval or plan. After the code blockers are resolved, any farm run needs two distinct BigBeans approvals for the exact head because the diff touches `nx2/`. [Farm state](https://beanstalk.magicbean.dev/prs/1978) **Overlaps.** The current patches conflict with [the dirty-page mask PR](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1979) and [the poll calling-convention PR](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1985). Recheck the shared generator and compile flags if either lands first. **Reviewed** `8ffcba44d195` against `6e1521a70a32`. Read all seven changed files and verified the write-watch, scheduler, DLL callback, and build-cache paths using revision-matched local Graphify maps and source. No PR code ran. [Existing full review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559)
siantm force-pushed perf/lift-loop-sink from 8ffcba44d1
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 6s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to 5114aeaed4
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 24s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-21 03:54:59 +00:00
Compare
Author
Contributor

Pushed 5114aeae (one commit, on main @ f1f2dc5b; it replaces 8ffcba44). The maintainer's review decided the scope: the plain marks are dropped, every mark stays main's release store, and RX_LOOP_SINK=1 only declares the poll's call willreturn, for the native build (the DLL keeps main's flags). nx2/rtgen.py is main's again, so a64.h is the same in either mode and retained objects keep their keys. In the fixture (clang 23.1.5, O1 and O2, bitmap off and on) that alone is enough: a copy loop with release marks and a load-only loop keep no context store with the switch on. dev.py pack builds the game when it is on; the build's log names the mode; the counts over the game's lifted functions are removed (squashed so that no pushed doc keeps them). Tested: tests/test_loop_sink.py all passed on this code before the rebase and comment edits; the run on 5114aeae itself is queued and its result follows here. Still to test: the in-game A/B and Linux.

Pushed 5114aeae (one commit, on `main` @ f1f2dc5b; it replaces 8ffcba44). The maintainer's review decided the scope: the plain marks are dropped, every mark stays main's release store, and `RX_LOOP_SINK=1` only declares the poll's call `willreturn`, for the native build (the DLL keeps main's flags). `nx2/rtgen.py` is main's again, so `a64.h` is the same in either mode and retained objects keep their keys. In the fixture (clang 23.1.5, O1 and O2, bitmap off and on) that alone is enough: a copy loop with release marks and a load-only loop keep no context store with the switch on. `dev.py pack` builds the game when it is on; the build's log names the mode; the counts over the game's lifted functions are removed (squashed so that no pushed doc keeps them). Tested: `tests/test_loop_sink.py` all passed on this code before the rebase and comment edits; the run on 5114aeae itself is queued and its result follows here. Still to test: the in-game A/B and Linux.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62742: addressed in 5114aeae (one commit, rebased on main @ f1f2dc5b), and your first point decided the scope: the plain marks are dropped, every mark stays main's release store, and RX_LOOP_SINK=1 now only marks the poll's call willreturn (native build); in the fixture (clang 23.1.5) a copy loop with release marks and a load-only loop still keep no context store with it on. a64.h is main's byte for byte again (git diff --quiet origin/main HEAD -- nx2/rtgen.py holds), so retained objects keep their keys in either mode. The game-derived counts are removed; the fixture now checks in the IR that each guest store is followed by its two release marks, and at run time stores across pages and has the poll take every mark between writes with an acquire exchange, checking the exact marks left after the last one. The A/B in play (merge base, off, on) is pending with the opener.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62742](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62742): addressed in 5114aeae (one commit, rebased on `main` @ f1f2dc5b), and your first point decided the scope: the plain marks are dropped, every mark stays main's release store, and `RX_LOOP_SINK=1` now only marks the poll's call `willreturn` (native build); in the fixture (clang 23.1.5) a copy loop with release marks and a load-only loop still keep no context store with it on. `a64.h` is main's byte for byte again (`git diff --quiet origin/main HEAD -- nx2/rtgen.py` holds), so retained objects keep their keys in either mode. The game-derived counts are removed; the fixture now checks in the IR that each guest store is followed by its two release marks, and at run time stores across pages and has the poll take every mark between writes with an acquire exchange, checking the exact marks left after the last one. The A/B in play (merge base, off, on) is pending with the opener.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62550 (L1): fixed in 5114aeae by dropping the plain marks, as the maintainer's review also asked: every mark is main's release store with the switch either way. The test checks it in the IR (each guest store followed by two store atomic ... release marks, bitmap off and on) and at run time with a poll that takes the marks between writes to the same page, checking the marks left exactly.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62550](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62550) (L1): fixed in 5114aeae by dropping the plain marks, as the maintainer's review also asked: every mark is main's release store with the switch either way. The test checks it in the IR (each guest store followed by two `store atomic ... release` marks, bitmap off and on) and at run time with a poll that takes the marks between writes to the same page, checking the marks left exactly.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62551 (L2): fixed in 5114aeae. With the plain marks gone, nx2/rtgen.py is main's again and a64.h is the same with the switch unset and set (the test compares the two headers); the switch is only an LLVM option on the lifted chunks' command line, so the default build's object keys are main's.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62551](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62551) (L2): fixed in 5114aeae. With the plain marks gone, `nx2/rtgen.py` is main's again and `a64.h` is the same with the switch unset and set (the test compares the two headers); the switch is only an LLVM option on the lifted chunks' command line, so the default build's object keys are main's.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62552 (L3): removed in 5114aeae as asked. The static counts over the game's hottest lifted functions (and the derived figures of the tried variants) are gone from the doc, the commit message and the description; the page says the per-function counts were taken locally and are not published, and the claims it keeps rest on the authored loops in tests/test_loop_sink.py. The description's no-game-output entry stands for this head.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62552](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62552) (L3): removed in 5114aeae as asked. The static counts over the game's hottest lifted functions (and the derived figures of the tried variants) are gone from the doc, the commit message and the description; the page says the per-function counts were taken locally and are not published, and the claims it keeps rest on the authored loops in `tests/test_loop_sink.py`. The description's no-game-output entry stands for this head.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62553 (L4): fixed in 5114aeae. The doc, the build reference row and the description now say a change of the switch translates the game again where the translated C is gone (a player's build folder), and that an A/B builds with LONGSHOT_KEEP_BUILD_FILES=1 or in a development checkout, the game folder copied between the two builds.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62553](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62553) (L4): fixed in 5114aeae. The doc, the build reference row and the description now say a change of the switch translates the game again where the translated C is gone (a player's build folder), and that an A/B builds with `LONGSHOT_KEEP_BUILD_FILES=1` or in a development checkout, the game folder copied between the two builds.
Author
Contributor

(L5 in https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559): fixed in 5114aeae. The attribute is added by native_flags(gen, rt64, dll) for the native build only; the emulator-hosted DLL keeps -DA64_POLL_CTX and main's flags (the test checks it), and the mark flag no longer exists.

(L5 in [https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559)): fixed in 5114aeae. The attribute is added by `native_flags(gen, rt64, dll)` for the native build only; the emulator-hosted DLL keeps `-DA64_POLL_CTX` and main's flags (the test checks it), and the mark flag no longer exists.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62554 (L6): fixed in 5114aeae. The poll stand-in no longer touches the context; the copy loop raises the request itself through c every eighth iteration, so repeated requests go through the lifted code's own path, and the driver checks the exact polls taken per call.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62554](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62554) (L6): fixed in 5114aeae. The poll stand-in no longer touches the context; the copy loop raises the request itself through `c` every eighth iteration, so repeated requests go through the lifted code's own path, and the driver checks the exact polls taken per call.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62555 (L7): fixed in 5114aeae. The IR check now takes every store of the loop in order and requires each guest store to be followed by its two release marks before the next; at run time destinations are unaligned (stores cross pages) and the poll takes every mark with an acquire exchange between writes, and the marks left must be exactly the pages stored to after the last poll.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62555](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62555) (L7): fixed in 5114aeae. The IR check now takes every store of the loop in order and requires each guest store to be followed by its two release marks before the next; at run time destinations are unaligned (stores cross pages) and the poll takes every mark with an acquire exchange between writes, and the marks left must be exactly the pages stored to after the last poll.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62556 (L8): fixed in 5114aeae. RUN_ALL_ARGS is gone and the test resolves the compiler itself: --cc, then CC, clang on PATH, then LONGSHOT_MINGW's clang, with that compiler's own target; a --target in --cflags runs the IR checks only.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62556](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62556) (L8): fixed in 5114aeae. `RUN_ALL_ARGS` is gone and the test resolves the compiler itself: `--cc`, then `CC`, clang on PATH, then `LONGSHOT_MINGW`'s clang, with that compiler's own target; a `--target` in `--cflags` runs the IR checks only.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62557 (L9): fixed in 5114aeae. nx2/build.py is imported with RX_*, LONGSHOT_* and OOT_* cleared, RX_MARCH=x86-64 and no process allowed to start; the target comes from the compiler, and IR and programs are built with the bitmap off and on explicitly.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62557](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62557) (L9): fixed in 5114aeae. `nx2/build.py` is imported with `RX_*`, `LONGSHOT_*` and `OOT_*` cleared, `RX_MARCH=x86-64` and no process allowed to start; the target comes from the compiler, and IR and programs are built with the bitmap off and on explicitly.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62558 (L10): fixed in 5114aeae. The loop is found by its symbol (^define ...@f_80000000(, any linkage or visibility), and a missing function or loop is a reported failure, not an exception.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62558](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62558) (L10): fixed in 5114aeae. The loop is found by its symbol (`^define ...@f_80000000(`, any linkage or visibility), and a missing function or loop is a reported failure, not an exception.
Author
Contributor

(L11 in https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559): the edit part is fixed in 5114aeae: the build's log prints build: RX_LOOP_SINK=1: ... when the executable has it, and dev.py pack builds the game when it is on even with no file changed. The in-game A/B against the merge base (Windows, Linux, Deck, build time and size) is pending with the opener.

(L11 in [https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559)): the edit part is fixed in 5114aeae: the build's log prints `build: RX_LOOP_SINK=1: ...` when the executable has it, and `dev.py pack` builds the game when it is on even with no file changed. The in-game A/B against the merge base (Windows, Linux, Deck, build time and size) is pending with the opener.
Author
Contributor

(L12 in https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559): in a later round. The earlier --changed run is not repeated on this head; its counts and skips will be reconciled from the job's output when the full checks run again.

(L12 in [https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62559)): in a later round. The earlier `--changed` run is not repeated on this head; its counts and skips will be reconciled from the job's output when the full checks run again.
Author
Contributor

@Beanstalk This adds a compile switch, RX_LOOP_SINK, off by default (nx2/build.py, nx2/rtgen.py). The farm cannot build with it set, so only the default build is to test: with the switch unset, the lift and its C must be main's. Please time the lift against main's and check the lifted C is the same, on a Windows PC and on a Linux PC. No game scenario is needed: unset, the game's code is main's.

@Beanstalk This adds a compile switch, RX_LOOP_SINK, off by default (nx2/build.py, nx2/rtgen.py). The farm cannot build with it set, so only the default build is to test: with the switch unset, the lift and its C must be main's. Please time the lift against main's and check the lifted C is the same, on a Windows PC and on a Linux PC. No game scenario is needed: unset, the game's code is main's.
Member

@siantm only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 5114aea, and the PR has changed since (57ae9f3), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `5114aea`, and the PR has changed since (`57ae9f3`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62742, to be exact about 5114aeae: the marks stay main's release stores, in place after the guest store each one marks, and with RX_LOOP_SINK=1 the context stores of a loop that contains marked guest stores are sunk to the loop's exits too: in tests/test_loop_sink.py the copy loop's stores go from CCGMMCC an iteration (C a context store, G the guest store, M a release mark) to GMM, at O1 and O2 with the bitmap off and on. So inside such a loop the context in memory lags the loop's registers while the marks are published.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62742](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62742), to be exact about 5114aeae: the marks stay main's release stores, in place after the guest store each one marks, and with `RX_LOOP_SINK=1` the context stores of a loop that contains marked guest stores are sunk to the loop's exits too: in `tests/test_loop_sink.py` the copy loop's stores go from `CCGMMCC` an iteration (C a context store, G the guest store, M a release mark) to `GMM`, at O1 and O2 with the bitmap off and on. So inside such a loop the context in memory lags the loop's registers while the marks are published.
Author
Contributor

Risks now names what is not verified: with the switch on, a loop's context stores move to its exits also in loops with marked guest stores, and what a fault, an interrupt or a sampler reading the context mid-loop then sees has not been checked. No code change; the head stays 5114aeae.

Risks now names what is not verified: with the switch on, a loop's context stores move to its exits also in loops with marked guest stores, and what a fault, an interrupt or a sampler reading the context mid-loop then sees has not been checked. No code change; the head stays 5114aeae.
Author
Contributor

The queue run on 5114aeae itself (job fb2-1978-final, Windows 11, i7-9700, llvm-mingw clang 23.1.5, each check in a hidden console of its own) ended: python -I -B tests/test_loop_sink.py (no arguments, the compiler through LONGSHOT_MINGW) "all passed", with the same IR as before the rebase (copy loop CCGMMCC off, GMM on; load-only loop CCC off, no store on), and tests/test_vk_pgo.py, tests/test_light_passes.py exit 0 each.

The queue run on 5114aeae itself (job fb2-1978-final, Windows 11, i7-9700, llvm-mingw clang 23.1.5, each check in a hidden console of its own) ended: `python -I -B tests/test_loop_sink.py` (no arguments, the compiler through `LONGSHOT_MINGW`) "all passed", with the same IR as before the rebase (copy loop `CCGMMCC` off, `GMM` on; load-only loop `CCC` off, no store on), and `tests/test_vk_pgo.py`, `tests/test_light_passes.py` exit 0 each.
Author
Contributor

Tested corrected: an earlier run on this PC had no Vulkan headers for the renderer checks (RX_CPM unset), so the ones it listed as also failing on main had compiled nothing on either side. They ran again with the headers at 5114aeae and on main (queue job fb2-vk-1); the description now gives those results. No check fails at this head alone; nothing in the branch changed.

Tested corrected: an earlier run on this PC had no Vulkan headers for the renderer checks (`RX_CPM` unset), so the ones it listed as also failing on `main` had compiled nothing on either side. They ran again with the headers at 5114aeae and on `main` (queue job fb2-vk-1); the description now gives those results. No check fails at this head alone; nothing in the branch changed.
futondestroyer left a comment

Recommendation: Request changes. The earlier dirty-page and retained-object blockers are fixed. Keep the new compile switch out of the default shared base so an A/B actually compares the two build modes.

  • Shared base can inherit the experiment. dev.py base passes the caller’s environment to the build and keys the shared base by commit alone. If the first build of a commit containing this switch runs with RX_LOOP_SINK=1, a later run with the switch unset reuses the enabled executable as its baseline. The new pack route also lets an unchanged-tree off pack inherit that executable. Strip this switch from shared default-base builds or include the effective mode in the base identity. Exercise an enabled-first, unset-second sequence in a game-free test.
  • The IR fixture checks guest-store and release-mark order with the bitmap off. With the bitmap on, it only checks that both types of store exist. Verify that the guest store precedes the conditional publication, or narrow the stated IR guarantee to the bitmap-off case.

Does it help? Unproven. The author’s exact-head Windows fixture passed and showed guest-register stores moving to loop exits while keeping release marks. The poll-only setting showed no instruction-count gain on the earlier experimental branch and compiler. Compare the actual merge base with this head off and on using verified executables, interleaved gameplay, and clean build time and size. Include Linux and Steam Deck. The crash reporter reads saved guest registers, so check what it reports when a fault occurs inside a loop eligible for promotion. Required source CI is pending.

Test Farm. The requested switch-off lifted C and lift-timing check is supported. The dashboard currently pairs 5114aeae with 6e1521a7 while this head’s merge base is f1f2dc5b. Hold the pending request for the source fix and a corrected pair. The enabled compiler mode needs a separate build outside the current farm schema. Author’s request · Farm status

Reviewed 5114aeae against f1f2dc5b and compared with the previous review head using revision-matched local maps and source. The runtime header generator matches the base, the normal native and DLL flags match with the switch off, and the renderer’s release/acquire protocol is intact. The patches still conflict with the build and pack changes in PR 1979 and PR 1985. Previous review

**Recommendation: Request changes.** The earlier dirty-page and retained-object blockers are fixed. Keep the new compile switch out of the default shared base so an A/B actually compares the two build modes. - **Shared base can inherit the experiment.** `dev.py base` passes the caller’s environment to the build and keys the shared base by commit alone. If the first build of a commit containing this switch runs with `RX_LOOP_SINK=1`, a later run with the switch unset reuses the enabled executable as its baseline. The new pack route also lets an unchanged-tree off pack inherit that executable. Strip this switch from shared default-base builds or include the effective mode in the base identity. Exercise an enabled-first, unset-second sequence in a game-free test. - The IR fixture checks guest-store and release-mark order with the bitmap off. With the bitmap on, it only checks that both types of store exist. Verify that the guest store precedes the conditional publication, or narrow the stated IR guarantee to the bitmap-off case. **Does it help?** Unproven. The author’s exact-head Windows fixture passed and showed guest-register stores moving to loop exits while keeping release marks. The poll-only setting showed no instruction-count gain on the earlier experimental branch and compiler. Compare the actual merge base with this head off and on using verified executables, interleaved gameplay, and clean build time and size. Include Linux and Steam Deck. The crash reporter reads saved guest registers, so check what it reports when a fault occurs inside a loop eligible for promotion. Required source CI is pending. **Test Farm.** The requested switch-off lifted C and lift-timing check is supported. The dashboard currently pairs `5114aeae` with `6e1521a7` while this head’s merge base is `f1f2dc5b`. Hold the pending request for the source fix and a corrected pair. The enabled compiler mode needs a separate build outside the current farm schema. [Author’s request](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-63247) · [Farm status](https://beanstalk.magicbean.dev/prs/1978) **Reviewed** `5114aeae` against `f1f2dc5b` and compared with the previous review head using revision-matched local maps and source. The runtime header generator matches the base, the normal native and DLL flags match with the switch off, and the renderer’s release/acquire protocol is intact. The patches still conflict with the build and pack changes in [PR 1979](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1979) and [PR 1985](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1985). [Previous review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-62742)
@ -445,0 +448,4 @@
the renderer; RX_PGO (the game's hot pieces), LONGSHOT_TRACY (its client is in the game's executable) and a
GAME_COMPILE_SWITCHES experiment turned on the game"""
if environ.get("RX_PGO") or environ.get("LONGSHOT_TRACY", "0") not in ("", "0") or \
any(environ.get(k, "").strip().lower() not in ("", "0", "false", "off", "no") for k in GAME_COMPILE_SWITCHES):
Member

The enabled pack case still needs an off baseline. If RX_LOOP_SINK=1 is set on the first dev.py base for a commit that contains this switch, cmd_base forwards it and caches the enabled executable by commit alone. A later unset run treats that executable as the baseline, and an unchanged-tree off pack builds nothing. Keep the switch out of shared default-base builds or key the base by the effective compile mode.

The enabled pack case still needs an off baseline. If RX_LOOP_SINK=1 is set on the first dev.py base for a commit that contains this switch, cmd_base forwards it and caches the enabled executable by commit alone. A later unset run treats that executable as the baseline, and an unchanged-tree off pack builds nothing. Keep the switch out of shared default-base builds or key the base by the effective compile mode.
@ -0,0 +222,4 @@
scan = stores(loop_blocks(ir, "f_80000100", what))
print("%s: the loops' stores in order: copy %s, load-only %s (G guest, M release mark, C context)" % (what, copy, scan))
if bitmap: # (a mark only where the bitmap says: in a block of its own)
check("G" in copy and "M" in copy and "m" not in copy, "%s: the copy loop's marks are release stores (%s)" % (what, copy))
Member

The bitmap-on assertion accepts any ordering of G and M, so it would pass an IR regression that publishes the mark before the guest store. Check that the guest store executes before the conditional mark block, or scope the documented order assertion to the bitmap-off case.

The bitmap-on assertion accepts any ordering of G and M, so it would pass an IR regression that publishes the mark before the guest store. Check that the guest store executes before the conditional mark block, or scope the documented order assertion to the bitmap-off case.
siantm force-pushed perf/lift-loop-sink from 5114aeaed4
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 24s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to 57ae9f39ca
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-21 10:31:45 +00:00
Compare
Author
Contributor

Pushed 57ae9f39 (on main @ 9dd41326; the PR's commit rebased unchanged): futondestroyer's second look. dev.py base now builds the commit-keyed shared base without RX_LOOP_SINK, so the base is the default executable whichever order the builds come in; the test commit db1993b4 fails on it and the fix 57ae9f39 passes (job fb2-lift-r2). Testing has the round's results.

Pushed 57ae9f39 (on `main` @ 9dd41326; the PR's commit rebased unchanged): futondestroyer's second look. `dev.py base` now builds the commit-keyed shared base without `RX_LOOP_SINK`, so the base is the default executable whichever order the builds come in; the test commit db1993b4 fails on it and the fix 57ae9f39 passes (job fb2-lift-r2). Testing has the round's results.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65503: fixed in 57ae9f39 (the test first, failing, in db1993b4). dev.py base (cmd_base) now leaves the game's compile-only experiments (packs.GAME_COMPILE_SWITCHES, here RX_LOOP_SINK) out of the shared base's build and says so, so the commit-keyed base is main's mode whichever order the builds come in; a pack with the switch on still routes to its own game build. tests/test_loop_sink.py runs cmd_base at one revision enabled-first then unset, and unset-first then enabled: one build each time, without the switch, and an unchanged-tree pack uses that base unset and builds its own game set. At the test commit the test fails ("dev.py base, RX_LOOP_SINK=1 then unset: its build leaves RX_LOOP_SINK out"); at 57ae9f39 it passes (job fb2-lift-r2).

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65503](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65503): fixed in 57ae9f39 (the test first, failing, in db1993b4). `dev.py base` (`cmd_base`) now leaves the game's compile-only experiments (`packs.GAME_COMPILE_SWITCHES`, here `RX_LOOP_SINK`) out of the shared base's build and says so, so the commit-keyed base is main's mode whichever order the builds come in; a pack with the switch on still routes to its own game build. `tests/test_loop_sink.py` runs `cmd_base` at one revision enabled-first then unset, and unset-first then enabled: one build each time, without the switch, and an unchanged-tree pack uses that base unset and builds its own game set. At the test commit the test fails ("dev.py base, RX_LOOP_SINK=1 then unset: its build leaves RX_LOOP_SINK out"); at 57ae9f39 it passes (job fb2-lift-r2).
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65504: fixed in db1993b4. With the bitmap on the IR check now requires the same order as with it off (each guest store, then its two release marks, in block order), and a new check that every block holding a mark runs after the guest store: the store is earlier in the same block, or in a block that dominates the mark's block from the loop's header. A hand-written self-check shows the test passes a conditional mark block after the store and fails one reached before it. It passed at 57ae9f39 (job fb2-lift-r2).

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65504](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65504): fixed in db1993b4. With the bitmap on the IR check now requires the same order as with it off (each guest store, then its two release marks, in block order), and a new check that every block holding a mark runs after the guest store: the store is earlier in the same block, or in a block that dominates the mark's block from the loop's header. A hand-written self-check shows the test passes a conditional mark block after the store and fails one reached before it. It passed at 57ae9f39 (job fb2-lift-r2).
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65505: addressed in db1993b4 (test) and 57ae9f39 (fix), rebased unchanged onto main @ 9dd41326 (range-diff "=" for the PR's commit). The shared base no longer inherits the experiment (inline 65503), and the bitmap-on IR order is checked by dominance (inline 65504). What the crash reporter shows for a fault inside a promoted loop is not checked yet: Risks names it as not verified, and it goes with the in-game A/B (merge base, off, on), which is pending with the opener; the farm request is for the base pair to be corrected to this head's merge base.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65505](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65505): addressed in db1993b4 (test) and 57ae9f39 (fix), rebased unchanged onto `main` @ 9dd41326 (range-diff "=" for the PR's commit). The shared base no longer inherits the experiment (inline [65503](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65503)), and the bitmap-on IR order is checked by dominance (inline [65504](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65504)). What the crash reporter shows for a fault inside a promoted loop is not checked yet: Risks names it as not verified, and it goes with the in-game A/B (merge base, off, on), which is pending with the opener; the farm request is for the base pair to be corrected to this head's merge base.
Author
Contributor

@Beanstalk This adds a compile switch, RX_LOOP_SINK, off by default (nx2/build.py, nx2/rtgen.py). The farm cannot build with it set, so only the default build is to test: with the switch unset, the lift and its C must be main's. This head is on main 9dd41326: please compare with main at that merge base. Please time the lift against main's and check the lifted C is the same, on a Windows PC and on a Linux PC. No game scenario is needed: unset, the game's code is main's.

@Beanstalk This adds a compile switch, RX_LOOP_SINK, off by default (nx2/build.py, nx2/rtgen.py). The farm cannot build with it set, so only the default build is to test: with the switch unset, the lift and its C must be main's. This head is on main 9dd41326: please compare with main at that merge base. Please time the lift against main's and check the lifted C is the same, on a Windows PC and on a Linux PC. No game scenario is needed: unset, the game's code is main's.
Member

@siantm only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 57ae9f3, and the PR has changed since (947af7d), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `57ae9f3`, and the PR has changed since (`947af7d`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
futondestroyer left a comment

Recommendation: Request changes. The queued dev.py base now clears RX_LOOP_SINK, but the documented dev.py packs base command still inherits it. A named base built with the switch enabled stays enabled when dev.py packs rt later assembles the baseline with the switch unset. Apply the default-mode rule when the named base launches the compiler and add a regression test through that entry point. The enabled pack should continue to build its own executable. Documented A/B commands

The queued-base regression test failed at the test-only commit and passed on the current Windows build, along with two related checks, according to the author. The bitmap-on fixture now checks control flow from the guest store to its release marks. Author’s update · Previous review

Does it help? Unproven. The focused fixture confirms the intended compiler change in a synthetic loop. The earlier probe measured no instruction-count gain from the retained poll-only change. Compare 9dd41326 with verified switch-off and switch-on builds of this head in warmed, interleaved gameplay. Record frame times, clean build time and size, and what the crash reporter shows for a fault inside a promoted loop. Linux and Steam Deck coverage, the full checks, and required CI are still open.

Test Farm. The current request asks for default lifted-C parity and lift timing on Windows and Linux. The dashboard shows head 57ae9f39 paired with f1f2dc5b, while the actual merge base and requested baseline is 9dd41326. Hold the request until the dashboard shows the correct pair. The enabled compiler mode still needs separately built executables. Author’s request · Farm status

Reviewed 57ae9f39 against 9dd41326 and compared the changes since 5114aeae. The default flags and generated runtime header still match the base. The atomic page-mark protocol and DLL callback are intact. The PR remains WIP.

**Recommendation: Request changes.** The queued `dev.py base` now clears `RX_LOOP_SINK`, but the documented `dev.py packs base` command still inherits it. A named base built with the switch enabled stays enabled when `dev.py packs rt` later assembles the baseline with the switch unset. Apply the default-mode rule when the named base launches the compiler and add a regression test through that entry point. The enabled pack should continue to build its own executable. [Documented A/B commands](https://git.magicbean.dev/MagicBeanDev/Longshot/src/commit/9dd41326e71094d8b774459dac5154eb5a3306d9/docs/dev/developing.md#test-a-change-against-a-base) The queued-base regression test failed at the test-only commit and passed on the current Windows build, along with two related checks, according to the author. The bitmap-on fixture now checks control flow from the guest store to its release marks. [Author’s update](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65892) · [Previous review](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65505) **Does it help?** Unproven. The focused fixture confirms the intended compiler change in a synthetic loop. The earlier probe measured no instruction-count gain from the retained poll-only change. Compare `9dd41326` with verified switch-off and switch-on builds of this head in warmed, interleaved gameplay. Record frame times, clean build time and size, and what the crash reporter shows for a fault inside a promoted loop. Linux and Steam Deck coverage, the full checks, and required CI are still open. **Test Farm.** The current request asks for default lifted-C parity and lift timing on Windows and Linux. The dashboard shows head `57ae9f39` paired with `f1f2dc5b`, while the actual merge base and requested baseline is `9dd41326`. Hold the request until the dashboard shows the correct pair. The enabled compiler mode still needs separately built executables. [Author’s request](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-65907) · [Farm status](https://beanstalk.magicbean.dev/prs/1978) Reviewed `57ae9f39` against `9dd41326` and compared the changes since `5114aeae`. The default flags and generated runtime header still match the base. The atomic page-mark protocol and DLL callback are intact. The PR remains WIP.
@ -392,1 +394,4 @@
py, env = environment()
# (a shared base is keyed by its commit alone, and is the off side of every A/B on it: built as main builds it, without
# the game's compile-only experiments; a pack with one on builds its own game, packs.py pack_route)
left = [k for k in packs.GAME_COMPILE_SWITCHES if env.pop(k, None) is not None]
Member

This clears the switch for the queued wrapper. The documented direct dev.py packs base dispatches to packs.py:600, where the build at line 620 still inherits RX_LOOP_SINK from run(). A named baseline built with RX_LOOP_SINK=1 is then copied by no-pack dev.py packs rt even after the switch is unset. Apply the default-mode rule at the named-base build boundary after the environment merge, and cover enabled-first through that entry point. Keep the pack build's explicit opt-in.

This clears the switch for the queued wrapper. The documented direct dev.py packs base dispatches to packs.py:600, where the build at line 620 still inherits RX_LOOP_SINK from run(). A named baseline built with RX_LOOP_SINK=1 is then copied by no-pack dev.py packs rt even after the switch is unset. Apply the default-mode rule at the named-base build boundary after the environment merge, and cover enabled-first through that entry point. Keep the pack build's explicit opt-in.
Review of #1978 (futondestroyer): round 2 left the switch out only in the dev.py base wrapper. The documented dev.py packs
base runs packs.cmd_base directly, and its make_game.py build still took RX_LOOP_SINK from the caller's environment, so a
named base built with it on was what a later dev.py packs rt with it unset copied. The base check now drives both entry
points through dev.py's own command line, each with the switch on first and unset second and the other way round, then
dev.py packs rt with no pack and dev.py packs pack and rt with the switch on. A stand-in for make_game.py records the
environment the build gets after packs.run's merge and writes executables saying the mode they were built in. Fails
here: the direct command's base build gets the switch when it comes first.

Assisted-by: Claude Code
fix(devtools): dev.py packs base builds the named base without RX_LOOP_SINK
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 8s
947af7d2ca
Review of #1978 (futondestroyer): round 2 left the switch out only in the dev.py base wrapper (build.py cmd_base). The
documented dev.py packs base runs packs.cmd_base directly, whose make_game.py build took RX_LOOP_SINK from the caller's
environment through packs.run, so a named base built with it on was the executable a later dev.py packs rt with it
unset copied, and an unchanged off-mode pack supplies none of its own. The rule now sits where both commands converge:
packs.cmd_base builds with the game's compile-only experiments (GAME_COMPILE_SWITCHES) taken out of the environment
after packs.run merges the caller's, and says so; the wrapper's own strip is gone. A pack with one on still builds its
own game in that mode (pack_route; its make_game.py call keeps the caller's environment).

Assisted-by: Claude Code
Author
Contributor

Pushed 947af7d2 (on main @ 9dd41326; the earlier commits unchanged): futondestroyer's third look. dev.py packs base now builds a named base without RX_LOOP_SINK too: the rule sits in packs.cmd_base, where it and dev.py base converge, and the wrapper's own strip is gone. The test commit 0100d3c5 fails without it and the fix 947af7d2 passes (job fb2-lift-r3b). Testing has the round's results; Measurements says the switch stays off by default at the maintainer's request.

Pushed 947af7d2 (on `main` @ 9dd41326; the earlier commits unchanged): futondestroyer's third look. `dev.py packs base` now builds a named base without `RX_LOOP_SINK` too: the rule sits in `packs.cmd_base`, where it and `dev.py base` converge, and the wrapper's own strip is gone. The test commit 0100d3c5 fails without it and the fix 947af7d2 passes (job fb2-lift-r3b). Testing has the round's results; Measurements says the switch stays off by default at the maintainer's request.
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67210: fixed in 947af7d2 (the test first, failing, in 0100d3c5). packs.cmd_base, which dev.py packs base runs directly and dev.py base through the queue, now builds the base with RX_LOOP_SINK taken out of the environment after packs.run merges the caller's, and the wrapper's strip in scripts/devtools/build.py is gone; a pack with the switch on still builds its own game in that mode. tests/test_loop_sink.py now drives both entry points through dev.py's command line, enabled first then unset and the reverse, checking the base build's environment and that dev.py packs rt with no pack runs an off game while the enabled pack's runtime runs an on one: 2 failures at 0100d3c5, all passed at 947af7d2 (job fb2-lift-r3b).

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67210](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67210): fixed in 947af7d2 (the test first, failing, in 0100d3c5). `packs.cmd_base`, which `dev.py packs base` runs directly and `dev.py base` through the queue, now builds the base with `RX_LOOP_SINK` taken out of the environment after `packs.run` merges the caller's, and the wrapper's strip in `scripts/devtools/build.py` is gone; a pack with the switch on still builds its own game in that mode. `tests/test_loop_sink.py` now drives both entry points through `dev.py`'s command line, enabled first then unset and the reverse, checking the base build's environment and that `dev.py packs rt` with no pack runs an off game while the enabled pack's runtime runs an on one: 2 failures at 0100d3c5, all passed at 947af7d2 (job fb2-lift-r3b).
Author
Contributor

https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67211: addressed in 0100d3c5 (test) and 947af7d2 (fix), on main @ 9dd41326 with the earlier commits unchanged. Round 2 covered only the dev.py base wrapper; this round covers the direct dev.py packs base command, with the default applied in packs.cmd_base where both converge (inline 67210). Testing in the description has the round's results (67293); the gameplay comparison and the Test Farm pairing are still open.

[https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67211](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67211): addressed in 0100d3c5 (test) and 947af7d2 (fix), on `main` @ 9dd41326 with the earlier commits unchanged. Round 2 covered only the `dev.py base` wrapper; this round covers the direct `dev.py packs base` command, with the default applied in `packs.cmd_base` where both converge (inline [67210](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67210)). Testing in the description has the round's results ([67293](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67293)); the gameplay comparison and the Test Farm pairing are still open.
Author
Contributor

@Beanstalk This adds a compile switch, RX_LOOP_SINK, off by default (nx2/build.py, nx2/rtgen.py). The farm cannot build with it set, so only the default build is to test: with the switch unset, the lift and its C must be main's. Please time the lift against main's and check the lifted C is the same, on a Windows PC and on a Linux PC. No game scenario is needed: unset, the game's code is main's.

@Beanstalk This adds a compile switch, RX_LOOP_SINK, off by default (nx2/build.py, nx2/rtgen.py). The farm cannot build with it set, so only the default build is to test: with the switch unset, the lift and its C must be main's. Please time the lift against main's and check the lifted C is the same, on a Windows PC and on a Linux PC. No game scenario is needed: unset, the game's code is main's.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

Re #1978 (comment) ("Does it help?"): the warmed, interleaved off/on comparison in play has run at 947af7d2, and Measurements now has it run by run. off is the switch unset, whose lifted code, object keys and executable are main 9dd41326's; on is set at build. Kokiri Forest, 800x600, 4 runs a side after a warm-up: off 67.6 to 76.4 fps, on 70.3 to 82.3. Reading: not decided, no loss seen. Every run sits in one of two scene states (a refused or a taken teleport at the run's start, about 1,380 against 1,100 textures a frame) and both sides land in both; within a state the on side leads in each pairing, at two runs a cell. The run wrapper is fixed, and a rerun of 8 a side, classed by state, follows. Clean build time and size, the crash reporter in a promoted loop, Linux and Steam Deck are not measured yet. The switch stays off.

Re https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67211 ("Does it help?"): the warmed, interleaved off/on comparison in play has run at 947af7d2, and Measurements now has it run by run. off is the switch unset, whose lifted code, object keys and executable are main 9dd41326's; on is set at build. Kokiri Forest, 800x600, 4 runs a side after a warm-up: off 67.6 to 76.4 fps, on 70.3 to 82.3. Reading: not decided, no loss seen. Every run sits in one of two scene states (a refused or a taken teleport at the run's start, about 1,380 against 1,100 textures a frame) and both sides land in both; within a state the on side leads in each pairing, at two runs a cell. The run wrapper is fixed, and a rerun of 8 a side, classed by state, follows. Clean build time and size, the crash reporter in a promoted loop, Linux and Steam Deck are not measured yet. The switch stays off.
Author
Contributor

Re #1978 (comment) ("Does it help?"): the warmed, interleaved in-game comparison has run at 947af7d2, 8 runs a side in Kokiri Forest (800x600, CPU-paced), every run checked in the same scene state, GPU cooled before each, on this PC alone; off is the switch unset (main's flags and header). Calm game time a frame, median (range): off 10.26 ms (9.97 to 10.45), on 10.10 (9.97 to 10.33), 1.6 % lower with the switch on but inside the spread; fps 87.4 against 88.3, and no loss in the tail. Eight a side resolve roughly 1.5 to 2 % on the median (an estimate), so play shows no gain for it. The switch stays off; whether it stays as an off-by-default experiment or is dropped is your call and the author's. Measurements has every run; clean build time and size, Linux and the Steam Deck are not measured.

Re https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1978#issuecomment-67211 ("Does it help?"): the warmed, interleaved in-game comparison has run at 947af7d2, 8 runs a side in Kokiri Forest (800x600, CPU-paced), every run checked in the same scene state, GPU cooled before each, on this PC alone; off is the switch unset (main's flags and header). Calm game time a frame, median (range): off 10.26 ms (9.97 to 10.45), on 10.10 (9.97 to 10.33), 1.6 % lower with the switch on but inside the spread; fps 87.4 against 88.3, and no loss in the tail. Eight a side resolve roughly 1.5 to 2 % on the median (an estimate), so play shows no gain for it. The switch stays off; whether it stays as an off-by-default experiment or is dropped is your call and the author's. Measurements has every run; clean build time and size, Linux and the Steam Deck are not measured.
Author
Contributor

Testing brought in line with Measurements: the Kokiri Forest off/on comparison of 2026-11-22 (8 a side at 947af7d2, no gain shown) is now under Tested; Still to test lists what is still open: clean build time and size, Linux, the Steam Deck and the Test Farm run.

Testing brought in line with Measurements: the Kokiri Forest off/on comparison of 2026-11-22 (8 a side at 947af7d2, no gain shown) is now under Tested; Still to test lists what is still open: clean build time and size, Linux, the Steam Deck and the Test Farm run.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Description follows the template (pull_request_target) Successful in 8s
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/lift-loop-sink:siantm-perf/lift-loop-sink'
git switch 'siantm-perf/lift-loop-sink'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1978
No description provided.