perf(builder): the hot units' never-run blocks leave the hot code by default (LONGSHOT_HOT_SPLIT=0 turns it off) #2700

Merged
HumanBean merged 11 commits from klimovich008/Longshot:perf/hot-split into main 2026-11-28 01:18:12 +00:00
Member

Summary

The guest profile's text has no taken count for a branch that never jumped, so today such a branch has no weights at all and LLVM guesses where the side that never ran goes, often in the middle of the code that runs. In Market about 12,000 code pages of the exe run in every 50-100 ms, and only a little over a third of the hot units' guest instructions are in blocks that ran.

This is on by default now (HumanBean's question on this PR, answered yes by the maintainers). LONGSHOT_HOT_SPLIT=0 turns it off and gives the build without it exactly: main's IR and compile flags (386 of 386 unit texts identical to main's in a whole lift, from the earlier round). With it on, the lift weights every branch of the hot units that ran but never jumped (0, n). The compile then builds the hot units with LLVM's hot-cold splitting, but only for blocks behind such a branch (a probability of at most 2^-31). Block placement moves those never-run blocks to the end of each hot function, and LLVM moves a region out into a cold function of its own where it can (400 regions in the game, 55 KB). The code that runs every frame is denser. With LONGSHOT_HOT_SPLIT=1 the result was Market child +3.6 to +6.2 % fps and −4.4 to −6.6 % CPU ms over three rounds, every pair in favour.

The switch:

  • Unset, 1 or any other word: on. 0, off, no, false or empty: off. The lift and the compile read it through one function (build_compile::hotsplit::on), so the two halves can't disagree.
  • LONGSHOT_HOT_SPLIT_SKIP=<entries> still leaves functions out.
  • A standalone longshot-builder compile checks the lift's lift.key against the switch under the new default: a lift made with the default compiles with the default; a lift made at 0 is refused by a compile with the default, and the other way round.
  • longshot-builder dev lift now reads the two switches as the build does; --hot-split, --no-hot-split and --hot-split-skip override them.

What the writer guards:

  • A side that was taken, or that goes to a block that ran through another edge (a join), is never weighted 0. It gets at least 1, with the other side capped so that LLVM's rounding can't take it for cold.
  • A split function's later piece's first branch gets no weights, because passes::split makes that block at the function's entry address.
  • A function that calls the host's setjmp is written noinline, so it is never split.
  • The functions the edits change (hook sites, patches, entry hooks) and those of LONGSHOT_HOT_SPLIT_SKIP get no new zero weights.

Read first:

  • builder/crates/build-compile/src/hotsplit.rs: the switch (on) and the flags.
  • builder/crates/llvm/src/lib.rs: Module::split_cold, weights(), piece_start.
  • builder/crates/lift/src/whole/mod.rs: the keys and the lift.key line.
  • builder/crates/build-driver/src/stages.rs: hot_split and check_hot_split.

Testing

Tested: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2 (LLPC). I built packs over main 9eabf8bc3 with LONGSHOT_HOT_SPLIT=1 and ran std_test A/Bs in Market child (and Lost Woods child once), plus single starts in Lost Woods, Fire Temple and Kokiri Forest. Every run reached its scene. No new error lines appeared in any game log (18 logs in round 1, every run since). No crash records.

The default flip was not run again in the game or measured. Every number and game run here is from =1. The default now takes the same code path as =1: both go through the same reading of the switch, and the new tests below check that unset gives what 1 gives.

Checks on the latest head (the default flip, merged with main 20bedc6da):

  • The tests that state the default, run once: build-compile hotsplit 2/2 (new: unset_is_on_and_an_off_word_is_off), lift the_hot_split_is_in_the_key_only_when_on 1/1, and the longshot-builder integration test hot_split 6/6. The new test there, unset_is_on_and_0_is_off_in_the_lift_the_compile_and_the_compile_s_check, covers the lift's half, the compile's half and the standalone compile's check of a lift made unset, at 0, or with no lift.key.
  • cargo fmt --all --check, cargo clippy -D warnings on the changed crates and mise run lint are clean.

Checks from the rounds before, with =1:

  • Switch off: a whole lift of the game gives 386 of 386 unit texts identical to main's own lift.
  • Switch on: only the 122 hot units' keys and texts change.
  • tests/run_all.py (Windows): 793 passed, 17 failed, 51 skipped; all 17 fail on main 455b143b on this PC too.
  • Crate tests: llvm 17/17, lift 47/47. build-compile and build-driver have 10 Windows path and toolchain failures, the same ones main has on this PC.
  • The integration test (Windows and Linux targets) shows:
    • a never-run region moves out;
    • a join is weighted 1 and nothing moves;
    • nothing moves without the switch, without the flags, or with the function left out;
    • the lifted function, built and run from both sides of its branch, gives the same registers and guest memory on and off, and its outlined region runs;
    • a standalone compile refuses a lift made with the switch the other way, or a bad skip list.
  • tests/test_lifter_semantics.py: the new --hot-flags (compile as a hot unit) and --hot-split (the writer) are ok against Unicorn at x86-64-v2 and v3, with 3,561 outlined cold functions each.
  • Two independent code reviews and their fixes are in the commits.

Still to test:

  • Linux and the Steam Deck: a pack in Market child, LONGSHOT_HOT_SPLIT=0 against the default, expecting fewer CPU ms with the default (by hand, or the Test Farm).
  • Other CPUs, especially ones with a smaller L3 than 96 MB: the same A/B, expecting the gain to hold or grow (by hand, or the Test Farm).
  • Scenes beyond Market, Lost Woods, Fire Temple and Kokiri Forest: one start each with the default, expecting no new error lines (by hand).

Measurements

All measured with LONGSHOT_HOT_SPLIT=1, before the default flip.

Verdict: Market child +3.6 to +6.2 % fps and −4.4 to −6.6 % CPU ms in three 3-pair A/Bs, all 9 pairs in favour. Lost Woods child +2.5 % fps, CPU flat. Market's 3-pair noise is about 3 % fps and 5 % CPU ms, so each A/B alone is close to it; the three agree.

Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2. Uncapped (HOS_FPS_MAX=240), 16:9, render thread on, the fixed test profile. std_test's 20 s window after the teleport, 3 alternating pairs per A/B, with the background GPU load. Medians. Every contained game-clock reading was 0.989-1.011.

Market child:

Market child, median Before: main @ 9eabf8bc3 After: this PR @ c17ccc776
A/B 1 (this PR's first version, d4d0f25f6): fps, CPU ms, p99 101.94, 43.31, 17.89 108.29, 41.39, 17.31 (+6.2 % fps, −4.4 % CPU)
A/B 2: fps, CPU ms, p99 106.44, 43.04, 17.27 111.54, 40.21, 16.86 (+4.8 % fps, −6.6 % CPU)
A/B 3: fps, CPU ms, p99 105.29, 43.46, 17.72 109.09, 41.03, 18.15 (+3.6 % fps, −5.6 % CPU)
  • Per pair, fps: +7.0 / +3.1 / +3.9 %, then +3.9 / +5.8 / +4.4 %, then +4.9 / +3.6 / +4.0 %.
  • No frame over 50 ms in either arm of the last two A/Bs.

Lost Woods child (round 1): 121.44 → 124.44 fps (+2.5 %), 39.83 → 39.73 CPU ms (flat), p99 11.02 → 11.72.

The A/Bs ran on main 9eabf8bc3. The PR is now on main 20bedc6da. The commits since then change none of the lifter, the IR writer or the compile of the lifted units. One of them (#2665, mutex lookups through the guest word) changes the host's CPU work in both arms alike. The A/B was not run again. LONGSHOT_NO_CLANG in the diff is the builder tests' existing escape (no clang on the runner: the clang checks pass over), used by the new integration test as by the others, not a switch the build reads.

Costs:

  • The exe grows 288,256 bytes (+0.036 %), with 400 outlined regions (55,117 bytes). The hot functions' code goes from 41.14 to 41.34 MB.
  • Compile time of the 122 hot units is 0 to +2 % (CPU seconds, 15 jobs).
  • Turning the switch on or off lifts and compiles only the 122 hot units again.

Risks

  • On by default, for every player. On the update that ships this, every player's lift runs once more: the lifter's sources changed, so every lift key moves. The units other than the hot ones come out with the same texts, and the compile finds them in its content-keyed cache. The 122 hot units have new texts and new flags, so they compile again, once. The lift itself takes about 30 s for the whole game here (15 threads).
  • Kill switch: LONGSHOT_HOT_SPLIT=0 gives the build without the splitting: main's IR and compile flags, and the keys this lifter gives without it. Setting it or clearing it lifts and compiles the hot units alone again.
  • A block the profile never saw run that a player does run often (another save, another route) becomes a call each time it runs. That is slower there but exact: hot-cold splitting only moves code.
  • Known follow-up (latent, not seen):
    • Shape: a never-taken edge into a never-run block that only jumps on to a join that ran is still weighted (0, n). LLVM folds the jump block, so in synthetic IR that zero edge could reach the join and mark it cold.
    • Not reproduced: through this writer, compiled for Windows and Linux at the hot units' flags, nothing was outlined.
    • In the game IR: 1,217 of 27,562 zero-weighted sides go to a jump-only block, 650 of them with a target that has more than one way in.
    • In play: two sampled Market starts of the pack, 0 of about 24,700 lifted-code samples landed in the outlined code.
    • Fix: follow jump-only blocks in ran.
  • Profiling tools: outlined leaf functions have no .pdata (Win64 allows it), so the host sampler's stack walk stops at one; the crash recorder's leaf rule handles them. scripts/profiling/cpu.py doesn't map f_X.cold.N names to their guest function.
  • Developer-only paths:
    • A profile recorded with other piece cuts (--split-over) keys a piece start's counts at the entry.
    • A standalone compile at LONGSHOT_HOT_SPLIT=0 accepts a gen/ with no lift.key and kept IR, as main's does.

Turn it off: LONGSHOT_HOT_SPLIT=0, or revert.

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. The game runs were with =1; the default flip runs the same code and was checked by the tests above.
  • mise run test passes (any failure that also fails on main is named). tests/run_all.py on Windows, before the flip: 793 passed, 17 failed, 51 skipped; the same 17 fail on main 455b143b on this PC: test_auto_handheld.py, test_builder_channel.py, test_control_picture.py, test_coverage_run.py, test_crash_record.py, test_dev_ab.py, test_dev_build.py, test_dev_migrate.py, test_fs_path_utf8.py, test_job_queue.py, test_longshot_ctl.py, test_oot_menu_mouse.py, test_oot_state_tap.py, test_parity_gates.py, test_run_all_mingw.py, test_screensaver.py, test_switch_table.py.
  • 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 switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def. It's a build switch, on by default: its row, LONGSHOT_HOT_SPLIT=0, is in docs/dev/reference/build.md's table, not switches.def.
  • 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.

🤖 Generated with Claude Code

## Summary The guest profile's text has no taken count for a branch that never jumped, so today such a branch has no weights at all and LLVM guesses where the side that never ran goes, often in the middle of the code that runs. In Market about 12,000 code pages of the exe run in every 50-100 ms, and only a little over a third of the hot units' guest instructions are in blocks that ran. This is **on by default** now (HumanBean's question on this PR, answered yes by the maintainers). `LONGSHOT_HOT_SPLIT=0` turns it off and gives the build without it exactly: main's IR and compile flags (386 of 386 unit texts identical to main's in a whole lift, from the earlier round). With it on, the lift weights every branch of the hot units that ran but never jumped `(0, n)`. The compile then builds the hot units with LLVM's hot-cold splitting, but only for blocks behind such a branch (a probability of at most 2^-31). Block placement moves those never-run blocks to the end of each hot function, and LLVM moves a region out into a `cold` function of its own where it can (400 regions in the game, 55 KB). The code that runs every frame is denser. With `LONGSHOT_HOT_SPLIT=1` the result was Market child +3.6 to +6.2 % fps and −4.4 to −6.6 % CPU ms over three rounds, every pair in favour. The switch: - Unset, `1` or any other word: on. `0`, `off`, `no`, `false` or empty: off. The lift and the compile read it through one function (`build_compile::hotsplit::on`), so the two halves can't disagree. - `LONGSHOT_HOT_SPLIT_SKIP=<entries>` still leaves functions out. - A standalone `longshot-builder compile` checks the lift's `lift.key` against the switch under the new default: a lift made with the default compiles with the default; a lift made at `0` is refused by a compile with the default, and the other way round. - `longshot-builder dev lift` now reads the two switches as the build does; `--hot-split`, `--no-hot-split` and `--hot-split-skip` override them. What the writer guards: - A side that was taken, or that goes to a block that ran through another edge (a join), is never weighted 0. It gets at least 1, with the other side capped so that LLVM's rounding can't take it for cold. - A split function's later piece's first branch gets no weights, because `passes::split` makes that block at the function's entry address. - A function that calls the host's setjmp is written `noinline`, so it is never split. - The functions the edits change (hook sites, patches, entry hooks) and those of `LONGSHOT_HOT_SPLIT_SKIP` get no new zero weights. Read first: - `builder/crates/build-compile/src/hotsplit.rs`: the switch (`on`) and the flags. - `builder/crates/llvm/src/lib.rs`: `Module::split_cold`, `weights()`, `piece_start`. - `builder/crates/lift/src/whole/mod.rs`: the keys and the `lift.key` line. - `builder/crates/build-driver/src/stages.rs`: `hot_split` and `check_hot_split`. ## Testing **Tested:** Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2 (LLPC). I built packs over main 9eabf8bc3 with `LONGSHOT_HOT_SPLIT=1` and ran std_test A/Bs in Market child (and Lost Woods child once), plus single starts in Lost Woods, Fire Temple and Kokiri Forest. Every run reached its scene. No new error lines appeared in any game log (18 logs in round 1, every run since). No crash records. **The default flip was not run again in the game or measured.** Every number and game run here is from `=1`. The default now takes the same code path as `=1`: both go through the same reading of the switch, and the new tests below check that unset gives what `1` gives. Checks on the latest head (the default flip, merged with main 20bedc6da): - The tests that state the default, run once: `build-compile` `hotsplit` 2/2 (new: `unset_is_on_and_an_off_word_is_off`), `lift` `the_hot_split_is_in_the_key_only_when_on` 1/1, and the `longshot-builder` integration test `hot_split` 6/6. The new test there, `unset_is_on_and_0_is_off_in_the_lift_the_compile_and_the_compile_s_check`, covers the lift's half, the compile's half and the standalone compile's check of a lift made unset, at `0`, or with no `lift.key`. - `cargo fmt --all --check`, `cargo clippy -D warnings` on the changed crates and `mise run lint` are clean. Checks from the rounds before, with `=1`: - **Switch off:** a whole lift of the game gives 386 of 386 unit texts identical to main's own lift. - **Switch on:** only the 122 hot units' keys and texts change. - **`tests/run_all.py`** (Windows): 793 passed, 17 failed, 51 skipped; all 17 fail on main 455b143b on this PC too. - **Crate tests:** `llvm` 17/17, `lift` 47/47. `build-compile` and `build-driver` have 10 Windows path and toolchain failures, the same ones main has on this PC. - **The integration test** (Windows and Linux targets) shows: - a never-run region moves out; - a join is weighted 1 and nothing moves; - nothing moves without the switch, without the flags, or with the function left out; - the lifted function, built and run from both sides of its branch, gives the same registers and guest memory on and off, and its outlined region runs; - a standalone `compile` refuses a lift made with the switch the other way, or a bad skip list. - **`tests/test_lifter_semantics.py`:** the new `--hot-flags` (compile as a hot unit) and `--hot-split` (the writer) are ok against Unicorn at x86-64-v2 and v3, with 3,561 outlined cold functions each. - Two independent code reviews and their fixes are in the commits. **Still to test:** - Linux and the Steam Deck: a pack in Market child, `LONGSHOT_HOT_SPLIT=0` against the default, expecting fewer CPU ms with the default (by hand, or the Test Farm). - Other CPUs, especially ones with a smaller L3 than 96 MB: the same A/B, expecting the gain to hold or grow (by hand, or the Test Farm). - Scenes beyond Market, Lost Woods, Fire Temple and Kokiri Forest: one start each with the default, expecting no new error lines (by hand). ## Measurements All measured with `LONGSHOT_HOT_SPLIT=1`, before the default flip. **Verdict:** Market child +3.6 to +6.2 % fps and −4.4 to −6.6 % CPU ms in three 3-pair A/Bs, all 9 pairs in favour. Lost Woods child +2.5 % fps, CPU flat. Market's 3-pair noise is about 3 % fps and 5 % CPU ms, so each A/B alone is close to it; the three agree. Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2. Uncapped (`HOS_FPS_MAX=240`), 16:9, render thread on, the fixed test profile. std_test's 20 s window after the teleport, 3 alternating pairs per A/B, with the background GPU load. Medians. Every contained game-clock reading was 0.989-1.011. Market child: | Market child, median | Before: main @ 9eabf8bc3 | After: this PR @ c17ccc776 | |---|---|---| | A/B 1 (this PR's first version, d4d0f25f6): fps, CPU ms, p99 | 101.94, 43.31, 17.89 | 108.29, 41.39, 17.31 (+6.2 % fps, −4.4 % CPU) | | A/B 2: fps, CPU ms, p99 | 106.44, 43.04, 17.27 | 111.54, 40.21, 16.86 (+4.8 % fps, −6.6 % CPU) | | A/B 3: fps, CPU ms, p99 | 105.29, 43.46, 17.72 | 109.09, 41.03, 18.15 (+3.6 % fps, −5.6 % CPU) | - Per pair, fps: +7.0 / +3.1 / +3.9 %, then +3.9 / +5.8 / +4.4 %, then +4.9 / +3.6 / +4.0 %. - No frame over 50 ms in either arm of the last two A/Bs. Lost Woods child (round 1): 121.44 → 124.44 fps (+2.5 %), 39.83 → 39.73 CPU ms (flat), p99 11.02 → 11.72. The A/Bs ran on main 9eabf8bc3. The PR is now on main 20bedc6da. The commits since then change none of the lifter, the IR writer or the compile of the lifted units. One of them (#2665, mutex lookups through the guest word) changes the host's CPU work in both arms alike. The A/B was not run again. `LONGSHOT_NO_CLANG` in the diff is the builder tests' existing escape (no clang on the runner: the clang checks pass over), used by the new integration test as by the others, not a switch the build reads. Costs: - The exe grows 288,256 bytes (+0.036 %), with 400 outlined regions (55,117 bytes). The hot functions' code goes from 41.14 to 41.34 MB. - Compile time of the 122 hot units is 0 to +2 % (CPU seconds, 15 jobs). - Turning the switch on or off lifts and compiles only the 122 hot units again. ## Risks - **On by default, for every player.** On the update that ships this, every player's lift runs once more: the lifter's sources changed, so every lift key moves. The units other than the hot ones come out with the same texts, and the compile finds them in its content-keyed cache. The 122 hot units have new texts and new flags, so they compile again, once. The lift itself takes about 30 s for the whole game here (15 threads). - **Kill switch:** `LONGSHOT_HOT_SPLIT=0` gives the build without the splitting: main's IR and compile flags, and the keys this lifter gives without it. Setting it or clearing it lifts and compiles the hot units alone again. - **A block the profile never saw run that a player does run often** (another save, another route) becomes a call each time it runs. That is slower there but exact: hot-cold splitting only moves code. - **Known follow-up (latent, not seen):** - Shape: a never-taken edge into a never-run block that only jumps on to a join that ran is still weighted `(0, n)`. LLVM folds the jump block, so in synthetic IR that zero edge could reach the join and mark it cold. - Not reproduced: through this writer, compiled for Windows and Linux at the hot units' flags, nothing was outlined. - In the game IR: 1,217 of 27,562 zero-weighted sides go to a jump-only block, 650 of them with a target that has more than one way in. - In play: two sampled Market starts of the pack, 0 of about 24,700 lifted-code samples landed in the outlined code. - Fix: follow jump-only blocks in `ran`. - **Profiling tools:** outlined leaf functions have no `.pdata` (Win64 allows it), so the host sampler's stack walk stops at one; the crash recorder's leaf rule handles them. `scripts/profiling/cpu.py` doesn't map `f_X.cold.N` names to their guest function. - **Developer-only paths:** - A profile recorded with other piece cuts (`--split-over`) keys a piece start's counts at the entry. - A standalone `compile` at `LONGSHOT_HOT_SPLIT=0` accepts a gen/ with no `lift.key` and kept IR, as main's does. Turn it off: `LONGSHOT_HOT_SPLIT=0`, or revert. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. The game runs were with `=1`; the default flip runs the same code and was checked by the tests above. - [x] `mise run test` passes (any failure that also fails on `main` is named). `tests/run_all.py` on Windows, before the flip: 793 passed, 17 failed, 51 skipped; the same 17 fail on main 455b143b on this PC: test_auto_handheld.py, test_builder_channel.py, test_control_picture.py, test_coverage_run.py, test_crash_record.py, test_dev_ab.py, test_dev_build.py, test_dev_migrate.py, test_fs_path_utf8.py, test_job_queue.py, test_longshot_ctl.py, test_oot_menu_mouse.py, test_oot_state_tap.py, test_parity_gates.py, test_run_all_mingw.py, test_screensaver.py, test_switch_table.py. - [x] 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 switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. It's a build switch, on by default: its row, `LONGSHOT_HOT_SPLIT=0`, is in `docs/dev/reference/build.md`'s table, not `switches.def`. - [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. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The guest profile's text has no taken count for a branch never taken, so today such a branch has no weights and its
never-run side is placed by LLVM's static guesses, often in the middle of the code that runs. With the switch, the
lift weights every such branch of the hot units 0 to its block's count, and the compile builds the hot units with
LLVM's hot-cold splitting for blocks behind a branch of probability at most 2^-31 alone: a region that never ran
becomes a cold function of its own where LLVM can take it out (.text$unlikely$ on Windows), and block placement puts
the rest after the blocks that ran.

- llvm: Module::split_cold(skip); weights() gives a never-taken branch of a block that ran (0, n) in such a module;
  a function that calls the host's setjmp is written noinline there, which hot-cold splitting leaves whole (it is
  never inlined anyway: returns_twice). Off, the writer's text is unchanged.
- lift: LiftOptions::hot_split (None off; Some(skip)); in codegen_text only when on, so off every key is as before;
  the hot units alone are made with split_cold, leaving out the skip list's functions and those the edits change.
- build-driver: LONGSHOT_HOT_SPLIT=1 (by value) and LONGSHOT_HOT_SPLIT_SKIP; the lift logs the line and refuses a bad
  list. build-compile: Settings::hot_split from the same switch, hotsplit::flags for the hot units only.
- dev lift --hot-split / --hot-split-skip, dev words --hot-split.
- tests: llvm hotsplit_tests (the weights, nothing else changes, left out = off, setjmp noinline), lift whole test (off
  by default, keys move only when on, off again gives the first key), build-compile flags, longshot-builder
  tests/hot_split.rs (compiled for Windows and Linux: the never-run region moves to a .cold function; written without
  the switch, compiled without the flags or left out, nothing moves; the switch read by value),
  test_lifter_semantics.py --hot-split (every cold region outlined, against Unicorn) and --march.
- docs: build.md switch table, builder.md guest profile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The review of d4d0f25f6 (checker and sol, 2026-11-27):

1. A split function's later piece starts at a block passes::split makes at the function's entry address, so the
   profile's counts there are the entry block's: 21 hot pieces got a (0, n) from them. That block's branch is now
   written as without the switch.
2. A never-taken edge into a block that ran through another edge (49.8 % of the zero weights) is weighted 1, not 0, so
   that hot-cold splitting cannot take a hot join for cold; the same for a not-taken side, and for a count the 32-bit
   scaling made 0. The other side is kept to 2^30, above the compile's 2^-31.
3. dev words --hot-split made the module split_cold after its functions were written, so it changed nothing: it is
   now set before. test_lifter_semantics.py takes --hot-flags (the hot units' compile) apart from --hot-split (the
   writer), so the matrix compares the writer off and on at the same -O2 with the hot flags. A word's function has no
   branch with counts, so the writer's weights are run in longshot-builder's tests/hot_split.rs instead: built for this
   PC and run from both sides of the branch, the program with the region moved out gives the registers and guest
   memory of the program without the switch.
4. The docs said left-out and edited functions are never split; the flags are a whole unit's, so they can be behind a
   weight they have without the switch or at a call of a cold helper. Reworded (build.md, builder.md).
5. A lift with the switch on writes "hot_split skip ..." in gen/lift.key (off: no line, the file as before), and
   longshot-builder compile on its own refuses a lift made with the switch or the skip list otherwise, or a bad list
   (stages::check_hot_split): with LONGSHOT_KEEP_IR=1 the texts on disk were compiled with whatever flags were asked.
6. The switch is no longer in codegen_text, which every unit's key holds: a hot function's own key holds it (and
   whether the skip list names it), so a change of it moves the hot units' keys alone; the whole lift's key holds the
   switch and the list, so an old lift is not kept.

Tests: llvm hotsplit_tests (a later piece's first block as off, a rare branch kept at 1), lift whole test (only the
hot unit's key moves, the skip list of a function in no hot unit moves no unit key, the key file's line),
tests/hot_split.rs (the run on both sides, the join weighted 1 and nothing outlined on Windows and Linux, the compile
on its own refusing each mismatch and a bad list).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The sol review of fa27af4c5 (stubs/sol-reviews/m1-hot-split-r2.md):

- 3: a later piece's first block (made at the function's entry address) still got the entry's counts through the old
  rule, (n, 0) among them. Made for hot-cold splitting, its branch now has no weights at all.
- 4: a never-taken edge into a piece's first block looked up the entry's count to say whether the block ran. That block
  is now taken to have run (weighted 1).
- 1: a compile on its own with the switch on refuses a gen/ with no lift.key (a lift that stopped, or whose link
  failed, deletes it and can leave its texts).
- 5: the check runs only where the compile reads the lift (game, game only), not for the renderer alone.
- 6: the run test's harness counts the guest call, which only the region moved out makes: Z set must call once, Z
  clear never, so the outlined region is shown to have run.

Not changed: an interrupted lift whose rewritten unit text has the old size can be kept by the next lift's size check
(review point 2). That is the lift's own reuse rule for any option, not this switch's; and a gen/ lifted by d4d0f25f6
with the switch on has no key line, so the check cannot tell it (that commit was never shipped).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The sol review of 149bebf57 (stubs/sol-reviews/m1-hot-split-r3.md):

- A function left out (the skip list, the edits) kept its weights without the switch, which can be (n, 0) into a
  join, and the unit's flags still split it. The guard (a side that was taken, or that goes to a block that ran, is
  never weighted 0) now applies to every function of a module made for hot-cold splitting; only the new zero weights
  are left out for them. The same for a split function's piece's first branch (no weights) in such a function.
- A rare branch, taken once in about 2^31, is unscaled (1, 2147483645): LLVM rounds that probability to its cutoff
  and takes the side for cold. The side that ran now keeps the other to at most 2^30 times its own weight.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the sol review of c17ccc776 (stubs/sol-reviews/m1-hot-split-r4.md): the piece-start case with the function on the
skip list (no weights there either), and the not-taken side of a rare branch kept to 2^30 to 1, so that both pass only
with the guard as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the check of ed5f537bf (check-r2.md 1.4 and 1.6):

- the lift test now also says that a hot unit whose function is left out has neither the on key nor the off key: its
  text is not off's (the guard's weights are in it), so a mutant giving it the off key would reuse a stale unit.
