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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2665
Loading…
Reference in a new issue
No description provided.
Delete branch "klimovich008/Longshot:perf/2090-port"
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
LockMutexandUnlockMutexare the game's busiestnn::oscalls, and each one looks its host object up by the mutex's guest address (the per-thread cache, then the table). This PR keeps the object's number in the guestMutexTypeitself and reads it from there first, so most lookups skip the cache. It is on by default, andHOS_MUTEX_GUEST_ID=0turns it off. On one PC it gained +3.5 % fps in the Market (child) and +5.8 % in Lost Woods (child), with better 1 % lows in both (Measurements).Credit. This is a port of siantm's #1969 and #2090 onto the current
main, which has the Rust builder (#2286). siantm wrote the design and most of the code, and the 14 commits keep siantm as author:obj_is), the cache mode read once, andHOS_OBJ_CACHE=sets. Onlygpu/vk/switches.defconflicted, a row beside it. Thehost/andtests/diff is byte-for-byte #1969's head617c4fba.mutex_guest_id,obj_of_word,obj_miss,obj_by_word. They are identical to its head179e9947, except that theobj_athunk and itstest_cv_handoff_threads.pyhunk are left out. Bracketed port notes in those commits say so.obj_at, the calling thread and the core checkpoint's test taken from the context), and #1957 builds on #1956. #1956's lifter half lives innx2/guest_os.pyandnx2/rtgen.py, and #2286 deletednx2/. Main'sCtxhas noHosThreadHeadorvc_kickoffset, so #1956 can't come over, and #1957 is left out with it. Here,obj_mutex(key, kind)stands in forobj_at. It runsobj()'s core checkpoint first, then the guest-word lookup, orobj_nockptwith the switch off.Our commits on top (each with a
Co-Authored-Bytrailer):af5a9c898:obj_mutex, and LockMutex/UnlockMutex call it.1730d1eca: drops an unused pattern intests/test_multiwait_wake.py. Ruff flags it once the file changes.a3c1e3db9: hardening and tests from a review:HOS_OBJ_CACHE=setstoo;obj_mutex, with the checkpoint before any lookup, the mark after the store, and a one-load identity read.17e1be712: on by default.b6b80b457: comment and switch-row fixes from a second review (when the word is read again; an empty value on Windows). A broken test variant now counts as caught only when one of the fixture's checks fails.main86b3b9e4f.Read first:
obj_mutex,mutex_guest_id,obj_by_word,obj_of_word,obj_isandobj_new_lockedinhost/nn_os_sync.c, thentests/test_obj_guest_id.py.Testing
Tested: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2.
17e1be712with the switch unset (the new default): Market child, pause and unpause; teleport to Lost Woods, pause and unpause; teleport to Fire Temple, pause and unpause.af5a9c898(Market, Lost Woods, Fire Temple with the pause menu): every step reached, and no error lines in either arm.tests/run_all.py):test_obj_guest_id,test_obj_cache_size,test_multiwait_wake,test_cv_handoff_threads,test_switch_table,test_switches_removedpass. All 10 oftest_obj_guest_id's broken variants fail on a check, each for its stated reason (the word's object taken withoutobj_is;obj_mutexignoring the switch; no checkpoint; the checkpoint after the lookup; LockMutex or UnlockMutex throughobj(); the mark before the store; no first-MiB guard; the sets cache's mode read before the switch; unset read as off).test_obj_guest_idandtest_obj_cache_sizepass, andtest_cv_handoff_threadspasses, at17e1be712.host/*.csyntax-compile with the build's flags.nn_os_sync.cwith-Wall -Wextragives no new warnings on llvm-mingw, Linux clang or Linux gcc.1730d1eca: 743 passed, 14 failed, 103 skipped. All 14 fail onmain09dea503too: auto_handheld, builder_channel, coverage_run, dev_ab, dev_build, dev_migrate, game_menu_mouse_buttons, input_movie, job_queue, longshot_ctl, oot_menu_mouse, pads_after_menu, parity_gates, run_all_mingw.mise run lintpasses.a3c1e3db9, and points 1, 3 and 9 are answered below. The second covered the round-2 delta: its points were fixed inb6b80b457, and the fixed-cache probe count is answered below.Still to test:
HOS_MUTEX_GUEST_ID=0, expecting fps and 1 % low equal or better unset, and no crash, hang or new error line (@Beanstalk).HOS_MUTEX_GUEST_ID=1andHOS_OBJ_CACHE=setsin the game: start, play the Market and Lost Woods, expecting no crash or new error line (by hand).Measurements
Verdict: faster on this PC in both scenes. Market child: +3.5 % fps by median, with a better 1 % low. Lost Woods child: +5.8 % fps, with a better 1 % low. Both are "diagnostic": in the Market, n = 3 pairs at that scene's ~3 % run-to-run noise. In each of the two sessions of 3 Market pairs, every pair gained.
Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2.
HOS_FPS_MAX=240), the render thread on (RX_VK_ASYNC=1), the same fixed options file.main09dea503with no pack. After: this branch's pack ataf5a9c898withHOS_MUTEX_GUEST_ID=2, the mode the default now gives (17e1be712makes unset mean 2). The commits sinceaf5a9c898add the first-MiB guard, tests, comments and the default.main09dea503; this branch is now on86b3b9e4f. The numbers still hold, because the 9 commits between them don't touch the host's sync layer or the lifted code. They are builder, release and docs fixes, plus #2158, a mesh-fallback change for AMD's Windows driver on GCN only, which leaves this RDNA 4 card's path alone.09dea503af5a9c89809dea503af5a9c898Two more Market sessions:
=2): fps 105.89 → 109.39, +3.3 %. The 1 % low was about the same (52.4 → 51.8 by median, 51.9 → 52.0 by mean).main(105.49). So the gain comes from the guest word, not from #1969's part.The target: summed per-thread cache lookups fell from 168 M to 21 M (Market, the first pair), so most mutex lookups skip the cache.
The default ships on (unset = mode 2), and
HOS_MUTEX_GUEST_ID=0(oroff,no,false) is the kill switch. futondestroyer asked on #1966 that siantm's experiments stay off while the enabled and disabled results were gathered, and that the default follow evidence from the affected CPUs (review). It is on here for two reasons:MutexType's +0x18 word to the internal critical-section helpers was checked against the game's executable. All of them but one are replaced by the HLE: Lock, TryLock, Unlock, IsMutexLockedByCurrentThread, WaitConditionVariable and TimedWaitConditionVariable. The exception,nn::os::GetMutexOwnerThread, is unreachable: no branch reaches it in any module, no absolute pointer names it, and neither main nor subsdk0 imports it. The scan's limit: it looked for the +0x18 argument within 4 instructions before each branch, and didn't search exhaustively for inlined atomics on +0x18 elsewhere. No game code or bytes were kept from it.Risks
HOS_WRITTEN).obj_is: key and kind in one load). Anything else falls back to the lookup as before, and the word is rewritten.nn::oswrites +0x18 in Lock/Unlock too.obj_mutex. The off arm ismainplus #1969's one-load identity check.HOS_OBJ_CACHE=sets(off by default): two live mutexes whose addresses share the low 32 bits can thrash one set (sol, first review, point 3; #1969's code). It costs speed only, with that switch.switches.defchanged: it is not a shader-cache stamp file, so no pipeline preparation follows.HOS_MUTEX_GUEST_ID=0inlongshot_env.txtor the environment. On Windows an empty value removes the variable, which then reads as on, so use0. A revert is enough too: no saves, options or caches change.Review points left as they are:
LONGSHOT_MINGW's clang on Linux, whose release lacks the sanitizer runtimes. This is #1969's code, and CI doesn't set that variable.HOS_MUTEX_GUEST_ID=0andHOS_OBJ_CACHE=0, a warm fixed-cache hit moves none of the fixture's counters, so the order check is weaker in that one configuration. The "checkpoint after the lookup" variant still fails in the default configuration.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
gpu/vk/switches.def.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
86b3b9e4finto perf/2090-portTested in game: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2: with the switch unset (on) at
17e1be712, Market child, Lost Woods child and Fire Temple with the pause menu, every step reached, no new error lines, 0 virtual-core escapes, the guest-word path in use (per-thread cache lookups 1.9-2.5 M against 25-46 M off); 18 A/B runs (Market and Lost Woods child, uncapped) against plain main, all admitted, game clock 1.000 +-0.015, no frame over 50 ms.@review
@Beanstalk This is a performance change in the host's nn::os layer (host/nn_os_sync.c), on Windows and Linux alike: LockMutex and UnlockMutex find their host object through a number kept in the guest mutex, on by default, with HOS_MUTEX_GUEST_ID=0 as the off switch.
Beanstalk test farm · an earlier run: commit
01b867c(the newer results are in a comment below)Commit
01b867c· approved by klimovich008 (reviewed) · dashboardDone (started 11:55 UTC, last report 11:56 UTC). Comment
@Beanstalkto run it again.anyCouldn'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.
any, report 1:main's longshot-builder failed (exit 1): longshot_builder: no llvm-mingw: pass --llvm-mingw <folder> or set LONGSHOT_MINGW (Y:\builder\tools\tools\llvm-mingw\bin\x86_64-w64-mingw32-clang.exe is not there)any, report 2:main's longshot-builder failed (exit 1): longshot_builder: no llvm-mingw: pass --llvm-mingw <folder> or set LONGSHOT_MINGW (Z:\builder\tools\tools\llvm-mingw\bin\x86_64-w64-mingw32-clang.exe is not there)What was tested
What will be tested · default plan (AI failed: the summary says 'tester will': the farm is unattended, so it must describe only what the plan's steps do (no one looks at, checks or does anything by hand); write it again)
The AI plan failed: the summary says 'tester will': the farm is unattended, so it must describe only what the plan's steps do (no one looks at, checks or does anything by hand); write it again; using the default plan.
kokiri-start, then teleport to Hyrule Field, measure field for 60 s (after 10 s warm-up); 2 runs on each side.Measurements on `any`, for the PR description
Verdict: could not be judged on any (2 reports).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAM; 2: windows+intel+intel-proprietary+igpuIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMScene: title, from the title screen; hyrule-field, from the repository's save kokiri-start; 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); title: 2 game starts a side, title 20 s after 5 s warm-up; hyrule-field: 2 game starts a side, field 60 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
anyNVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAManyIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM@Beanstalk plan The previous plan fell back to the default because the planner's summary was refused. Here is the same request, for an unattended run. Describe only what the steps do.
This PR changes the host's nn::os layer (host/nn_os_sync.c) on Windows and Linux alike. LockMutex and UnlockMutex now find their host object through a number kept in the guest mutex. It is on by default, and HOS_MUTEX_GUEST_ID=0 turns it off.
Beanstalk test farm · an earlier run: commit
01b867c, run 2 (the newer results are in a comment below)Commit
01b867c· approved by klimovich008 (reviewed) · dashboard⚠️ Note: The plan can turn the camera before each measurement, but cannot hold the stick during a measure step; it therefore does not reproduce the claimed turning-camera measurements exactly.
⚠️ Note: Core count, thread count, and hybrid CPU architecture cannot be selected directly by the target schema, so the requested CPU spread is not guaranteed.
⚠️ Note: Two runs per side and the regression thresholds may not distinguish the claimed 3.5–5.8% gains from noise.
Started at 11:56 UTC. Run 2: re-planned by klimovich008.
steamdecklinux+amdlinux+nvidiawindows+amdwindows+nvidiamarket-lost-woods· frame time p99 (ms)HOS_MUTEX_GUEST_ID=HOS_MUTEX_GUEST_ID=0(reference)steamdecklinux+amdlinux+nvidiawindows+amdwindows+nvidiaCouldn'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.
steamdeck, report 1:main's longshot-builder failed (exit 1): Traceback (most recent call last):linux+amd, report 1:main's longshot-builder failed (exit 1): Traceback (most recent call last):linux+amd, report 2:main's longshot-builder failed (exit 1): Traceback (most recent call last):windows+amd, report 1:main's longshot-builder failed (exit 1): longshot_builder: no llvm-mingw: pass --llvm-mingw <folder> or set LONGSHOT_MINGW (Z:\builder\tools\tools\llvm-mingw\bin\x86_64-w64-mingw32-clang.exe is not there)windows+amd, report 2:main's longshot-builder failed (exit 1): longshot_builder: no llvm-mingw: pass --llvm-mingw <folder> or set LONGSHOT_MINGW (Z:\builder\tools\tools\llvm-mingw\bin\x86_64-w64-mingw32-clang.exe is not there)windows+nvidia, report 1:main's longshot-builder failed (exit 1): longshot_builder: no llvm-mingw: pass --llvm-mingw <folder> or set LONGSHOT_MINGW (Y:\builder\tools\tools\llvm-mingw\bin\x86_64-w64-mingw32-clang.exe is not there)windows+nvidia, report 2:main's longshot-builder failed (exit 1): longshot_builder: no llvm-mingw: pass --llvm-mingw <folder> or set LONGSHOT_MINGW (Z:\builder\tools\tools\llvm-mingw\bin\x86_64-w64-mingw32-clang.exe is not there)What was tested
What will be tested · AI plan (
gpt-6.1-terra)The plan compares main with the PR’s default mutex lookup and its disabled setting on Windows, Linux, and Steam Deck. From a child save, each run teleports to Market and Lost Woods, takes a stationary picture, turns the camera, and measures each scene for 20 seconds after warm-up. Two runs per side and setting report frame rate, frame times, hitches, and worst frames; a crash, a substantial performance regression, or a picture difference beyond the threshold fails the plan. No tester online now matches linux+nvidia: that target waits for one.
0(PR only).market-entrance(settings vsync=2, fullscreen=0, frame_rate_cap=6, frame_generation=0), then teleport to Market, take the picture market to compare with main, move the stick, measure market for 20 s (after 5 s warm-up), teleport to Lost Woods, take the picture lost-woods to compare with main, measure lost-woods for 20 s (after 5 s warm-up); 2 runs on each side for each of 2 cells (2 game starts a run).Measurements on `steamdeck`, for the PR description
Verdict: queued on steamdeck (1 report).
Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMScene: market-lost-woods, from the repository's save market-entrance (vsync=2, fullscreen=0, frame_rate_cap=6, frame_generation=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-lost-woods: 2 game starts a side, market 20 s after 5 s warm-up, lost-woods 20 s after 5 s warm-up; 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)Nothing was measured: no metric came back.
Flags and settings
HOS_MUTEX_GUEST_ID0As Markdown for the PR description:
Measurements on `linux+amd`, for the PR description
Verdict: could not be judged on linux+amd (2 reports).
Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 9070 (RADV GFX1201), 26.0.8AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAMScene: market-lost-woods, from the repository's save market-entrance (vsync=2, fullscreen=0, frame_rate_cap=6, frame_generation=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-lost-woods: 2 game starts a side, market 20 s after 5 s warm-up, lost-woods 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
HOS_MUTEX_GUEST_ID0As Markdown for the PR description:
Measurements on `windows+amd`, for the PR description
Verdict: could not be judged on windows+amd (2 reports).
Hardware: 1: windows+amd+amd-proprietary+dgpu+fsr4
AMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 9 7950X 16-Core Processor, 128 GB RAM; 2: windows+amd+amd-proprietary+dgpu+fsr4AMD Radeon RX 9060 XT, 2.0.416AMD Ryzen 5 5600 6-Core Processor, 32 GB RAMScene: market-lost-woods, from the repository's save market-entrance (vsync=2, fullscreen=0, frame_rate_cap=6, frame_generation=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-lost-woods: 2 game starts a side, market 20 s after 5 s warm-up, lost-woods 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
HOS_MUTEX_GUEST_ID0As Markdown for the PR description:
Measurements on `windows+nvidia`, for the PR description
Verdict: could not be judged on windows+nvidia (2 reports).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpu+dlssNVIDIA GeForce RTX 3050 Laptop GPU, 621.40.012th Gen Intel(R) Core(TM) i5-12500H, 16 GB RAMScene: market-lost-woods, from the repository's save market-entrance (vsync=2, fullscreen=0, frame_rate_cap=6, frame_generation=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-lost-woods: 2 game starts a side, market 20 s after 5 s warm-up, lost-woods 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
HOS_MUTEX_GUEST_ID0As Markdown for the PR description:
The testers' hardware
steamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMlinux+amdAMD Radeon RX 9070 (RADV GFX1201), 26.0.8AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAMlinux+amdAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAMwindows+amdAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 9 7950X 16-Core Processor, 128 GB RAMwindows+amdAMD Radeon RX 9060 XT, 2.0.416AMD Ryzen 5 5600 6-Core Processor, 32 GB RAMwindows+nvidiaNVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAMwindows+nvidiaNVIDIA GeForce RTX 3050 Laptop GPU, 621.40.012th Gen Intel(R) Core(TM) i5-12500H, 16 GB RAMRun by hand on PCs that don't match their target (not counted)
AMD Radeon RX 9060 XT, 2.0.416)Recommendation: Request changes. The new checks fail on Linux when LONGSHOT_MINGW selects an llvm-mingw installation without Linux sanitizer runtimes. The reported runs also leave the default-on synchronization path unmeasured on Linux, Steam Deck and other affected CPUs.
LockMutex and UnlockMutex can find their host object through a number stored in guest memory, bypassing the per-thread cache. This adds numbered object storage, a guest-memory write and another experimental cache mode in exchange for the reported frame-rate gain.
Blocking (1): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 10s.Should fix (1): not blocking, but worth doing before merging.
tests/test_obj_cache_size.py:468: The compiler selection prefers llvm-mingw on Linux even though both fixtures unconditionally request Linux sanitizer runtimes that that distribution does not supply. (more on the line) Do: On Linux select a native compiler ahead of LONGSHOT_MINGW, while continuing to honor explicit --cc and CC; keep llvm-mingw selection for Windows.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
host/nn_os_sync.c:264: The default-on hot path needs comparison on the other supported CPU and OS configurations before its default can be settled. (more on the line) Do: Run warmed, interleaved base-versus-head game comparisons in the target and heavy scenes at player settings, including Linux/Steam Deck and the requested CPU coverage; report fps, 1% lows and frame times. (@fixdoes its part first: Keep the guest-word path off on configurations where it does not win, or remove the extra lookup from those paths.)host/nn_os_sync.c:348: The default now allocates synchronization objects in chunks, but its memory cost has not been measured. (more on the line) Do: Compare peak and steady host RAM against the base through startup and representative play, including a scene transition. (@fixdoes its part first: Reduce chunk granularity or allocate numbered storage in smaller increments.)@fixcan do L1, L2, L3 and L4.Questions (1) (not confirmed from the code; they don't hold the recommendation)
Checks: Still running: 8 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for the supported player configurations. The PR reports median gains of 3.5% in Market and 5.8% in Lost Woods, with better 1% lows, over 3 and 6 interleaved pairs respectively on one Windows Ryzen 7 5700X3D/RX 9070 XT PC. The Market result is near the stated 3% noise, the runs had no warm-up, and the comparison used uncapped settings rather than establishing the gain at normal player settings.
Other systems: The lookup and object identity changes affect all synchronization objects and both Windows and Linux, regardless of GPU. The guest-word path is default-on; Linux, Steam Deck, other CPUs and GPUs, and the sets-cache combination remain untested in game. Numbered chunks also change host memory use. The PR reports Windows smoke runs without new errors; it does not establish those other configurations.
Switches: HOS_MUTEX_GUEST_ID is new, defaults to 2 and accepts 0/off/no/false to disable it or 1 to consult the word on cache misses; its default needs the outstanding platform measurements. HOS_OBJ_CACHE adds the experimental sets value; its default remains 16384 entries. Both have switch-table rows.
Reviewed:
01b867c739against86b3b9e4f0: Read AGENTS.md, CONTRIBUTING.md, the PR template, docs/dev/standards.md, the commit log and diff, the changed synchronization and test code, and the guest range and platform memory implementation around the change. Skimmed the longer fixture bodies and commit histories; did not inspect game-derived material. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run, as requested. The PR reports Windows game smoke tests and focused game-free checks; Linux game runs and the other requested hardware runs remain outstanding. One head-only CI check is failing and several are still running; the supplied CI result is not restated as an item.
Overlaps and merge order: The description identifies this as a port of #1969 and #2090; their current status and merge order cannot be checked from the supplied checkout.
Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.
@ -226,0 +261,4 @@static Obj *obj_by_word(uint64_t key, int kind, int mode);static int mutex_guest_id(void); /* (HOS_MUTEX_GUEST_ID: 0 off, 1 or 2; below, with the caches' switches) */static Obj *obj_mutex(uint64_t key, int kind) {hos_vcore_checkpoint(); /* (as obj: before the lookup) */L2 (should fix): The default-on hot path needs comparison on the other supported CPU and OS configurations before its default can be settled.
When: Every lock and unlock now reads guest memory and follows a numbered-object pointer before the cache; their locality and contention can differ on Linux, Steam Deck and CPUs unlike the tested 5700X3D.
Do: Run warmed, interleaved base-versus-head game comparisons in the target and heavy scenes at player settings, including Linux/Steam Deck and the requested CPU coverage; report fps, 1% lows and frame times.
@ -255,0 +345,4 @@if (id >> OBJ_CHUNK_BITS >= OBJ_CHUNKS) return (Obj *)calloc(1, sizeof(Obj));Obj *k = obj_chunks[id >> OBJ_CHUNK_BITS];if (!k) {k = (Obj *)calloc((size_t)1 << OBJ_CHUNK_BITS, sizeof(Obj));L3 (should fix): The default now allocates synchronization objects in chunks, but its memory cost has not been measured.
When: The first numbered object allocates 1024 Obj slots and every subsequent chunk can retain unused slots for the process lifetime, whereas the base allocates objects individually.
Do: Compare peak and steady host RAM against the base through startup and representative play, including a scene transition.
@ -188,0 +465,4 @@for c in (given, os.environ.get("CC")):if c:return shutil.which(c) or (c if os.path.isfile(c) else None)mingw = os.environ.get("LONGSHOT_MINGW")L1 (should fix): The compiler selection prefers llvm-mingw on Linux even though both fixtures unconditionally request Linux sanitizer runtimes that that distribution does not supply.
When: On a Linux developer machine with LONGSHOT_MINGW set and CC unset, compiler() selects its clang; both this test and test_obj_guest_id then fail to link their ASan/UBSan fixtures instead of running the checks, even when a suitable native compiler is on PATH.
Do: On Linux select a native compiler ahead of LONGSHOT_MINGW, while continuing to honor explicit --cc and CC; keep llvm-mingw selection for Windows.
On BeanBot's review of
01b867c7:main86b3b9e4f's own push run (run 55611, job 2), and the log here says "Guide screenshot check failed: 1 issue(s)". This PR changes no UI, guide orthird_party/file. CI "Rust" fails onmaintoo (run 55611, job 3): clippy's three "creates a reference which is immediately dereferenced" errors inbuild-driver, and this PR has no Rust. I'll mergemainagain once it fixes them.LONGSHOT_MINGW, so CI is not affected, andCCor--ccpicks the compiler. A commit will make the fixtures prefer a native compiler on Linux ahead ofLONGSHOT_MINGW, keepingCC/--ccfirst and llvm-mingw on Windows.HOS_MUTEX_GUEST_ID=0and againstmain, uncapped, in the Market and Lost Woods. If it goes against the default on a platform, that platform turns it off before this leaves WIP.Objthat are never freed. So the extra memory overmainis at most the unused slots of the last chunk, plus a chunk pointer table of 4096 entries (32 KiB). Peak and steady host RAM againstmain, through start, play and a scene change, will be measured and added under Measurements.MutexType's +0x18, but it didn't search for inlined atomics on that offset elsewhere. Code there would see the object number in place of the sdk's critical-section word.HOS_MUTEX_GUEST_ID=0is the switch if any player-facing case shows it.Answers to L1 and L3 from the review.
L1: fixed in
836a55e69.test_obj_cache_size.compiler, whichtest_obj_guest_iduses too, now picks the compiler in this order:--cc, thenCC;LONGSHOT_MINGW's clang, then cc, clang or gcc on PATH, as before;LONGSHOT_MINGW's clang only when PATH has none.compiler_choice_checkruns this choice over a fake PATH and file system before the fixtures build. It checks six cases, and each Linux case is asked again as Windows and must answer differently. With the old order (llvm-mingw first everywhere) it fails on "Linux: a native compiler before llvm-mingw".What ran:
LONGSHOT_MINGWnaming a clang that cannot link and no--ccorCC: both fixtures build with the native compiler and pass.obj_guest_id,obj_cache_size,multiwait_wake,cv_handoff_threads,switch_table,switches_removed) passes 6/6, and lint passes.L3: measured, and the difference is below run-to-run noise.
HOS_MUTEX_GUEST_ID=0(off). Each run was a tour from the save: Market child (play, pause menu), teleport to Lost Woods (play, pause menu), teleport to the Fire Temple (play, pause menu, then idle to the end).GetProcessMemoryInfoevery 0.25 s. "Private" is the commit charge (PrivateUsage).=0(off)The differences go in both directions between scenes and metrics, so with one run per arm they are noise.
By construction, the switch adds no more than:
The numbered objects replace one allocation per object, so the steady cost is that bound or less.
The guest-word path was active in the "on" run. A module worker's per-thread cache saw 2.19 M lookups with the switch on and 46.0 M with it off. Neither run logged a vcore escape or any fatal or crash line.
Not covered: Linux, the Steam Deck and other GPUs (that is L2, for the farm round), and more than one run per arm.
The farm round (Run 2) is on
01b867c73.836a55e69changes only these two test files, so that round still measures this head's game code.🤖 Generated with Claude Code
Beanstalk test farm
Commit
836a55e· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it./review
Recommendation: Request changes. The guest-word lookup improves frame rates on the measured Windows PC, but the default-on path still needs results on other supported CPUs and operating systems. (It stands on L4: The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 10s.)Mutex lookups can bypass the per-thread cache using an object number stored in guest memory. This adds lookup and allocation complexity in exchange for the reported performance gain.
Blocking (3): must change before merging.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 10s.CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)fails on this head and passes on the base branch: Failing after 5m13s.CI / Game-free checks (run_all.py, part 2/2) (pull_request)fails on this head and passes on the base branch: Failing after 26m18s.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
host/nn_os_sync.c:264: The default-on hot path needs comparison on the other supported CPU and OS configurations before its default can be settled. When: Every lock and unlock now reads guest memory and follows a numbered-object pointer before the cache; their locality and contention can differ on Linux, Steam Deck and CPUs unlike the tested 5700X3D. Do: Run warmed, interleaved base-versus-head game comparisons in the target and heavy scenes at player settings, including Linux/Steam Deck and the requested CPU coverage; report fps, 1% lows and frame times. (@fixdoes its part first: Keep the guest-word path off on configurations where it does not win, or remove the extra lookup from those paths.)@fixcan do L2, L4, L5 and L6.Since the last review (on
01b867c739)Resolved: L1 (The compiler selection prefers llvm-mingw on Linux even though both fixtures unconditional…); L3 (The default now allocates synchronization objects in chunks, but its memory cost has not b…)
Still open: L2 (The default-on hot path needs comparison on the other supported CPU and OS configurations…); L4 (The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head…)New: L5 (The check
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request)fails on th…); L6 (The checkCI / Game-free checks (run_all.py, part 2/2) (pull_request)fails on this head…)Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes on the measured PC: median FPS rose 3.5% in the Market and 5.8% in Lost Woods, with better median 1% lows. These are author-reported runs against an earlier main commit; results on other systems remain outstanding.
Other systems: The synchronization path runs on Windows and Linux across CPUs and GPUs. The author reports Windows AMD gameplay and Linux game-free checks; Steam Deck, Linux gameplay, other CPUs and GPUs remain under test.
Switches: HOS_MUTEX_GUEST_ID is added, defaulting to mode 2; 0 disables it and 1 uses the guest word on cache misses. The default remains subject to the outstanding hardware comparisons. HOS_OBJ_CACHE gains the experimental sets value; its existing default remains 16384 entries.
Reviewed:
836a55e69cagainst86b3b9e4f0: Read the repository rules and pull request template, the incremental diff, compiler selection and its callers, and the relevant synchronization allocation and lookup code. Skimmed the remaining changed files and recorded runs; the full base-to-head diff and all changed code were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run tests were executed. The author reports focused Windows checks, Linux fixture runs, and a Windows gameplay tour; broader gameplay and performance results are pending.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
WIP: perf(os): mutex lookups through the guest MutexType word, on by default (port of #2090 and #1969)to perf(os): mutex lookups through the guest MutexType word, on by default (port of #2090 and #1969)