test: the hot pieces' split and -O1 against -O2 compute the same, game-free #1142
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1142
Loading…
Reference in a new issue
No description provided.
Delete branch "Marcuss2/Longshot:test/exactness-hot-split"
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?
Type: test · Risk: low · Tested on: Linux (game-free checks only; nothing here runs the game) · Needs: none
Why
Two codegen changes are being prepared for the build and neither may change what the game computes:
A64_HOT_FUNCSlist,code_hot*.cholds the hot functions togetherat
RX_HOT_OPT(-O2). One of them,f_81b8c000, is a 4.79 MB translation unit that takes 346 s. The lifted chunksalready have the fix (
LONGSHOT_SPLIT_GIANTS,nx2/split_giants.py: a function ofMIN_KB(256 KB) or more is cut at itstop-level labels into pieces plus a dispatcher); the hot pieces' flags (
nx2/build.pyhot_fl) never got it.split-giantsis adding it, which takes a from-scratch build from 7:13 to 3:17.
-O2instead of-O1with the lightpasses (
build.LIGHT_FLAGS), and that must not change the computed result either.Neither change is worth landing on a hunch. The split mechanism's own exactness is already proven by
tests/test_split_giants.py; what was missing is (a) the same proof down the hot pieces' path at-O2, and (b) thatraising the level from
-O1+ light passes to-O2computes the same thing. That is this PR: a second check that reusesthat harness rather than writing one.
What changed
tests/test_opt_level_exactness.py(new, one file, no production code touched):Hot + split (
hot_split_check). A giant lifter-shaped function (test_split_giants.big_source, 416 KB, pastsplit_giants.MIN_KB) is compiled twice throughnx2/build.py'scompile_one, exactly as the build compilescode_hot_0.c:-O2, built the waybuild.py'shot_flis);split_giants.FLAG, socompile_onecompilessplit_giants' copy — cut attop-level labels into
static __attribute__((noinline))pieces and a dispatcher under the function's own name. The checkalso asserts the object really holds the pieces (
s_00002000_) and thatcompile_oneremoved the split copy.Both objects go into
test_split_giants'DRIVER, which runs them from 300 randomCtx/guest-memory states and comparesevery byte of the context, the whole guest window, the page marks, the calls out (each with a hash of the context), the
setjmp resumes and the interrupt polls.
-O1 with LIGHT_FLAGS vs -O2 (
opt_level_check). The same function (240 blocks, 161 KB) is compiled into two programs —one translation unit at
-O1+build.LIGHT_FLAGS, one at-O2, each linked with the harness's driver at the harness'sown flags. The driver (
DIGEST, derived fromtest_split_giants.DRIVER's text so the guest model, page marks, event logand host setjmp/longjmp are the same) runs one function from the same 300 states and prints an FNV-1a 64 digest of the final
context bytes, every guest-memory byte, the page marks, the event log, the polls, the setjmp resumes and the setjmp stack's
depth. The two executables' lines must be equal, and the check also requires the poll and event counts to be non-zero so a
digest cannot match because nothing ran. A compiler that does not take
LIGHT_FLAGS(-opt-disableis LLVM 22's;build.light_flags_work) still gets the-O1against-O2comparison and says so in its output.It is discovered by
tests/run_all.pyon its own (tests/test_*.py), and declaresRUN_ALL_ARGS = ["--cc", "clang"]so therunner skips it where clang is missing and
--strictfails it instead, liketests/test_split_giants.py.tests/test_split_giants.py,nx2/build.pyandtests/test_lifted_flags_safe.pyare untouched.Measurements
Verdict: nothing to measure: this PR adds a game-free check and changes no code the game runs; the check's own run, and the full suite's, are in Testing.
Flags and settings
None: a test only, no switch, menu row, ini key or build flag.
Testing
Tested: on this PC (Linux, no GPU needed):
825e022bpython -I -B tests/test_opt_level_exactness.py --cc clangpython -I -B tests/run_all.py(Linux)The exactness lines the check prints:
The two levels' objects are genuinely different code, so the matching digest is not a comparison of the same object:
74784 bytes at
-O2against 78704 bytes at-O1+LIGHT_FLAGSfor the same 161 KB source (sha1b4b8bc945164vs8c1ee83319cf).The 17 failures are the known environmental ones that also fail on main @
71b1edd8:test_audio_output_devices,test_bug_report,test_bug_report_defaults,test_crt_options,test_dlss_feature_size,test_failed_compile_keeps_objects,test_guest_imported,test_hardware_report,test_linux_preflight,test_linux_update,test_make_game_cache,test_missing_nup,test_mods_size_table,test_pending_guest_import,test_run_all_changed,test_vk_occlusion_queries,test_walk_key.What the two checks do and do not prove, plainly:
hot pieces compiled at
-O2and cut at their labels bysplit_giantscompute exactly what the whole-O2functioncomputes — every register, every guest byte it writes, every page mark, every call, every setjmp resume and every interrupt
poll, from 300 random states. And
-O1with the light passes and-O2compute the same thing over the same 300 states.tests/test_split_giants.pycovers the real lifter's output, notthis one); the FP shapes (this function is the integer and guest-memory shapes; no FP helper is called); that
nx2/build.py'shot_flactually carries the split flag on its own (the flag-surface check on the split PR covers that —this test passes the flag itself, so it does not fail on main for the missing flag and is not a replacement for that
check); other compilers and CPUs.
-O2) each need their own game runbefore they land, which is theirs to do, not this test's.
Not tested: the game and any GPU path: this PR adds no code the game runs.
Must be tested: None.
Risks
What could break: nothing the game runs; a new check in the suite (3-13 s) only. If
split_giantsor the flags change, thischeck fails, which is its job.
Turning it off: revert the commit.
Compatibility: Nothing changes.
Checklist
Everyone
type(scope): description) of the status line's type.opt-budget work is tracked on the team board).
main(71b1edd8).python -I -B tests/run_all.pypasses (the 17 failures that also fail onmainare named above).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened (none of the existing checks readsthis file;
tests/test_split_giants.pyis reused, unmodified).Possibly related, for context:
WIP: test: the hot pieces' split and -O1 against -O2 compute the same, game-freeto test: the hot pieces' split and -O1 against -O2 compute the same, game-freeab31cdacfb825e022be6The hot pieces' flags are now built at -O2 unconditionally in the check (not from RX_HOT_OPT), so an environment that sets RX_HOT_OPT cannot change what the check compares; amended to
825e022b. Re-ran the full suite: 587 passed, 17 failed (the same known environmental failures as main @71b1edd8, none of them this check), 74 skipped in 59 s; tests/test_opt_level_exactness.py passes in 5.2 s.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.