- build.md, builder.md and the split_cold comment said left-out functions keep the weights they have without the
  switch. They get no new zero weights; the guard still keeps a side that ran from a cold probability in every
  function of a hot unit, and a later piece's first branch has no weights.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge main into perf/hot-split
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
CI / What the change needs (pull_request) Successful in 18s
CI / Third-party parts and guide screenshots (pull_request) Failing after 28s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 31s
PR description / Title and description (pull_request_target) Successful in 13s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
e93c76c1f8
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2 (LLPC): packs with LONGSHOT_HOT_SPLIT=1 over main 9eabf8bc3, std_test A/Bs in Market child (three rounds, 3 pairs each) and Lost Woods child, single starts in Lost Woods, Fire Temple and Kokiri Forest. Every run reached its scene; no new error lines in the game logs; no crash records. Market child +3.6 to +6.2 % fps, -4.4 to -6.6 % CPU ms.

Tested in game: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2 (LLPC): packs with LONGSHOT_HOT_SPLIT=1 over main 9eabf8bc3, std_test A/Bs in Market child (three rounds, 3 pairs each) and Lost Woods child, single starts in Lost Woods, Fire Temple and Kokiri Forest. Every run reached its scene; no new error lines in the game logs; no crash records. Market child +3.6 to +6.2 % fps, -4.4 to -6.6 % CPU ms.
Member

