perf(builder): a float operation with a NaN lane and no subnormal lane is answered inline by default (LONGSHOT_FP_NAN_MID=0 turns it off) #2684
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!2684
Loading…
Reference in a new issue
No description provided.
Delete branch "klimovich008/Longshot:perf/fp-nan-mid"
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: where the game's float vectors carry a NaN in one lane (the cloth keeps one in its vectors' fourth lane: Lost Woods first), every add, multiply or subtract on them leaves the fast path for the exact helper, a
noinline coldcall. In Lost Woods child that helper was 6 % of the process's CPU samples. This answers most of those operations inline, on by default;LONGSHOT_FP_NAN_MID=0at build time turns it off.What changed: by default (
LONGSHOT_FP_NAN_MIDunset, or1), the slow path of a float add, subtract, multiply, divide, FMULX or fused multiply-add in a hot unit (lifted_hot_*) gets a middle path. When a lane is a NaN and no operand lane and no lane of the fast value is subnormal, every flush in the exact semantics is the identity, so the exact result is the host's operation with Arm's NaN choice applied. That is computed inline. A subnormal lane still takes the full helper, as today. WithLONGSHOT_FP_NAN_MID=0, the emitted IR and the lift keys are byte-identical to main's.Files, in reading order:
builder/crates/sem/src/fpfast.rs:nan_mid(and the hiddennan_mid_brokenfor the negative control). The test classifies each f32/f64 operand lane and each lane of the fast value as subnormal or not. The value is the helper's ownSem::exact(farith/fmulx/fmuladdwith the samenan_fix) with FZ held clear and DN read from FPCR, so the NaN choice (a signalling operand first, in operand order, quieted; the addend first for fused; the default NaN for an invalid operation or under DN) matches the helper by construction.builder/crates/mir/src/lib.rs,mir/src/verify.rs:Helper.mid: Option<Box<Mid>>(the middle path belongs to the helper, so noOp::Checkedpattern changes); the verifier checks its signatures, names, pure bodies, and refuses a table lookup inside one, a test and value with the same name, or two same-named helpers with different bodies.builder/crates/llvm/src/lib.rs: the slow path calls the test and branches (the full helper weighted unlikely) to the inline value or the helper; a three-input phi joins them. The test reads its values through an emptyasm "", "=x,0"so LLVM keeps the cold test's classifications apart from the fast path's merged check. A third counter,lifter_mid_checks, besideLONGSHOT_COUNT_CHECKS's two. Off, nothing new is written.builder/crates/lift/src/whole/mod.rs:LiftOptions::fp_nan_mid, applied to hot units only, minus the skip list; in each hot unit's key (the switch and the skip entries among that unit's own functions) and in the whole lift's key, never in the other units' keys, so turning it on or off moves only the hot units' keys (BeanBot L1; 122 of 386 in the whole game); the log line counts the fast paths given a middle path.builder/crates/build-driver/src/stages.rs,build.rs: the switches, read by value (build_core::switch: unset or any value but an off word is on); a malformed skip list stops the lift and a compile alone the same way.builder/crates/longshot-builder/src/dev/{words,lift_cmd}.rs:dev words --fp-nan-mid/--fp-nan-mid-broken,dev liftwith the middle path by default, as a build;--no-fp-nan-midlifts without it,--fp-nan-mid-skipleaves functions out (--fp-nan-midis kept and is the default).tests/test_lifter_semantics.py,tests/lifter_semantics_rt.c: fixed NaN cases (always, CI included),--fp-nan-mid,--march.sem/src/tests.rs,llvm/src/tests.rs,lift/src/whole/tests.rs; docs indocs/dev/reference/builder.mdandbuild.md.Flags and settings:
LONGSHOT_FP_NAN_MID: build time, on by default, read by value as the builder's other switches (build_core::switch):0,off,no,falseor empty turn it off (the kill switch: the IR and keys are main's); unset,1or any other value is on. On, it is in each hot unit's key and the whole lift's key, not in the other units' keys.LONGSHOT_FP_NAN_MID_SKIP=f_<hex>,...: a developer's list of functions left out of it (hex,f_or0xprefixes). A malformed or non-Unicode list with the switch on (the default) stops the build; with it off, the list is not read. A change to the list moves only the keys of the hot units whose functions it adds or removes.switches.def. The launcher sets neither.Vectors only, an offer: of the 66,397 middle paths in the hot units, 36.8 % are on vectors and 63.2 % on scalars. The cloth's NaN lane is a vector lane. A vectors-only variant would drop about 60 % of the added code and most of the extra compile CPU, probably at little cost to the gain. Not measured: the counters don't split scalars from vectors. I can add it if the builder's owner prefers that shape.
Testing
The default flip itself was not retested. Every measurement and game run below is of a build with
LONGSHOT_FP_NAN_MID=1, which the default now gives (the unit tests below check that unset reads as1does, and0as off). No whole-game lift, game run or second-opinion review was done on the flip.Tested: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2. The game runs used a build from this branch's first round (
a03c59a6e) on main09dea503. The head's emitted IR is byte-identical to that commit's in every mode, so those runs stand for the head (see "Exactness" below).Exactness:
tests/test_lifter_semantics.pyagainst Unicorn (Windows port of the test, default sizes): passes off and on,--march x86-64-v2andv3, at -O1, and on at -O2 with-ffp-contract=offas hot units ship. Each run: 126,846 single-word runs, 2,988 edge states, 11,066 sequence runs, and 1,408 fixed NaN-case runs (352 cases under all four FZ/DN settings; 952 slow, 724 middle path). The NaN cases cover each kind in each shape (vector .4s/.2s/.2d, by-element, scalar s/d/h): one quiet NaN lane beside finite ones, NaNs in both operands (payload order, the addend first), a signalling NaN behind a quiet one, a NaN in the second lane alone of either operand, invalid operations with no NaN operand (inf×0, inf−inf, inf/inf, 0/0, FMULX's ±2, a quiet-NaN addend with inf×0), signed zeros, subnormals beside a NaN lane (operand and result). The test fails unless the fast, middle and full paths all ran.LONGSHOT_FP_NAN_MID=0is byte-identical to main (measured with the switch off on the earlier head, when off was the default):dev wordsover 118,829 words, 4,000 sequences and the 32 NaN-case words gives the same 73,557,937 bytes plain and 74,390,314 with--count-checksas main's builder. A whole-game lift with the switch off: 386 of 386 units with the same content as main's. On: 114 of 122 hot units change, no other unit.0b01c7a9d, merged with main20bedc6da; Windows, Rust 1.99.1), the tests it edits or adds only:cargo test -p lift48 passed; build-driver'sstages::tests 3 passed (new:the_float_middle_path_is_on_when_its_switch_is_unset_and_off_when_it_is_0); longshot-builder'sdev lifttest 1 passed (new). Each fails when the default is put back to off, four ways (the switch's rule, the skip list's Unicode check,LiftOptions::new,dev lift's start).cargo clippy --locked -p build-driver -p lift -p longshot-builder -p sem --all-targets -- -D warningsclean (the crates the flip touches; workspace clippy not run);cargo fmt --all --checkclean;mise run lintpasses every hook. The crates' full suites were not run again.699405ecb):cargo test --locked --no-fail-fast -p mir -p sem -p llvm -p lift: 81 passed, 0 failed, all middle-path tests among them.tests/run_all.py --jobs 4(Windows, llvm-mingw 20261104) on the merge with main2e02c0d66and on that main (before #2680 landed, which changes the builder's progress reports only): 719 passed, 14 failed, 128 skipped on both. The same 14 files fail on both (Windows-environment tests:test_longshot_ctl,test_job_queue,test_dev_ab,test_parity_gates,test_run_all_mingwand others; none touches the builder's lifter). One extra sub-check intest_parity_gatesfailed on the merge only, "path is on mount 'E:', start on mount 'C:'": the merge's checkout was on another drive than the temp folder, main's was not.test_lifter_semantics.pyis skipped on Windows by design; the matrix above ran through a Windows port of it.Still to test:
tests/test_lifter_semantics.pywith and without--fp-nan-mid, expecting a pass as on Windows (CI's Linux job runs the default mode;--fp-nan-midby hand).-march=native): build withLONGSHOT_FP_NAN_MID=1and play Lost Woods child, expecting the cloth as on main and no new error line (by hand; here the asm was only compiled for x86-64-v4, not run).LONGSHOT_FP_NAN_MID=1 RX_MARCH=x86-64-v2in Lost Woods child and Market child, expecting the cloth as on main and Market not slower (by hand; the semantics test passes at v2).Measurements
Verdict: with the switch on, Lost Woods child: CPU per frame −3.2 % and fps +4.5 % (best estimate about −3 % CPU over both sessions); Market child: not worse. All "diagnostic" (under 5 % with 3 pairs).
Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2;
claude-perf/std_test.py, uncapped (HOS_FPS_MAX=240), 16:9, render thread on, 3 alternating pairs, the median; game clock 0.993–1.011 on every reading. Before: main09dea503built as a player's build. After: the same with this branch (a03c59a6e, whose IR the head reproduces byte for byte) built withLONGSHOT_FP_NAN_MID=1. Switch off, the build is main's.09dea503a03c59a6e09dea503a03c59a6eFps was higher with the switch in all 6 Lost Woods pairs over both sessions. An earlier run by the implementer gave −5.6 % CPU; the checker did not reproduce it.
Why these numbers still hold on current main: they were taken on main
09dea503. Since then main has not changed the lifter (builder/crates/{sem,mir,llvm,lift,passes},third_party/a64-kit), and this head's builder emits byte-identical IR to the measured commit's, off and on. Main's other changes since (the mutex lookups of #2665, a renderer fix for GCN, startup reporting, a game fix ingame/) apply to both arms alike. Not measured again on current main.No Test Farm run. With the default on, a farm comparison of this PR against main would measure the
LONGSHOT_FP_NAN_MID=1build above; none was run.Costs, with the switch on (now the default; stated plainly):
09dea503a03c59a6e.textbytes.textbytesNon-hot units are byte-identical either way. The extra register saves are on the fast path's prologue; Market showed no slowdown from them on this CPU, and v2 was not measured in the game. A full cold build was not timed.
Risks
LONGSHOT_FP_NAN_MID=0the IR and keys are main's.LONGSHOT_FP_NAN_MID=0turns it off for a build, the skip list for single functions. Linux, AVX-512 and x86-64-v2 in the game are still untested (Still to test). The inline asm is x86-64 ("=x,0"); the builder has no other host target.LONGSHOT_FP_NAN_MID=0for a build; or revert (no data or format depends on it).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, a build of this branch's first round (
a03c59a6e, whose emitted IR this head reproduces byte for byte) on main09dea503with LONGSHOT_FP_NAN_MID=1: Lost Woods child and Market child (3 alternating pairs each against main, uncapped), Kokiri Forest (Link's cap and tunic hang as on main), Fire Temple. Pictures normal; no error line appeared only with the switch on (8 runs a side). The Kokiri children's cloth was not seen.@review
Recommendation: Request changes. The opt-in path shows a Lost Woods gain on the tested Windows PC, but its cache key invalidates units whose output cannot change. The enabled path also needs the outstanding Linux and CPU-target runs before merge.
The builder can inline the NaN slow path in hot units when explicitly enabled. The reported gain comes with a 36% increase in hot-unit compile CPU time and a 40% increase in their object text size.
Blocking (1): must change before merging.
builder/crates/lift/src/whole/mod.rs:198: The option and entire skip list enter the base key shared by every unit, including units whose generated text cannot change. (more on the line) Do: Put the effective option and the relevant skipped entries into each affected unit's key, leaving unaffected units' keys unchanged.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/llvm/src/lib.rs:1333: The enabled path has not been run on Linux or on an AVX-512 CPU, and the x86-64-v2 game run is still outstanding. (more on the line) Do: Run the semantics test on Linux and the specified Lost Woods and Market game checks on x86-64-v2 and an AVX-512 CPU; compare the cloth and error logs with the base.builder/crates/lift/src/whole/mod.rs:560: The reported compile cost covers hot units, not a clean game build or an incremental build after one function changes. (more on the line) Do: Measure clean and one-function-change build time and size against the base with the switch enabled. (@fixdoes its part first: Restricting the middle path to vector operations could reduce generated code and compile work; its effect needs measurement.)@fixcan do L1 and L3.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: 9 checks.More: does it help, other systems, switches, what was read
Does it help: Yes, on the reported Windows Ryzen 7 5700X3D run: three alternating pairs in Lost Woods showed median CPU time per frame falling from 42.153 to 40.808 ms and fps rising from 116.29 to 121.54. The earlier session showed a smaller gain; current main and other CPU targets have not been measured in game.
Other systems: The default is off. When enabled, the generated floating-point path can affect Windows and Linux and different x86-64 CPU targets. The reported Windows semantics and game runs cover one CPU; Linux, x86-64-v2 in game, AVX-512 execution and the Kokiri children's cloth remain untested.
Switches: LONGSHOT_FP_NAN_MID defaults off and enables the path only for value 1. LONGSHOT_FP_NAN_MID_SKIP defaults to an empty list and excludes named functions when enabled. The developer commands also add --fp-nan-mid, --fp-nan-mid-broken and --fp-nan-mid-skip. The off default limits the unmeasured costs while the remaining runs are outstanding.
Reviewed:
238c600160against699405ecba: Read AGENTS.md, CONTRIBUTING.md, the pull request template and standards; inspected the diff, focusing on the changed semantics, LLVM emission, verifier, lift cache, driver options and test changes. The full changed files and all surrounding callers were not read in full; the full diff output was truncated. The review checklist file was absent. No generated files or translations changed. Commit history was skimmed.; nothing run (a code review).Checked and fine:
Testing: No commands from the pull request, builds or tests were run, as requested. The assessment uses the author's reported runs and the supplied CI status.
Overlaps and merge order: Not checked; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.
@ -189,0 +195,4 @@let mut text =format!("{:?} mark_each={} no_simplify={} split={:?}", o.codegen, o.mark_each, o.no_simplify, o.split);if let Some(skip) = &o.fp_nan_mid {text.push_str(&format!(" fp_nan_mid=1 skip={skip:?}"));L1 (blocking): The option and entire skip list enter the base key shared by every unit, including units whose generated text cannot change. This breaks the repository's rule that a unit's cache key contains only inputs that change its output.
When: Enabling the option or changing one skipped function invalidates every unit's lift key, so even non-hot units and unrelated hot units have their texts made again.
Do: Put the effective option and the relevant skipped entries into each affected unit's key, leaving unaffected units' keys unchanged.
@ -507,6 +557,9 @@ impl Session {if !self.o.no_simplify {simplified += passes::simplify(f);}if mid {L3 (should fix): The reported compile cost covers hot units, not a clean game build or an incremental build after one function changes.
When: With the switch enabled, the measured hot-unit compile CPU rises from 492 to 669 seconds, but its effect on the complete build and incremental workflow is unknown.
Do: Measure clean and one-function-change build time and size against the base with the switch enabled.
@ -1255,0 +1330,4 @@let b = self.temp();self.line(format!("{b} = bitcast {t} {v} to {carrier}"));v = b;}L2 (should fix): The enabled path has not been run on Linux or on an AVX-512 CPU, and the x86-64-v2 game run is still outstanding.
When: A developer enabling the switch on these supported configurations relies on newly emitted inline assembly and floating-point code that has not yet been exercised there.
Do: Run the semantics test on Linux and the specified Lost Woods and Market game checks on x86-64-v2 and an AVX-512 CPU; compare the cloth and error logs with the base.
Thanks. Point by point:
L1 (lift key): agreed, it will be fixed.
docs/dev/standards.mdsays a cache key holds exactly what changes its output, and todaycodegen_textputs the switch and the whole skip list intobase_key, which every unit's key starts from, while only the hot units' text changes. The fix: takefp_nan_midout ofcodegen_text. Alifted_hot_*unit's key gets the switch when it is on, plus the skip-list entries among that unit's own functions. Every other unit's key stays as it is with the switch off. The whole lift's key (whole_key) must still change when the switch flips or the list changes, so that an unchanged gen/ isn't taken for the new lift. The tests inlift/src/whole/tests.rsthat now assert "on moves every key" will change to match: on, only the hot unit's key moves and the cold unit's stays; a skip entry moves only its own unit's key; off again gives the first keys. This is a change to the cache keys, so it goes back through our implementer and checker with its own second-opinion review before I push it. I'll ask for a review again on that commit. Off (the default), no key changes either way, so a player's build is unaffected meanwhile.L2 (Linux, AVX-512, x86-64-v2 in game): open, and listed under Still to test. Not run yet. The switch stays off by default until they have run. Turning it on would be a separate change, and these runs are a precondition for it.
L3 (whole-build and one-function-change cost): not measured, and said so. What was measured: the hot units' compile CPU (+36 %, ABBA, same load), their
.text(+40 %) and the whole exe's.text(+2.24 %). Non-hot units' text is byte-identical. A clean build and an incremental build with the switch on were not timed; I won't estimate them here. I'll time a clean build and a one-function edit against main before anyone proposes turning it on, along with the vectors-only variant offered in the description, which should cut most of that cost.Checks:
Third-party parts and guide screenshotsfails on this head, which is one commit behind main (#2683). I haven't read its log yet; the L1 commit will be pushed on current main and I'll look at that check again there. CI's Rust job should stop at clippy for the reason below. Separately, clippy on the merge stops at main's own threeneedless_borrowerrors inbuilder/crates/build-driver/src/play.rs(503, 521, 522); this PR doesn't touch that file.No Test Farm request on this PR: off by default, its build is main's, so the farm would see no difference.
🤖 L1 (the option in every unit's key): fixed in
e87e3d3be,a9fbea091,d27b46a9dandc35216ebe(headc35216ebe).What changed
codegen_textno longer holdsLONGSHOT_FP_NAN_MIDor its skip list, so the key every unit starts from is the same with the option on or off.lifted_hot_*unit's key holds the switch and the skip-list entries among its own functions (units::plan_with). A hot unit whose functions are all on the list keeps the key it has without the option, as its text is the same.unchanged(), the lift store andTexts::text's check never take a lift made with another setting for this one.build.md,builder.md) now say which keys move: the hot units' when the switch flips, only the affected hot units' when the list changes, no other unit's.Whole game (
longshot-builder dev liftof the same image, off and then on): 122 of 386 unit keys move, exactly the 122 hot units. 114 unit texts change, all hot; no other unit's key or text moves. The off lift's 386 unit texts are byte-identical to the base build's (09dea503), 386 of 386.IR:
dev wordsover 118,829 words, 4,000 sequences and the 32 NaN-case words gives byte-identical output to the PR's first commit's builder in all 5 modes: plain,--count-checks,--fp-nan-mid,--count-checks --fp-nan-mid,--count-checks --fp-nan-mid-broken.Tests (
builder/crates/lift/src/whole/tests.rs)the_float_middle_path_is_off_by_default_in_the_hot_units_and_their_keys_only:codegen_textis the same on and off;a_hot_unit_s_key_holds_which_of_its_functions_the_middle_path_leaves_out, one hot unit of two functions:It fails when the hot unit's key leaves out which functions are skipped (mutant run here).
Results:
cargo test -p lift: 48 passed, 0 failed.cargo fmt --checkis clean andmise run lintpasses.needless_borrowerrors inbuild-driver/src/play.rs. With that lint allowed, clippy on the touched crates is clean.d27b46a9d, the commit before the test-onlyc35216ebe.@review
Recommendation: Approve. The code is ready: only testing is left. The cache-key fix addresses the blocking item, but the enabled path still needs the outstanding platform runs and build-cost measurements. Recommend approval; not approved on the forge.
The opt-in builder switch handles eligible NaN float operations inline. The key change limits invalidation to affected hot units; enabling the feature still increases generated code and compile work.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/llvm/src/lib.rs:1333: The enabled path has not been run on Linux or on an AVX-512 CPU, and the x86-64-v2 game run is still outstanding. When: A developer enabling the switch on these supported configurations relies on newly emitted inline assembly and floating-point code that has not yet been exercised there. Do: Run the semantics test on Linux and the specified Lost Woods and Market game checks on x86-64-v2 and an AVX-512 CPU; compare the cloth and error logs with the base.builder/crates/lift/src/whole/mod.rs:560: The reported compile cost covers hot units, not a clean game build or an incremental build after one function changes. When: With the switch enabled, the measured hot-unit compile CPU rises from 492 to 669 seconds, but its effect on the complete build and incremental workflow is unknown. Do: Measure clean and one-function-change build time and size against the base with the switch enabled. (@fixdoes its part first: Restricting the middle path to vector operations could reduce generated code and compile work; its effect needs measurement.)@fixcan do L3.Since the last review (on
238c600160)Resolved: L1 (The option and entire skip list enter the base key shared by every unit, including units w…)
Still open: L2 (The enabled path has not been run on Linux or on an AVX-512 CPU, and the x86-64-v2 game ru…); L3 (The reported compile cost covers hot units, not a clean game build or an incremental build…)
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: 8 checks.More: does it help, other systems, switches, what was read
Does it help: Yes, on the measured Windows system: the reported Lost Woods session showed median CPU time per frame falling 3.2% and FPS rising 4.5% over three alternating pairs. Hot-unit compile CPU rose 36% and object text size 40%; clean and incremental build costs remain unmeasured.
Other systems: The enabled path has Windows game and semantics-test evidence. Linux, AVX-512 and an x86-64-v2 game build remain untested; the default-off path is reported byte-identical to main.
Switches: LONGSHOT_FP_NAN_MID defaults off and enables the optimization only when set to 1. LONGSHOT_FP_NAN_MID_SKIP defaults to empty and excludes named functions when the optimization is enabled. Keeping the optimization off by default is appropriate pending the outstanding runs.
Reviewed:
c35216ebe8against699405ecba: Read AGENTS.md, CONTRIBUTING.md, the changes since the ledger, whole/units.rs, and the cache-key and unit-generation paths in whole/mod.rs. Skimmed the test and documentation changes, commit list, reported runs and remaining changed-file inventory; the other changed code files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build, run tests or execute project code were run. The author reports passing lift tests and Windows game and semantics runs; CI is still running.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.
Should we enable by default?
WIP: perf(builder): LONGSHOT_FP_NAN_MID=1, a float operation with a NaN lane and no subnormal lane is answered inline, not by the exact helper (off by default)to WIP: perf(builder): a float operation with a NaN lane and no subnormal lane is answered inline by default (LONGSHOT_FP_NAN_MID=0 turns it off)@HumanBean Yes: it is now on by default, in
0b01c7a9d(head0b01c7a9d, merged with main20bedc6da).LONGSHOT_FP_NAN_MIDunset (or1) gives the hot units' float slow paths the middle path.LONGSHOT_FP_NAN_MID=0(oroff,no,false, empty, read bybuild_core::switchlike the builder's other switches) is the kill switch: the IR and the lift keys are main's again.LONGSHOT_FP_NAN_MID_SKIPstill leaves single functions out.LiftOptions::newandlongshot-builder dev liftstart with it on, as a build does.dev lift --no-fp-nan-midlifts without it.1and0reads as off, for the lift and for a compile alone (the_float_middle_path_is_on_when_its_switch_is_unset_and_off_when_it_is_0), plusdev lift's default and the lift crate's default lift. Each one fails when the default is put back to off, which I checked four ways. The edited tests pass, as do clippy on the touched crates, fmt andmise run lint.LONGSHOT_FP_NAN_MID=1builds, which is what the default now gives. Linux, AVX-512 and x86-64-v2 in the game are still open (L2), and so are the clean and one-function build times (L3).@review
Recommendation: Approve. The code is ready: only testing is left. The enabled path shows a Lost Woods gain on one Windows system, but its Linux, AVX-512 and x86-64-v2 game coverage and its whole-build costs remain unmeasured. Those runs matter now that the path is on by default. Recommend approval; not approved on the forge.
The builder handles eligible NaN float operations inline in hot units, reducing exact-helper calls at the cost of larger generated code and longer compilation. The latest change enables that path by default.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/llvm/src/lib.rs:1333: The enabled path has not been run on Linux or on an AVX-512 CPU, and the x86-64-v2 game run is still outstanding. When: A developer enabling the switch on these supported configurations relies on newly emitted inline assembly and floating-point code that has not yet been exercised there. Do: Run the semantics test on Linux and the specified Lost Woods and Market game checks on x86-64-v2 and an AVX-512 CPU; compare the cloth and error logs with the base.builder/crates/lift/src/whole/mod.rs:560: The reported compile cost covers hot units, not a clean game build or an incremental build after one function changes. When: With the switch enabled, the measured hot-unit compile CPU rises from 492 to 669 seconds, but its effect on the complete build and incremental workflow is unknown. Do: Measure clean and one-function-change build time and size against the base with the switch enabled. (@fixdoes its part first: Restricting the middle path to vector operations could reduce generated code and compile work; its effect needs measurement.)@fixcan do L3.Since the last review (on
c35216ebe8)Still open: L2 (The enabled path has not been run on Linux or on an AVX-512 CPU, and the x86-64-v2 game ru…); L3 (The reported compile cost covers hot units, not a clean game build or an incremental build…)
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. Cancelled on this head (no result):PR description / Title and description (pull_request_target). Still running: 8 checks.More: does it help, other systems, switches, what was read
Does it help: Yes, on the measured Windows system: three alternating Lost Woods pairs showed median CPU time per frame falling 3.2% and fps rising 4.5%; a second, slower session showed 1.5% and 1.4% respectively. Hot-unit compile CPU rose 36%, and whole-executable text grew 2.24%.
Other systems: The emitted code affects Windows and Linux x86-64 builds and CPUs using different instruction levels. Windows on Zen 3 was tested; enabled Linux semantics, AVX-512 gameplay and x86-64-v2 gameplay remain outstanding. Kokiri children's cloth was not observed.
Switches: LONGSHOT_FP_NAN_MID is added and now defaults on; 0, off, no, false or empty disable it. LONGSHOT_FP_NAN_MID_SKIP defaults to an empty list and excludes named functions when enabled. Both are documented builder switches; the default's broader correctness and build costs remain to be measured.
Reviewed:
0b01c7a9d6against20bedc6da1: Read AGENTS.md, CONTRIBUTING.md and the pull request template; inspected the default-flip commit, relevant lift and switch paths, the diff statistics, commits, description and comments. The full changed code files, referenced standards and remaining full diff were not read; the review checklist file is absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The author reports Windows game and semantics runs; CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.
WIP: perf(builder): a float operation with a NaN lane and no subnormal lane is answered inline by default (LONGSHOT_FP_NAN_MID=0 turns it off)to perf(builder): a float operation with a NaN lane and no subnormal lane is answered inline by default (LONGSHOT_FP_NAN_MID=0 turns it off)Out of WIP at
0b01c7a9d, as the maintainer asked: on by default,LONGSHOT_FP_NAN_MID=0turns it off. The edited tests pass (lift 48, build-driver stages 3, dev lift default 1), and four ways of putting the default back to off each fail one of them. fmt, clippy on the touched crates andmise run lintare clean. Not retested in the game: the measurements are from=1builds. 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.🤖 Generated with Claude Code
Merged main
d05a0dabainto the branch, which brings in #2700 (the hot split, on by default). Head is now2be149afe, a fast-forward over23e79ee39. The merge had seven conflicts (build.rs, stages.rs, liftwhole/mod.rsandtests.rs,dev lift,dev words,test_lifter_semantics.py), all resolved by keeping both sides. Main has moved six renderer and profile commits sinced05a0daba; they merge cleanly and are not in this merge.How the two switches combine
LONGSHOT_FP_NAN_MIDandLONGSHOT_HOT_SPLITare each on when unset and off at0/off/no/false/empty, independently. Each has its own skip list. Both are read inlift_options_from.hot_split/hot_split left out). The middle path's part is in the unit's key (fp_nan_mid=1 left_out=[...], or nothing when every function is left out).codegen_textholds neither.gen/lift.keykeeps thehot_split skipline.longshot-builder compileon its own still checks it before making texts, and makes texts only for Game/GameOnly.dev lifthas both sets of flags.dev wordsand the semantics test have both modes, and the test's NaN-case modules are built with--hot-flagsand--hot-splittoo.the_middle_path_and_the_hot_split_are_each_in_the_hot_units_keys_on_their_own:What ran (Windows 11, Rust 1.99.1, llvm-mingw clang 23.1.5; no game runs and no whole-game lift)
cargo fmt --all --check: clean.cargo clippy --workspace --all-targets -D warnings: clean.cargo test --no-fail-fastof lift, llvm, build-compile, build-driver and longshot-builder, includingtests/hot_split.rs(6/6):d05a0daba, with nothing failing only on the branch;a_lifted_unit_s_text_made_on_demand_compiles_…, passed on the branch;tests/run_all.py test_lifter_semantics:lifter_semantics_rt.cneedssys/mman.h, and the check is marked Linux-only);--fp-nan-mid; and--fp-nan-mid --hot-flags --hot-split;mise run lint: passes.🤖 Generated with Claude Code
@review
Recommendation: Approve. The code is ready: only testing is left. The reported Windows measurements show a Lost Woods improvement, but the outstanding platform runs and full-build costs remain unknown. CI is also still running. Recommend approval; not approved on the forge.
The builder answers eligible NaN-containing float operations inline in hot units. The reported gain is accompanied by larger generated code and longer hot-unit compilation.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/llvm/src/lib.rs:1333: The enabled path has not been run on Linux or on an AVX-512 CPU, and the x86-64-v2 game run is still outstanding. When: A developer enabling the switch on these supported configurations relies on newly emitted inline assembly and floating-point code that has not yet been exercised there. Do: Run the semantics test on Linux and the specified Lost Woods and Market game checks on x86-64-v2 and an AVX-512 CPU; compare the cloth and error logs with the base.builder/crates/lift/src/whole/mod.rs:560: The reported compile cost covers hot units, not a clean game build or an incremental build after one function changes. When: With the switch enabled, the measured hot-unit compile CPU rises from 492 to 669 seconds, but its effect on the complete build and incremental workflow is unknown. Do: Measure clean and one-function-change build time and size against the base with the switch enabled. (@fixdoes its part first: Restricting the middle path to vector operations could reduce generated code and compile work; its effect needs measurement.)@fixcan do L3.Since the last review (on
0b01c7a9d6)Still open: L2 (The enabled path has not been run on Linux or on an AVX-512 CPU, and the x86-64-v2 game ru…); L3 (The reported compile cost covers hot units, not a clean game build or an incremental build…)
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.More: does it help, other systems, switches, what was read
Does it help: Yes on the measured Windows system: median Lost Woods CPU time fell 3.2% and fps rose 4.5% over three alternating pairs; another session showed a 1.5% CPU reduction. Hot-unit compile CPU rose 36% and whole-executable text size rose 2.24%, according to the pull request.
Other systems: The emitted code affects Windows and Linux and multiple x86 CPU levels. Windows semantics and game runs are reported; Linux, AVX-512 and x86-64-v2 game coverage remain outstanding. The merged hot-split interaction has a reported Windows semantics run.
Switches: LONGSHOT_FP_NAN_MID defaults on; off words disable it. LONGSHOT_FP_NAN_MID_SKIP excludes selected functions when enabled. The default has a measured benefit on one Windows system, but its broader platform coverage and build costs remain open.
Reviewed:
2be149afeeagainstd05a0dabae: Read AGENTS.md, CONTRIBUTING.md, the pull request template and the diff since the ledger head. Skimmed the reported runs and changes relative to base; did not read every changed code file in full or all referenced repository rules.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The reported merged-head Windows tests pass the middle-path and hot-split cases; CI is still running.
Overlaps and merge order: None established from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.