perf(lift): the float slow paths' middle path off by default; LONGSHOT_FP_NAN_MID=1 brings it back #3081
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3081
Loading…
Reference in a new issue
No description provided.
Delete branch "klimovich008/Longshot:perf/nan-mid-off"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Why: #2684's middle path for float operations with a NaN lane no longer pays. It was added for the cloth's NaN lane in Lost Woods; since the cloth runs natively (
HOS_NATIVE_CLOTH), the lifted cloth no longer runs by default, and the middle path is only extra code: it makes the hot units 28 % bigger (58.6 → 42.0 MB with it off). Turned off, the game uses less CPU in every scene measured (Market −3.0 %, Fire Temple −2.3 %, Lost Woods −1.9 % CPU ms per frame; diagnostic, below).What changes:
LONGSHOT_FP_NAN_MIDis now off by default;LONGSHOT_FP_NAN_MID=1(oron,yes,true) turns the middle path back on, exactly as #2684 shipped it. Off, the lift is the lift before #2684: no middle path, nothing added to any key text. The middle path's code, its tests, the skip list anddev words --fp-nan-midall stay.Files, in reading order:
builder/crates/build-driver/src/stages.rs: the one place a build reads the switch.fp_nan_mid_onis on only for an on word ofbuild_core::switch; unset, an off word or any other word is off.LONGSHOT_FP_NAN_MID_SKIPis looked up only when the switch is on, and a non-Unicode list is refused only then.builder/crates/lift/src/whole/mod.rs:LiftOptions::newstarts withfp_nan_mid: None(the default ofdev liftand of the lift's tests).builder/crates/longshot-builder/src/dev/lift_cmd.rs:dev liftis off by default as a build is;--fp-nan-midturns it on;--no-fp-nan-midis kept.stages.rs,lift/src/whole/tests.rs,dev/lift_cmd.rs; doc comments insem/src/fpfast.rs,dev/words.rs,tests/test_lifter_semantics.py; docs indocs/dev/reference/build.md(the switch row is nowLONGSHOT_FP_NAN_MID=1) andbuilder.md.A cost on the update: the lifter's key moves (
LIFTER_SOURCEShashes the lift crate's sources), so every player's units lift again. Their stores hold the cold units' objects of the same IR, so the new work is compiling the 122 hot units: measured 712 CPU-seconds on a pre-#2684 build (the longest unit 30.8 s), about 1 minute on 16 threads, an estimated 3–4 minutes on 4 cores. No file of the shader stamp changes: the shader caches stay valid.Testing
Tested: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2.
In the game, a player's build with the new default (no switch set): Market child, Fire Temple, Lost Woods child (the runs below). The build log shows no middle-path line; the map's hot tier is 41,979,913 bytes, byte for byte the size of a
LONGSHOT_FP_NAN_MID=0build of #2684. Every run played its scene to the end and was admitted by the harness (game clock, no stall rejections).tests/test_lifter_semantics.pyagainst Unicorn (through a Windows port of its runtime; the suite skips it on Windows), default sizes, the fixed NaN cases each time: ok with the default (off) and with--fp-nan-mid, each on x86-64-v3 and plain x86-64 at -O1, and the default at -O2-ffp-contract=off(as the hot units ship) on both. The NaN cases' broken variant (--fp-nan-mid-broken) differs in 56 runs each time, as the test requires.Negative control for the code the default now relies on: a broken exact semantics (
nan_fixwith the operand NaN and the default NaN swapped) fails: 1,537 words differ from Unicorn.Builder, on
8ceba19e(merged with mainb4d56f526), Rust 1.99.1:dev.py cargo -- testfor build-driver (220 unit tests and its integration tests), lift (56), sem (9), llvm (23) and mir (7): all pass;longshot-builder dev::liftpasses;cargo fmt --all --checkclean;cargo clippy -p build-driver -p lift -p longshot-builder -p sem --all-targets -- -D warningsclean.mise run test(the whole suite) not run on this head.mise run lint: passes every hook.On this head (
d023c8bcb, merged with maind6e819e08: 68 commits, none in the lifter's crates, so the numbers below still hold):cargo fmt --all --checkclean, lift's 56 tests pass,mise run lintpasses. On this Windows PC fourlongshot-buildertests (the profile's settings and Streamline choice,dev_runtime) fail at the same lines on maind6e819e08as here, and clippy flags an unused import inbuild-core's Windows sandbox code on main as well; neither is in this change.A second-opinion review (gpt-6.2-sol), three rounds; the last found no defect in the change. One follow-up, older than this PR: a
longshot-builder dev compilerun alone does not check the middle path's setting against the lift's (ascheck_hot_splitdoes forLONGSHOT_HOT_SPLIT), so a developer compiling kept IR with the other setting gets it unchecked. A build lifts and compiles with one setting, so builds don't reach it.Steam Deck OLED (SteamOS 3.9.5, Mesa 26.2.0-devel RADV, stock 15 W): a player's build of this head (
8ceba19e) and of its main (b4d56f52).Not tested: a low-core or Intel CPU (no farm run).
Still to test:
tests/test_lifter_semantics.pyin its default mode, expecting a pass (by hand: CI's Linux job runs it on every push).Measurements
Verdict: with the middle path off, CPU ms per frame −3.0 % in Market child, −2.3 % in Fire Temple, −1.9 % in Lost Woods child (6 pairs); fps +1.9 %, +2.2 %, +0.9 %. All under 5 % with 3 pairs: diagnostic. The one case that is slower: with the native cloth turned off (
HOS_NATIVE_CLOTH=0), Lost Woods child +4.0 % CPU ms (1 pair);LONGSHOT_FP_NAN_MID=1restores it for anyone who runs that way.Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2; the standard test (
std_test.py): uncapped (HOS_FPS_MAX=240), 16:9, render thread on, the camera turning, 20 s window, 3 alternating pairs, the medians; game clock 0.999–1.002 on every run. Before: main694ae5820built as a player's build. After: the same with this change (27776d26d: the branch's commit cherry-picked onto it, the same 9 files), its own builder, no switch set. Lost Woods: #2684'sLONGSHOT_FP_NAN_MID=0on the same base, whose hot tier is identical byte for byte, 6 pairs.694ae5820694ae5820)Steam Deck: no measurable change in fps or CPU; CPU ms is not higher, as expected.
harness/deck_std_test.py): Market child, uncapped (HOS_FPS_MAX=240), no render thread, 45 s window, 3 alternating pairs, the medians; game clock 0.9995-1.001.b4d56f52and after is this head,8ceba19e(b4d56f52merged in), each built as a player's build.b4d56f528ceba19eRisks
HOS_NATIVE_CLOTH=0) is about 4 % slower in CPU;LONGSHOT_FP_NAN_MID=1at build time brings it back. A revert of this PR is also enough.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2: this change (27776d26d, on main
694ae5820, the same 9 files) built as a player's build with no switch set, run in Market child and Fire Temple (3 standard-test runs each, all admitted, no stall) and Lost Woods child (6 runs, LONGSHOT_FP_NAN_MID=0 of #2684, the same hot code byte for byte)@Beanstalk perf, this PR's head against main (a build-time switch: the PR's build is the new default, main's is the old one). Scene: Market child, then Lost Woods child if time allows. Uncapped: frame_rate_cap = 6, vsync = 2, frame_generation = 0, windowed. 2-3 runs a side, interleaved. Machines: steamdeck first, then a low-core (4-6 core) PC and an Intel CPU if any is online. Compare fps_mean, CPU ms per frame and frametime_p99; run_hitch_count and run_frametime_max_ms report-only. Expecting: not slower than main anywhere (on this PC Market was -3.0 % CPU ms). Note: the update relifts the game and recompiles the 122 hot units once, so the first start after the build is not a measurement.
Beanstalk test farm · an earlier run: commit
8ceba19(the newer results are in a comment below)Commit
8ceba19· approved by klimovich008 (reviewed) · dashboard⚠️ Note: The farm cannot directly measure CPU milliseconds per frame; process CPU seconds are reported but are not equivalent. Small gains near the claimed 3% may be indistinguishable from run-to-run noise.
⚠️ Note: Windowed scenarios cannot capture comparison pictures, and the build-time switch cannot be varied through a runtime matrix; the timed lift builds do not reproduce the specific one-time update cost.
⚠️ Note: The farm cannot designate an extra unmeasured first game start with this windowed scenario; each measured segment instead has a 20-second warm-up.
Started at 2026-12-03 13:33 UTC.
⚠ No tester has a PC for
steamdeck+window(none seen in 14 days): it waits until one signs in.steamdeck+windowwindow+cpu-5600x3d(CPU "5600x3d")window+cpu-i3-8100(CPU "i3 8100")Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
window+cpu-5600x3d, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'swindow+cpu-i3-8100, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'sWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)The plan compares the PR’s default build with main in child Market and Lost Woods, using three interleaved starts per side and 30-second uncapped measurements in a window. It targets Steam Deck, a six-core PC, and an Intel CPU; the Steam Deck target will wait for a matching window-capable tester. It reports FPS, frame-time tails and hitches, and times the lift builds separately. Crashes, a frame-time regression over 15%, or an FPS regression over 10% fail the plan. No tester online now matches steamdeck+window: that target waits for one.
market-entrance(settings vsync=2, fullscreen=0, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switchesHOS_OUTPUT_RES=1280x720,RX_VK_AUTO_TUNE=0; in a hidden window (the present path runs)), then teleport to Market, measure market for 30 s (after 20 s warm-up), teleport to Lost Woods, measure woods for 30 s (after 20 s warm-up); 3 runs on each side.Measurements on `window+cpu-5600x3d`, for the PR description
Verdict: queued on window+cpu-5600x3d (1 report).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+window+dlss+xess
NVIDIA GeForce RTX 3070, 621.35.0AMD Ryzen 5 5600X3D 6-Core Processor, 32 GB RAMScene: market-woods, from the repository's save market-entrance (vsync=2, fullscreen=0, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-woods: 3 game starts a side, market 30 s after 20 s warm-up, woods 30 s after 20 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
b4d56f58ceba19Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `window+cpu-i3-8100`, for the PR description
Verdict: queued on window+cpu-i3-8100 (1 report).
Hardware: 1: windows+intel+intel-proprietary+igpu+window
Intel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMScene: market-woods, from the repository's save market-entrance (vsync=2, fullscreen=0, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-woods: 3 game starts a side, market 30 s after 20 s warm-up, woods 30 s after 20 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
b4d56f58ceba19Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
window+cpu-5600x3dNVIDIA GeForce RTX 3070, 621.35.0AMD Ryzen 5 5600X3D 6-Core Processor, 32 GB RAMwindow+cpu-i3-8100Intel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMTested on a Steam Deck OLED (stock 15 W). The farm's steamdeck runner errors on main's
tools.lock, so I ran this one by hand.b4d56f52.CI: Host C for Windows, Rust and Website fail here exactly as on #2784, a diff that shares no file with this one; details in #2784's comment. They look like main's.
Beanstalk test farm
Commit
d023c8b· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.WIP: perf(lift): the float slow paths' middle path off by default; LONGSHOT_FP_NAN_MID=1 brings it backto perf(lift): the float slow paths' middle path off by default; LONGSHOT_FP_NAN_MID=1 brings it backRecommendation: Approve. The code is ready: only testing is left. The hot units are 28.4% smaller, but the reported gameplay timing differences are within the run-to-run spread. The update also requires recompilation, whose effect on total build time has not been compared against main. Recommend approval; not approved on the forge.
The builder disables the float NaN middle path by default while retaining an opt-in switch. This reduces measured hot-unit code from 58.6 MB to 42.0 MB, at the cost of relifting and recompiling hot units on update; its gameplay performance benefit remains unproven.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/build-driver/src/stages.rs:339: The claimed gameplay speedup is smaller than the observed variation, so the new default's performance benefit is unproven. (more on the line) Do: Run additional alternating main-versus-head measurements in the affected scenes, including an Intel or low-core CPU, and report CPU time and frame-time distributions.builder/crates/lift/src/whole/mod.rs:139: The change invalidates the lifter key and recompiles hot units, but the reported compiler CPU seconds do not establish its effect on players' total build time. (more on the line) Do: Measure clean and one-function-change build time and output size on main and this head, including an update from a current build and a low-core machine. (@fixdoes its part first: Avoid invalidating lifter source keys for changes that do not alter generated IR, if the key can safely distinguish them.)@fixcan do L2.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for gameplay performance: the reported Windows CPU-time improvements are 1.9–3.0%, with overlapping or variable runs, and the Deck difference is within noise. The map reports a definite 16.7 MB reduction in hot-unit code, but total clean and incremental build times were not compared.
Other systems: The generated CPU code runs on Windows and Linux regardless of GPU. Windows AMD and Steam Deck gameplay were tested; low-core and Intel CPUs were not. The exact fallback was checked against Unicorn as reported, and the shader cache is unaffected by the changed files.
Switches: LONGSHOT_FP_NAN_MID changes from on to off by default; 1, on, yes or true enables it. LONGSHOT_FP_NAN_MID_SKIP is now read only when the middle path is enabled. The developer lift flags retain explicit on and off choices. The default's gameplay performance advantage is not yet established.
Reviewed:
d023c8bcbaagainstd6e819e084: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the diff, commit history, changed option wiring and its cache-key and caller context; inspected the changed tests and documentation. Skimmed the unchanged portions of the larger lift, semantics and test files. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no commands from the project or tests were run. The reported Linux semantics run and head CI remain pending.
Overlaps and merge order: Not checked; network access is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as klimovich008 took it out of WIP. Nothing was run; a maintainer decides.
@ -334,1 +336,4 @@/// Whether `LONGSHOT_FP_NAN_MID`'s value `v` turns the middle path on: only an on word ([`build_core::switch`]: `1`,/// `on`, `yes`, `true`). Unset, an off word or any other value is off, the default since 2026-11-29: measured then, the/// middle path no longer paid where the game's cloth runs natively (#2036), and it was 28 % of the hot units' code.fn fp_nan_mid_on(v: Option<&str>) -> bool {L1 (should fix): The claimed gameplay speedup is smaller than the observed variation, so the new default's performance benefit is unproven.
When: On Windows, Market pairs range from 6.0% faster to 0.8% slower in CPU time; Deck results likewise show no measurable gain. Players on other CPU architectures may see a different instruction-cache versus helper-call tradeoff.
Do: Run additional alternating main-versus-head measurements in the affected scenes, including an Intel or low-core CPU, and report CPU time and frame-time distributions.
@ -137,3 +137,3 @@mark_each: false,no_simplify: false,fp_nan_mid: Some(BTreeSet::new()),fp_nan_mid: None,L2 (should fix): The change invalidates the lifter key and recompiles hot units, but the reported compiler CPU seconds do not establish its effect on players' total build time.
When: An existing installation updating to this version relifts and recompiles hot units; a low-core machine can wait several minutes according to the estimate, without a measured main-versus-head wall-time comparison.
Do: Measure clean and one-function-change build time and output size on main and this head, including an update from a current build and a low-core machine.