Possibly related, for context:

  • PR #1146 perf(build): the hot pieces compile with their giant functions split — Previously merged hot-function splitting; this adds cold-block outlining
Possibly related, for context: - PR #1146 perf(build): the hot pieces compile with their giant functions split — Previously merged hot-function splitting; this adds cold-block outlining
Merge main into perf/hot-split
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 16s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
200d3741be
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member
@review
BeanBot left a comment

Recommendation: Approve. The new integration test ignores the configured compiler and can fail on supported setups that provide Clang through CC. The reported Market gain is promising, but Linux and Steam Deck behavior and the effect in other scenes remain unmeasured. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

The opt-in switch moves profile-cold regions of hot lifted functions out of their hot code. On the reported Windows PC, Market improved by 3.6–6.2% FPS across three A/B rounds, at the cost of a larger executable and a one-time lift-key change for everyone.

Should fix (1): not blocking, but worth doing before merging.

  • L1 builder/crates/longshot-builder/tests/hot_split.rs:19: The integration test selects only hard-coded Clang names and ignores CC. (more on the line) Do: Honor CC when selecting the compiler, with the existing Clang discovery as a fallback, and preserve the explicit no-Clang skip behavior.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 builder/crates/build-compile/src/hotsplit.rs:15: The changed CPU code has only been measured on one Windows CPU; its effect on Linux, Steam Deck and smaller caches remains unknown. (more on the line) Do: Run interleaved switch-off/on comparisons in Market on Linux or Steam Deck and a smaller-cache CPU, including FPS, lows and frame times; exercise additional scenes with the switch enabled. (@fix does its part first: The switch is already off by default; retain that default until the broader results support changing it.)
  • L3 builder/crates/lift/src/whole/mod.rs:460: The build measurements cover hot-unit compile CPU time but not the full clean build or the incremental one-function-change build. (more on the line) Do: Compare clean and one-function-change build elapsed times and output sizes against the base, including the default-off first rebuild.

