WIP: perf(build): optimize shared A64 helpers independently of cold chunks #756
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!756
Loading…
Reference in a new issue
No description provided.
Delete branch "siantm/Longshot:perf/shared-a64-helpers-o2"
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: perf · Risk: medium · Tested on: Windows 11, Python 3.12.10, game-free build/cache planning · Needs: interleaved same-scene gameplay A/B, compile timing, executable size, and Linux game-free suite
Why
Shared instruction and runtime helpers (
a64_rt.canda64_suyu.c) are small helper translation units rather than giant lifted game chunks, so they can be optimized at-O2independently without imposing-O2compile cost or memory spikes on coldcode_*.cchunks (-O1) and without invalidating lifted C caches. Because current-main in-game frame-time/compile-time A/B benchmarks are still pending, this PR staysWIP:until isolated same-scene measurements confirm a benefit.Searching the issue tracker and PR history (
a64_rt,a64_suyu) found no matching performance issue; related build-flag/cache context appears in#980,#979,#911,#737,#177,#172,#62, and mergedLONGSHOT_LIGHT_PASSES.What changed
Optimize
a64_rt.canda64_suyu.cat-O2by default innx2/build.py(withRX_A64_RT_O2=0restoring the cold-code-O1level), keepRX_A64_RT_O2compile-only innx2/make_game.pyso switching it does not retranslate the game, and add a real build-planner/object-key test reconciled withLONGSHOT_LIGHT_PASSES.nx2/build.py: adda64_rt_flags(fl)readingRX_A64_RT_O2(default on ->-O2, falsy ->-+OPT), routea64_rt.canda64_suyu.cthrougha64_rt_flvia optionala64_rt_fl=Noneonsource_flags(...)(preserving existing 7-arg callers such astests/test_light_passes.py), log the chosen level inmain(), and leave cold chunks (split_fl/LIGHT_FLAGS),code_hot*, and other files unchanged.nx2/make_game.py: add"RX_A64_RT_O2"toCOMPILE_ONLY_ENVso toggling it never invalidateslift_key.tests/test_a64_helper_build_flags.py: drive realbuild.main()/plan_jobs()/object_keyacross--dllandLONGSHOT_LIGHT_PASSESvariants, default vs falsyRX_A64_RT_O2values, andRX_HOT_OPT/RX_PGOisolation (preserving-O1and verifyingLIGHT_FLAGSnever leaks intoa64_rt.c/a64_suyu.c), with--sourceoverride (LONGSHOT_BUILD_TEST_SOURCE) for before/after verification.docs/development.md,docs/tested/2026-11-15-a64-helper-o2-siantm-check01.md: documentRX_A64_RT_O2=0(noting current-main A/B measurements remain pending) and keep the initialcheck01run record.Measurements
Verdict: game-free compiler job selection, fallback (
RX_A64_RT_O2=0),LIGHT_FLAGSisolation, and object-key isolation are verified onmain @ 71b1eddvs this branch (acd64056); current-main gameplay FPS, frame-time, compile-time, and binary-size A/B measurements remain pending (WIP:).Hardware: Windows 11, Intel Core i7-9700, 31.8 GiB usable RAM, Python 3.12.10, MSYS2 UCRT64 Clang 23.1.4 (also initially checked on
9e6f231dwith Python 3.14.7 indocs/tested/2026-11-15-a64-helper-o2-siantm-check01.md); no GPU used.Scene: Game-free authored build-planning fixtures on Windows 11 (in-game scene A/B pending before
pr ready).Method: identical authored
tests/test_a64_helper_build_flags.pyplanning/key checks againstorigin/main(71b1edd) and rebased commitacd64056, plustest_light_passes.py,test_lift_cache.py,test_build_hash_cache.py,test_build_times.py,test_kept_translation.py, andtests/run_all.py --changed origin/main. No compiler or game executable was launched bytest_a64_helper_build_flags.py.How to reproduce: compare
origin/main:nx2/build.py(71b1edd) viaLONGSHOT_BUILD_TEST_SOURCEagainstHEAD:nx2/build.py(acd64056) usingpython -I -B tests/test_a64_helper_build_flags.py, then runpython -I -B tests/test_light_passes.pyandpython -I -B tests/test_lift_cache.py.71b1eddacd64056test_a64_helper_build_flags.py(3 planning tests)FAILED (failures=9): helpers stay-O1)Ran 3 tests in 1.579s,OK)a64_rt.c/a64_suyu.cflags-O1-O2(with or withoutLONGSHOT_LIGHT_PASSES/--dll)RX_A64_RT_O2=0and cold/hot job isolation-O1-O1; only the 2 helper object keys changeWIP:)Flags and settings
Adds
RX_A64_RT_O2(default enabled,0/false/off/norestores-O1) so shared A64 helpers optimize independently of cold lifted chunks whileRX_A64_RT_O2=0gives a clean one-variable A/B and rollback toggle.RX_A64_RT_O2-O2vs coldOPT) ofa64_rt.canda64_suyu.c(nx2/build.py)-O1(switch absent)-O2);=0builds at-O1(compile-only inCOMPILE_ONLY_ENV)code_hot*stay unchangedmain; planning/key isolation verified game-freeWIP:; confirm via same-scene A/B beforepr ready, keep=0for rollbackTesting
Tested: rebased commit
acd64056ontomain @ 71b1eddunder Windows 11 + Python 3.12.10 + MSYS2 UCRT64 Clang 23.1.4:main @ 71b1eddviaLONGSHOT_BUILD_TEST_SOURCE):tests/test_a64_helper_build_flags.pyfails 9 subtests becausea64_rt.canda64_suyu.cremain-O1.acd64056): all 9 focused drivers pass (tests/test_a64_helper_build_flags.py3 tests,tests/test_light_passes.py,tests/test_lift_cache.py,tests/test_build_hash_cache.py11 tests,tests/test_build_times.py26 tests,tests/test_kept_translation.py7 tests,tests/test_doc_anchors.py,scripts/tested_configurations.py,scripts/check_third_party.py), andgit diff --check origin/main..HEADis clean.python -I -B tests/run_all.py --changed origin/main:90 passed, 13 failed, 7 skipped in 146 s— all 13 failures (tests/test_prepare_stall.py,tests/test_vk_occlusion_queries.py,tests/test_crash_dialog.py,tests/test_oot_state_tap.py,tests/test_make_game_cache.py,tests/test_linux_preflight.py,tests/test_job_queue.py,tests/test_fpx_sticky.py,tests/test_missing_nup.py,tests/test_walk_key.py,tests/test_failed_compile_keeps_objects.py,tests/test_portable_builder_startup.py,tests/test_audio_output_devices.py) are pre-existing in the verified 32-testmain @ 71b1eddWindows baseline (alongsidetests/test_pipeline_cache_file.py,tests/test_pipeline_play_cache.py,tests/test_bug_report_defaults.py,tests/test_run_all_changed.py,tests/test_fsr_uniform_ownership.py,tests/test_replay_write_order.py,tests/test_coverage_run.py,tests/test_dlss_feature_size.py,tests/test_import_reach.py,tests/test_spawn_emit.py,tests/test_portable_builder_home.py,tests/test_tested_configurations.py,tests/test_pending_guest_import.py,tests/test_guest_imported.py,tests/test_fastfp_fma.py,tests/test_pads_after_menu.py,tests/test_auto_handheld.py,tests/test_lift_lookups.py,tests/test_crt_options.py).Not tested: end-to-end native compile timing, final executable size delta, in-game runtime stability and interleaved same-scene FPS/frame-time A/B (
RX_A64_RT_O2=1vsRX_A64_RT_O2=0/main), and Linux fulltests/run_all.py.Must be tested:
mainand this branch (plusRX_A64_RT_O2=0) with the same dump/settings, run at least two interleaved same-scene pairs after warm-up (median FPS, 1% low, median/p99 frame time, binary size, helper compile time), pluspython -I -B tests/run_all.pyon Linux, expecting measurable or non-regressing gameplay performance with acceptable compile cost and clean suites (by hand on a local build, plus Test Farm:@Beanstalklinux).Risks
What could break: optimizer-sensitive code paths in
a64_rt.cora64_suyu.c, slightly larger helper object/executable size, or added helper compile time without a net FPS gain.Turning it off: set
RX_A64_RT_O2=0(keeps lifted C intact) or revert the commit.Compatibility: only
a64_rt.oanda64_suyu.oobject keys change (and toggle retranslation stays skipped viaCOMPILE_ONLY_ENV); saves,longshot_options.ini, shader/pipeline caches, and renderer ABI are unchanged.Issues
See #756
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).tests/that reads changed source updated in this PR, not weakened.a9269637ec16ea5060ccRebased onto
origin/main(71b1edd) asacd64056and reconciled withmain'sLONGSHOT_LIGHT_PASSES/source_flags()refactor:nx2/build.py: addeda64_rt_flags(fl)and routeda64_rt.c/a64_suyu.cthrough optionala64_rt_flinsource_flags(...)(preserving 7-argument callers such astests/test_light_passes.py), keepingsplit_fl/LIGHT_FLAGSandcode_hot*flags unchanged.nx2/make_game.py: kept"RX_A64_RT_O2"inCOMPILE_ONLY_ENV.tests/test_a64_helper_build_flags.py: reconciled planning fixture withLONGSHOT_LIGHT_PASSESandlight_flags_work, verifying both enabled and disabledLONGSHOT_LIGHT_PASSESalongside--dll.origin/main @ 71b1eddviaLONGSHOT_BUILD_TEST_SOURCE):tests/test_a64_helper_build_flags.pyfails 9 subtests because helpers remain-O1.acd64056): all 9 focused drivers pass (tests/test_a64_helper_build_flags.py3 tests,tests/test_light_passes.py,tests/test_lift_cache.py,tests/test_build_hash_cache.py11 tests,tests/test_build_times.py26 tests,tests/test_kept_translation.py7 tests,tests/test_doc_anchors.py,scripts/tested_configurations.py,scripts/check_third_party.py), andgit diff --check origin/main..HEADis clean.python -I -B tests/run_all.py --changed origin/main:90 passed, 13 failed, 7 skipped— all 13 failures are pre-existing onmain @ 71b1edd..forgejo/pull_request_template.mdcleanly (WIP:retained until interleaved same-scene gameplay/build A/B measurements and Linux verification are complete).16ea5060ccacd640569dView command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.