@fix can do L1 and L2.

Checks: Still running: 8 checks.

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

Does it help: Unproven across supported systems. The author's Windows Market measurements show 3.6–6.2% higher median FPS and 4.4–6.6% lower CPU time, but the third round's p99 rose from 17.72 to 18.15 ms; Lost Woods FPS rose 2.5% with CPU time flat and p99 rising from 11.02 to 11.72 ms. Linux, Steam Deck and other CPUs have not been measured.

Other systems: The switch changes generated CPU code on Windows and Linux regardless of GPU vendor. Different CPUs and routes can execute profile-cold regions frequently; the reported runs cover one Windows CPU and a few scenes. With the switch off, changed lifter sources still invalidate lift keys once for existing players.

Switches: LONGSHOT_HOT_SPLIT defaults off; that is appropriate while broader results are pending. LONGSHOT_HOT_SPLIT_SKIP defaults empty and is read only when splitting is on; it is a developer escape hatch. Both are documented in the build switch table. The new dev lift and words flags and semantics-test flags also default off.

Reviewed: 200d3741be against 1f83583528: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the diff, commit messages, the new hot-split integration test and LLVM hot-split tests, and the relevant lift session and LLVM writer paths. Skimmed the remaining changed files and surrounding callers; not every changed code file was read in full. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No recorded run artifacts, translations or generated files were included in the diff.; nothing run (a code review).

Checked and fine:

  • The switch defaults off in both lift and compile settings.
  • Standalone game compilation checks the lift's recorded switch and skip list.
  • The new tests use synthetic functions and words; no game-derived output appears among the changed files.
  • The listed commits carry AI-assistance trailers.

Testing: No commands that build, test or run project code were executed. The author's Windows game runs and reported crate and integration-test results were considered; CI was still running.

Overlaps and merge order: Unknown; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The new integration test ignores the configured compiler and can fail on supported setups that provide Clang through CC. The reported Market gain is promising, but Linux and Steam Deck behavior and the effect in other scenes remain unmeasured. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. The opt-in switch moves profile-cold regions of hot lifted functions out of their hot code. On the reported Windows PC, Market improved by 3.6–6.2% FPS across three A/B rounds, at the cost of a larger executable and a one-time lift-key change for everyone. **Should fix (1)**: not blocking, but worth doing before merging. - **L1** `builder/crates/longshot-builder/tests/hot_split.rs:19`: The integration test selects only hard-coded Clang names and ignores CC. (more on the line) **Do:** Honor CC when selecting the compiler, with the existing Clang discovery as a fallback, and preserve the explicit no-Clang skip behavior. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `builder/crates/build-compile/src/hotsplit.rs:15`: The changed CPU code has only been measured on one Windows CPU; its effect on Linux, Steam Deck and smaller caches remains unknown. (more on the line) **Do:** Run interleaved switch-off/on comparisons in Market on Linux or Steam Deck and a smaller-cache CPU, including FPS, lows and frame times; exercise additional scenes with the switch enabled. *(`@fix` does its part first: The switch is already off by default; retain that default until the broader results support changing it.)* - **L3** `builder/crates/lift/src/whole/mod.rs:460`: The build measurements cover hot-unit compile CPU time but not the full clean build or the incremental one-function-change build. (more on the line) **Do:** Compare clean and one-function-change build elapsed times and output sizes against the base, including the default-off first rebuild. `@fix` can do L1 and L2. **Checks:** Still running: 8 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven across supported systems. The author's Windows Market measurements show 3.6–6.2% higher median FPS and 4.4–6.6% lower CPU time, but the third round's p99 rose from 17.72 to 18.15 ms; Lost Woods FPS rose 2.5% with CPU time flat and p99 rising from 11.02 to 11.72 ms. Linux, Steam Deck and other CPUs have not been measured. **Other systems:** The switch changes generated CPU code on Windows and Linux regardless of GPU vendor. Different CPUs and routes can execute profile-cold regions frequently; the reported runs cover one Windows CPU and a few scenes. With the switch off, changed lifter sources still invalidate lift keys once for existing players. **Switches:** LONGSHOT_HOT_SPLIT defaults off; that is appropriate while broader results are pending. LONGSHOT_HOT_SPLIT_SKIP defaults empty and is read only when splitting is on; it is a developer escape hatch. Both are documented in the build switch table. The new dev lift and words flags and semantics-test flags also default off. **Reviewed:** 200d3741bed5 against 1f83583528ec: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, the diff, commit messages, the new hot-split integration test and LLVM hot-split tests, and the relevant lift session and LLVM writer paths. Skimmed the remaining changed files and surrounding callers; not every changed code file was read in full. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No recorded run artifacts, translations or generated files were included in the diff.; nothing run (a code review). **Checked and fine:** - The switch defaults off in both lift and compile settings. - Standalone game compilation checks the lift's recorded switch and skip list. - The new tests use synthetic functions and words; no game-derived output appears among the changed files. - The listed commits carry AI-assistance trailers. **Testing:** No commands that build, test or run project code were executed. The author's Windows game runs and reported crate and integration-test results were considered; CI was still running. **Overlaps and merge order:** Unknown; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.</sub>
@ -0,0 +12,4 @@
/// probability at most 2^-31, a branch the profile never saw taken (LLVM's default, 1 %, would also take blocks that
/// ran). A call of a `cold` function (a float's slow path) still makes its block cold, whatever the probability.
pub fn flags(on: bool) -> Vec<String> {
if !on {
Member

L2 (should fix): The changed CPU code has only been measured on one Windows CPU; its effect on Linux, Steam Deck and smaller caches remains unknown.

When: With the switch enabled on a different CPU or route, a region absent from the guest profile can be executed frequently and pay the outlined-call and layout costs.

Do: Run interleaved switch-off/on comparisons in Market on Linux or Steam Deck and a smaller-cache CPU, including FPS, lows and frame times; exercise additional scenes with the switch enabled.

**L2** (should fix): The changed CPU code has only been measured on one Windows CPU; its effect on Linux, Steam Deck and smaller caches remains unknown. *When:* With the switch enabled on a different CPU or route, a region absent from the guest profile can be executed frequently and pay the outlined-call and layout costs. **Do:** Run interleaved switch-off/on comparisons in Market on Linux or Steam Deck and a smaller-cache CPU, including FPS, lows and frame times; exercise additional scenes with the switch enabled.
@ -431,0 +457,4 @@
let mut text = format!("{}\n{}\n{} {:?}", program.inputs(entry), s.edits.key(entry), r.cold, r.counts);
// (a hot function's unit is made for hot-cold splitting with the switch: its key says so, and whether the
// skip list names it; the other units' texts, and so their keys, are the same either way)
if let Some(skip) = s.o.hot_split.as_ref().filter(|_| hot.contains(&entry)) {
Member

L3 (should fix): The build measurements cover hot-unit compile CPU time but not the full clean build or the incremental one-function-change build.

When: Every existing player gets new lift keys when these lifter sources ship, so the one-time rebuild can add elapsed time even with the switch off.

Do: Compare clean and one-function-change build elapsed times and output sizes against the base, including the default-off first rebuild.

**L3** (should fix): The build measurements cover hot-unit compile CPU time but not the full clean build or the incremental one-function-change build. *When:* Every existing player gets new lift keys when these lifter sources ship, so the one-time rebuild can add elapsed time even with the switch off. **Do:** Compare clean and one-function-change build elapsed times and output sizes against the base, including the default-off first rebuild.
@ -0,0 +16,4 @@
/// The clang the test compiles with (that of the PATH; `LONGSHOT_NO_CLANG=1` passes over the test without one).
fn clang() -> Option<&'static str> {
let found = ["clang", "clang-23"]
Member

L1 (should fix): The integration test selects only hard-coded Clang names and ignores CC.

When: On a supported build machine where CC points to a suitable Clang at another path or name and neither clang nor clang-23 is on PATH, the new test panics instead of using the configured compiler.

Do: Honor CC when selecting the compiler, with the existing Clang discovery as a fallback, and preserve the explicit no-Clang skip behavior.

**L1** (should fix): The integration test selects only hard-coded Clang names and ignores CC. *When:* On a supported build machine where CC points to a suitable Clang at another path or name and neither clang nor clang-23 is on PATH, the new test panics instead of using the configured compiler. **Do:** Honor CC when selecting the compiler, with the existing Clang discovery as a fallback, and preserve the explicit no-Clang skip behavior.
test(builder): the hot-split integration test compiles with CC when it names a clang
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Title and description (pull_request_target) Successful in 8s
CI / What the change needs (pull_request) Successful in 11s
CI / Third-party parts and guide screenshots (pull_request) Successful in 14s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 12s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Successful in 2m26s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 1m10s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 1m31s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 2m11s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Successful in 17m1s
CI / Website build and checks (pull_request) Failing after 2m21s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 25m21s
8b992fd06d
BeanBot's L1 on #2700: tests/hot_split.rs looked for clang and clang-23 on the PATH only. It now takes CC first when
CC names a compiler that runs, then those names, and LONGSHOT_NO_CLANG=1 still passes over it without one. Checked with
CC set to llvm-mingw's clang by its full path and no clang on the PATH: 5 of 5.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Answers to BeanBot's review of 200d3741b:

  • L1 (CC in the integration test): fixed in 8b992fd06. tests/hot_split.rs takes CC first when it names a compiler that runs, then clang and clang-23; LONGSHOT_NO_CLANG=1 still passes over it. Checked with CC set to llvm-mingw's clang by its full path and no clang on the PATH: 5 of 5.
  • L2 (Linux, Steam Deck, smaller caches, more scenes): not run yet. They stay in Still to test, and the switch stays off by default until they have run. A default flip is for the builder's owner, HumanBean, and the maintainers. A Steam Deck run is planned together with two other lifter changes measured on the same base. There is no Test Farm request yet: off by default, main's build is what players get.
  • L3 (clean and one-function builds):
    • Switch off: the IR is byte-identical to main's. A whole lift of the game gives 386 of 386 unit texts with main's content SHA-1. What changes for every player is the lift key, once, because the lifter's sources changed. That re-runs the lift (about 30 s for the whole game here, 15 threads), and the compile then finds every object in its content-keyed cache.
    • Switch on: only the 122 hot units lift and compile again. Their compile took 0 to +2 % CPU seconds over main's (two alternating rounds, 15 jobs). A one-function change compiles its own unit as before.
    • I didn't time a clean player build end to end. Off it runs the same compile as main; on, the hot units' share is what moves.
  • p99 in Market's third round and Lost Woods: 17.72 → 18.15 ms and 11.02 → 11.72 ms. In the other two Market rounds p99 went 17.89 → 17.31 and 17.27 → 16.86. No frame over 50 ms in either arm of the last two Market A/Bs.

Measured on main 9eabf8bc3; the PR is now on main 1f8358352. The 17 commits since change none of the lifter, the IR writer or the compile of the lifted units (one, #2665, changes the host's mutex lookups in both arms alike), so the A/B wasn't run again.

Answers to BeanBot's review of 200d3741b: - **L1 (CC in the integration test):** fixed in 8b992fd06. `tests/hot_split.rs` takes `CC` first when it names a compiler that runs, then `clang` and `clang-23`; `LONGSHOT_NO_CLANG=1` still passes over it. Checked with `CC` set to llvm-mingw's clang by its full path and no clang on the PATH: 5 of 5. - **L2 (Linux, Steam Deck, smaller caches, more scenes):** not run yet. They stay in Still to test, and the switch stays off by default until they have run. A default flip is for the builder's owner, HumanBean, and the maintainers. A Steam Deck run is planned together with two other lifter changes measured on the same base. There is no Test Farm request yet: off by default, main's build is what players get. - **L3 (clean and one-function builds):** - **Switch off:** the IR is byte-identical to main's. A whole lift of the game gives 386 of 386 unit texts with main's content SHA-1. What changes for every player is the lift key, once, because the lifter's sources changed. That re-runs the lift (about 30 s for the whole game here, 15 threads), and the compile then finds every object in its content-keyed cache. - **Switch on:** only the 122 hot units lift and compile again. Their compile took 0 to +2 % CPU seconds over main's (two alternating rounds, 15 jobs). A one-function change compiles its own unit as before. - I didn't time a clean player build end to end. Off it runs the same compile as main; on, the hot units' share is what moves. - **p99 in Market's third round and Lost Woods:** 17.72 → 18.15 ms and 11.02 → 11.72 ms. In the other two Market rounds p99 went 17.89 → 17.31 and 17.27 → 16.86. No frame over 50 ms in either arm of the last two Market A/Bs. Measured on main 9eabf8bc3; the PR is now on main 1f8358352. The 17 commits since change none of the lifter, the IR writer or the compile of the lifted units (one, #2665, changes the host's mutex lookups in both arms alike), so the A/B wasn't run again.
Owner

Should we enable by default?

Should we enable by default?
Owner
@review
BeanBot left a comment

Recommendation: Approve. The opt-in change shows a Windows Market gain, but its effect on Linux, Steam Deck and smaller caches remains unknown, as does its full build-time cost. Keep it off by default until broader results support enabling it. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

The builder can use profile weights and LLVM hot-cold splitting to make frequently executed game code denser. It adds an opt-in build path and causes a one-time lift-key change for existing builds.

Should fix (1): not blocking, but worth doing before merging.

  • L4 builder/crates/longshot-builder/tests/hot_split.rs:23: The compiler probe accepts any executable that succeeds with --version, including compilers that cannot compile LLVM IR. (more on the line) Do: Verify that the CC candidate is a suitable Clang compiler before selecting it, and fall back to the PATH candidates otherwise.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 builder/crates/build-compile/src/hotsplit.rs:15: The changed CPU code has only been measured on one Windows CPU; its effect on Linux, Steam Deck and smaller caches remains unknown. When: With the switch enabled on a different CPU or route, a region absent from the guest profile can be executed frequently and pay the outlined-call and layout costs. Do: Run interleaved switch-off/on comparisons in Market on Linux or Steam Deck and a smaller-cache CPU, including FPS, lows and frame times; exercise additional scenes with the switch enabled. (@fix does its part first: The switch is already off by default; retain that default until the broader results support changing it.)
  • L3 builder/crates/lift/src/whole/mod.rs:460: The build measurements cover hot-unit compile CPU time but not the full clean build or the incremental one-function-change build. When: Every existing player gets new lift keys when these lifter sources ship, so the one-time rebuild can add elapsed time even with the switch off. Do: Compare clean and one-function-change build elapsed times and output sizes against the base, including the default-off first rebuild.

@fix can do L2 and L4.

Since the last review (on 200d3741be)
Resolved: L1 (The integration test selects only hard-coded Clang names and ignores CC.)
Still open: L2 (The changed CPU code has only been measured on one Windows CPU; its effect on Linux, Steam…); L3 (The build measurements cover hot-unit compile CPU time but not the full clean build or the…)
New: L4 (The compiler probe accepts any executable that succeeds with --version, including compiler…)

Checks: Still running: 7 checks.

Also noticed (2; not asked for, not blocking)
  • The reported third Market round and Lost Woods run have higher p99 frame times despite higher median FPS.
  • The described jump-only-block case remains a possible source of incorrect cold classification.
More: does it help, other systems, switches, what was read

Does it help: Yes on the tested Windows PC: the PR reports three Market A/B medians of +3.6% to +6.2% FPS and −4.4% to −6.6% CPU time. The measurements used an earlier main commit, and results elsewhere remain unproven.

Other systems: The switch changes lifted CPU code on Windows and Linux when enabled. Linux, Steam Deck, smaller-cache CPUs and additional scenes remain untested; the author reports Windows game runs and matching lifted behavior in an integration test.

Switches: LONGSHOT_HOT_SPLIT defaults off; retaining that default is appropriate pending broader results. LONGSHOT_HOT_SPLIT_SKIP defaults to an empty list and excludes named functions when splitting is enabled. LONGSHOT_NO_CLANG is an existing test escape, not a new build switch.

Reviewed: 8b992fd06d against 1f83583528: Read the changed integration test in full, the fix diff, build-compile hotsplit flags, relevant lift and driver references, repository rules and PR template. Skimmed the overall diff and commit list; the remaining changed code and recorded tests were not read in full.; nothing run (a code review).

Checked and fine:

  • The changed test passes the selected compiler consistently to its compile and run helpers.
  • The reported fix preserves the opt-in hot-splitting path.

Testing: No commands from the project were run. The author reports Windows game and integration-test results; CI is still running.

Overlaps and merge order: Not checked; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The opt-in change shows a Windows Market gain, but its effect on Linux, Steam Deck and smaller caches remains unknown, as does its full build-time cost. Keep it off by default until broader results support enabling it. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. The builder can use profile weights and LLVM hot-cold splitting to make frequently executed game code denser. It adds an opt-in build path and causes a one-time lift-key change for existing builds. **Should fix (1)**: not blocking, but worth doing before merging. - **L4** `builder/crates/longshot-builder/tests/hot_split.rs:23`: The compiler probe accepts any executable that succeeds with --version, including compilers that cannot compile LLVM IR. (more on the line) **Do:** Verify that the CC candidate is a suitable Clang compiler before selecting it, and fall back to the PATH candidates otherwise. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `builder/crates/build-compile/src/hotsplit.rs:15`: The changed CPU code has only been measured on one Windows CPU; its effect on Linux, Steam Deck and smaller caches remains unknown. *When:* With the switch enabled on a different CPU or route, a region absent from the guest profile can be executed frequently and pay the outlined-call and layout costs. **Do:** Run interleaved switch-off/on comparisons in Market on Linux or Steam Deck and a smaller-cache CPU, including FPS, lows and frame times; exercise additional scenes with the switch enabled. *(`@fix` does its part first: The switch is already off by default; retain that default until the broader results support changing it.)* - **L3** `builder/crates/lift/src/whole/mod.rs:460`: The build measurements cover hot-unit compile CPU time but not the full clean build or the incremental one-function-change build. *When:* Every existing player gets new lift keys when these lifter sources ship, so the one-time rebuild can add elapsed time even with the switch off. **Do:** Compare clean and one-function-change build elapsed times and output sizes against the base, including the default-off first rebuild. `@fix` can do L2 and L4. **Since the last review** (on 200d3741bed5) Resolved: L1 (The integration test selects only hard-coded Clang names and ignores CC.) Still open: L2 (The changed CPU code has only been measured on one Windows CPU; its effect on Linux, Steam…); L3 (The build measurements cover hot-unit compile CPU time but not the full clean build or the…) New: L4 (The compiler probe accepts any executable that succeeds with --version, including compiler…) **Checks:** Still running: 7 checks. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The reported third Market round and Lost Woods run have higher p99 frame times despite higher median FPS. - The described jump-only-block case remains a possible source of incorrect cold classification. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the tested Windows PC: the PR reports three Market A/B medians of +3.6% to +6.2% FPS and −4.4% to −6.6% CPU time. The measurements used an earlier main commit, and results elsewhere remain unproven. **Other systems:** The switch changes lifted CPU code on Windows and Linux when enabled. Linux, Steam Deck, smaller-cache CPUs and additional scenes remain untested; the author reports Windows game runs and matching lifted behavior in an integration test. **Switches:** LONGSHOT_HOT_SPLIT defaults off; retaining that default is appropriate pending broader results. LONGSHOT_HOT_SPLIT_SKIP defaults to an empty list and excludes named functions when splitting is enabled. LONGSHOT_NO_CLANG is an existing test escape, not a new build switch. **Reviewed:** 8b992fd06d82 against 1f83583528ec: Read the changed integration test in full, the fix diff, build-compile hotsplit flags, relevant lift and driver references, repository rules and PR template. Skimmed the overall diff and commit list; the remaining changed code and recorded tests were not read in full.; nothing run (a code review). **Checked and fine:** - The changed test passes the selected compiler consistently to its compile and run helpers. - The reported fix preserves the opt-in hot-splitting path. **Testing:** No commands from the project were run. The author reports Windows game and integration-test results; CI is still running. **Overlaps and merge order:** Not checked; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -0,0 +20,4 @@
let found = std::env::var("CC")
.ok()
.into_iter()
.chain(["clang".to_string(), "clang-23".to_string()])
Member

L4 (should fix): The compiler probe accepts any executable that succeeds with --version, including compilers that cannot compile LLVM IR.

When: With CC=gcc and clang available on PATH, gcc is selected first; the tests then pass it Clang-specific options and LLVM IR and fail instead of falling back to clang.

Do: Verify that the CC candidate is a suitable Clang compiler before selecting it, and fall back to the PATH candidates otherwise.

**L4** (should fix): The compiler probe accepts any executable that succeeds with --version, including compilers that cannot compile LLVM IR. *When:* With CC=gcc and clang available on PATH, gcc is selected first; the tests then pass it Clang-specific options and LLVM IR and fail instead of falling back to clang. **Do:** Verify that the CC candidate is a suitable Clang compiler before selecting it, and fall back to the PATH candidates otherwise.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
perf(builder): the hot units' hot-cold splitting is on by default; LONGSHOT_HOT_SPLIT=0 turns it off
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, built by CI (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
CI / What the change needs (pull_request) Successful in 34s
CI / Third-party parts and guide screenshots (pull_request) Failing after 57s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 53s
PR description / Title and description (pull_request_target) Successful in 31s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 3m43s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 1m40s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 3m36s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 4m5s
CI / Website build and checks (pull_request) Failing after 3m31s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 22m11s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 36m37s
af570e01a8
HumanBean asked on #2700 whether to enable it by default; the maintainers said yes.

- build_compile::hotsplit::on is the one reading of the switch: unset on, an off word (0, off, no, false, empty)
  off, any other value on, as build_core::switch reads switches. The lift's half (build_driver::stages::hot_split)
  and the compile's (Settings::hot_split) both take it, so a lift made with the default compiles with the default,
  and the standalone `longshot-builder compile` check of lift.key follows the new default (check_hot_split_as takes
  the switch as given, for the test). The skip list works as before.
- `dev lift` reads LONGSHOT_HOT_SPLIT and LONGSHOT_HOT_SPLIT_SKIP as the build does; --hot-split, --no-hot-split and
  --hot-split-skip override them.
- Tests: hotsplit's unset_is_on_and_an_off_word_is_off; tests/hot_split.rs's new
  unset_is_on_and_0_is_off_in_the_lift_the_compile_and_the_compile_s_check (both halves and the compile's check of a
  lift made unset, at 0, or with no lift.key); the switch test's values follow the new rule; the lift crate's key test
  is renamed (LiftOptions::new stays off until the build sets it).
- The hot_split integration test takes CC only when it is a clang (BeanBot's L4: gcc can't read the IR).
- build.md's row is now LONGSHOT_HOT_SPLIT=0; builder.md, the semantics test's help and the comments say on by
  default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
klimovich008 changed title from WIP: perf(builder): LONGSHOT_HOT_SPLIT=1, the hot units' never-run blocks leave the hot code (off by default) to WIP: perf(builder): the hot units' never-run blocks leave the hot code by default (LONGSHOT_HOT_SPLIT=0 turns it off) 2026-11-28 01:11:55 +00:00
Author
Member

@HumanBean: yes. It is on by default now, in af570e01a (merged with main 20bedc6da first, no conflicts).

  • The switch: unset, 1 or any other word is on; LONGSHOT_HOT_SPLIT=0 (or off, no, false, empty) is the kill switch and gives main's IR and compile flags. The lift and the compile read it through one function, build_compile::hotsplit::on.
  • The standalone compile's check of lift.key follows the new default: a lift made with the default compiles with the default; a lift made at 0 and a compile with the default (or the other way round) is refused with "lift again".
  • For players: on the update that ships this, every player's lift runs once more (the lifter's sources changed), and the 122 hot units compile again once with their new texts and flags. Every other unit's text is the same and comes from the object cache.
  • Not retested: the flip itself wasn't run in the game or measured. The numbers in the description are from LONGSHOT_HOT_SPLIT=1, which the default now equals. New test: unset_is_on_and_0_is_off_in_the_lift_the_compile_and_the_compile_s_check in tests/hot_split.rs, plus hotsplit's unset_is_on_and_an_off_word_is_off.

BeanBot's L4 (the CC probe accepted gcc): fixed in af570e01a. CC is taken only when its --version says clang version; otherwise the test falls back to clang and clang-23 on the PATH. L2 and L3 stay as they were: Linux, the Steam Deck and smaller caches are in Still to test.

@HumanBean: yes. It is on by default now, in af570e01a (merged with main 20bedc6da first, no conflicts). - **The switch:** unset, `1` or any other word is on; `LONGSHOT_HOT_SPLIT=0` (or `off`, `no`, `false`, empty) is the kill switch and gives main's IR and compile flags. The lift and the compile read it through one function, `build_compile::hotsplit::on`. - **The standalone compile's check** of `lift.key` follows the new default: a lift made with the default compiles with the default; a lift made at `0` and a compile with the default (or the other way round) is refused with "lift again". - **For players:** on the update that ships this, every player's lift runs once more (the lifter's sources changed), and the 122 hot units compile again once with their new texts and flags. Every other unit's text is the same and comes from the object cache. - **Not retested:** the flip itself wasn't run in the game or measured. The numbers in the description are from `LONGSHOT_HOT_SPLIT=1`, which the default now equals. New test: `unset_is_on_and_0_is_off_in_the_lift_the_compile_and_the_compile_s_check` in `tests/hot_split.rs`, plus `hotsplit`'s `unset_is_on_and_an_off_word_is_off`. BeanBot's **L4** (the CC probe accepted gcc): fixed in af570e01a. `CC` is taken only when its `--version` says `clang version`; otherwise the test falls back to `clang` and `clang-23` on the PATH. L2 and L3 stay as they were: Linux, the Steam Deck and smaller caches are in Still to test.
Author
Member
@review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The Windows measurements show a Market gain, but the now-default optimization still needs the Linux, Steam Deck and smaller-cache measurements requested in L2. Clean and incremental build times also remain unmeasured. Recommend approval; not approved on the forge.

The builder moves profile-cold regions out of hot functions by default, improving measured Market performance at the cost of a one-time lift and recompilation of hot units after updating. The shared switch reader keeps the lift and compile defaults aligned.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 builder/crates/build-compile/src/hotsplit.rs:15: The optimization is now enabled by default without measurements on Linux, Steam Deck or smaller-cache CPUs. When: Those players receive the changed code layout, but its performance relative to the disabled build is unknown. Do: Run matched, repeated default-versus-0 game A/Bs on Linux, Steam Deck and a smaller-cache CPU. (@fix does its part first: The switch is already off by default; retain that default until the broader results support changing it.)
  • L3 builder/crates/lift/src/whole/mod.rs:460: The build measurements cover hot-unit compile CPU time but not the full clean build or the incremental one-function-change build. When: Every existing player gets new lift keys when these lifter sources ship, so the one-time rebuild can add elapsed time even with the switch off. Do: Compare clean and one-function-change build elapsed times and output sizes against the base, including the default-off first rebuild.

@fix can do L2.

Since the last review (on 8b992fd06d)
Resolved: L4 (The compiler probe accepts any executable that succeeds with --version, including compiler…)
Still open: L2 (The optimization is now enabled by default without measurements on Linux, Steam Deck or sm…); L3 (The build measurements cover hot-unit compile CPU time but not the full clean build or the…)

Checks: Failing on this head, which is behind its base, where it passes: CI / Third-party parts and guide screenshots (pull_request). @rebase (or @fix) brings it up to date and runs it again; not held against it. Still running: 7 checks.

Also noticed (1; not asked for, not blocking)
  • The author reports a possible jump-only-block profiling edge case and an unmeasured p99 increase in one Market round and Lost Woods.
More: does it help, other systems, switches, what was read

Does it help: Yes on the tested Windows PC: three Market A/B rounds reported 3.6–6.2% higher median FPS and 4.4–6.6% lower CPU time. The effect on Linux, Steam Deck and smaller-cache CPUs remains unproven.

Other systems: The changed native code runs on Windows and Linux across CPUs; only one Windows CPU was measured. The author reports Windows and Linux target integration checks and game starts in four scenes, but no Linux or Steam Deck game run.

Switches: LONGSHOT_HOT_SPLIT now defaults on; 0, off, no, false or empty disables it. The default still needs broader measurements. LONGSHOT_HOT_SPLIT_SKIP excludes named functions and defaults to an empty list; dev lift now reads both environment switches and permits command-line overrides.

Reviewed: af570e01a8 against 20bedc6da1: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the changed switch implementation, compiler probe, lift keys and LLVM changes; inspected the relevant diff and callers. Other changed files and tests were skimmed, not read in full.; nothing run (a code review).

Checked and fine:

  • Lift and compile use the same switch parser.
  • The standalone compile compares its requested split setting with the lift key.
  • The compiler probe rejects gcc.

Testing: No commands from the project were run. The author reports game runs and integration checks; CI is still running.

Overlaps and merge order: Not checked; network access is unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The Windows measurements show a Market gain, but the now-default optimization still needs the Linux, Steam Deck and smaller-cache measurements requested in L2. Clean and incremental build times also remain unmeasured. Recommend approval; not approved on the forge. The builder moves profile-cold regions out of hot functions by default, improving measured Market performance at the cost of a one-time lift and recompilation of hot units after updating. The shared switch reader keeps the lift and compile defaults aligned. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `builder/crates/build-compile/src/hotsplit.rs:15`: The optimization is now enabled by default without measurements on Linux, Steam Deck or smaller-cache CPUs. *When:* Those players receive the changed code layout, but its performance relative to the disabled build is unknown. **Do:** Run matched, repeated default-versus-0 game A/Bs on Linux, Steam Deck and a smaller-cache CPU. *(`@fix` does its part first: The switch is already off by default; retain that default until the broader results support changing it.)* - **L3** `builder/crates/lift/src/whole/mod.rs:460`: The build measurements cover hot-unit compile CPU time but not the full clean build or the incremental one-function-change build. *When:* Every existing player gets new lift keys when these lifter sources ship, so the one-time rebuild can add elapsed time even with the switch off. **Do:** Compare clean and one-function-change build elapsed times and output sizes against the base, including the default-off first rebuild. `@fix` can do L2. **Since the last review** (on 8b992fd06d82) Resolved: L4 (The compiler probe accepts any executable that succeeds with --version, including compiler…) Still open: L2 (The optimization is now enabled by default without measurements on Linux, Steam Deck or sm…); L3 (The build measurements cover hot-unit compile CPU time but not the full clean build or the…) **Checks:** Failing on this head, which is behind its base, where it passes: `CI / Third-party parts and guide screenshots (pull_request)`. `@rebase` (or `@fix`) brings it up to date and runs it again; not held against it. Still running: 7 checks. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The author reports a possible jump-only-block profiling edge case and an unmeasured p99 increase in one Market round and Lost Woods. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the tested Windows PC: three Market A/B rounds reported 3.6–6.2% higher median FPS and 4.4–6.6% lower CPU time. The effect on Linux, Steam Deck and smaller-cache CPUs remains unproven. **Other systems:** The changed native code runs on Windows and Linux across CPUs; only one Windows CPU was measured. The author reports Windows and Linux target integration checks and game starts in four scenes, but no Linux or Steam Deck game run. **Switches:** LONGSHOT_HOT_SPLIT now defaults on; 0, off, no, false or empty disables it. The default still needs broader measurements. LONGSHOT_HOT_SPLIT_SKIP excludes named functions and defaults to an empty list; dev lift now reads both environment switches and permits command-line overrides. **Reviewed:** af570e01a8ae against 20bedc6da146: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the changed switch implementation, compiler probe, lift keys and LLVM changes; inspected the relevant diff and callers. Other changed files and tests were skimmed, not read in full.; nothing run (a code review). **Checked and fine:** - Lift and compile use the same switch parser. - The standalone compile compares its requested split setting with the lift key. - The compiler probe rejects gcc. **Testing:** No commands from the project were run. The author reports game runs and integration checks; CI is still running. **Overlaps and merge order:** Not checked; network access is unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.</sub>
klimovich008 changed title from WIP: perf(builder): the hot units' never-run blocks leave the hot code by default (LONGSHOT_HOT_SPLIT=0 turns it off) to perf(builder): the hot units' never-run blocks leave the hot code by default (LONGSHOT_HOT_SPLIT=0 turns it off) 2026-11-28 01:14:33 +00:00
Author
Member

Out of WIP at af570e01a, as the maintainer asked: on by default, LONGSHOT_HOT_SPLIT=0 turns it off, and the standalone compile's lift.key check follows the new default. The edited tests pass (build-compile hotsplit 2/2, the lift key test 1/1, tests/hot_split.rs 6/6). fmt, clippy on the touched crates and mise run lint are clean. Not retested in the game: the measurements are from =1 builds. CI was still running when I took it out of WIP. The guide screenshot check fails on main's head too, on 7 menu files changed by #1349 and #2708 without a review; this PR touches no third_party/ file and no guide picture.

🤖 Generated with Claude Code

Out of WIP at af570e01a, as the maintainer asked: on by default, `LONGSHOT_HOT_SPLIT=0` turns it off, and the standalone compile's `lift.key` check follows the new default. The edited tests pass (build-compile hotsplit 2/2, the lift key test 1/1, `tests/hot_split.rs` 6/6). fmt, clippy on the touched crates and `mise run lint` are clean. Not retested in the game: the measurements are from `=1` builds. CI was still running when I took it out of WIP. The guide screenshot check fails on main's head too, on 7 menu files changed by #1349 and #2708 without a review; this PR touches no third_party/ file and no guide picture. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HumanBean deleted branch perf/hot-split 2026-11-28 01:18:14 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!2700
No description provided.