fix(host): the render thread's reserved core is one the game may run on, under a launcher's or Process Lasso's affinity mask too #1776
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1776
Loading…
Reference in a new issue
No description provided.
Delete branch "klimovich008/Longshot:fix/reserved-core-process-mask"
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
When the game is started kept to some of the CPU's cores (an affinity mask from a launcher, Process Lasso,
start /affinity, or keeping a dual-CCD Ryzen to one CCD), the core kept free for the render thread could be one the game isn't allowed to use. Windows then refused to pin the render thread there, nothing was kept free, and the log still said it was pinned. #522 fixed this for the fallback path; the main path (the last core of the fastest kind, on Windows and on Linux hybrid CPUs) returned before that check.This PR picks the reserved core only among the cores whose logical processors are all in the process's mask, on every path, or none when the mask has no whole core or fewer than 8 logical processors. The render thread's pin checks Windows' answer, and a refused pin is logged. With no mask the choice is the same as before. No switch, setting or cache changes; 7950X3D / 9950X3D players are unaffected by default (their cache-core rule keeps no reserved core, as before).
How to see it on main: Windows, a CPU with 8+ cores, start the game with
start "" /affinity 0FFF longshot.exe(on a 16-thread CPU), play, and readlongshot_log.txt: it says reserved core0xc000and "may run on 0xcfff", but the render thread's real affinity is0xfff(the pin was refused) and the game's threads use all of0xfff. Under0x5555the log says "may run on 0xd555", the render thread really runs on0x5555, and logical processor 14 has no game thread.What changed, to read first:
host/hos_thread.c: newprocess_cpus()(the process's mask fromGetProcessAffinityMask; every processor when it can't be read, as Windows gives 0 for a process in several processor groups).pick_reserved_core()takes the allowed mask: a core with a logical processor outside it is neither a candidate nor counted toward the 8 logical processors or the 4 fastest cores. Windows'last_fastest_core, its legacy twin and Linux's/sys/devices/cpu_corepath pass it; the fallback usesprocess_cpus()too. The reserved-core log lines name the mask they chose from.gpu/vk/vk_replay.cpp:replay_thread_mainchecksSetThreadAffinityMask; refused, it logsvk: the replay thread was NOT kept to logical processors ...and prints neither "runs on" nor "may run on".ReplayPin(RX_VK_ASYNC=0) logs a refused pin once. Not a shader-cache stamp file.tests/test_reserved_core_mask.py(new): cuts the realhos_reserved_cpus(Windows and Linux branches) and the replay thread's placement, over fake CPUs (8-core SMT, i7-12700K, 7950X3D, Core Ultra 7 265KF, legacy API) and masks, with a fakeSetThreadAffinityMaskthat refuses a mask outside the process's as Windows does.tests/test_reserved_core.pyfollows the new argument.See #522.
Testing
Tested: On my PC (Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2), in the game in Hyrule Field: with no mask, under
0x0FFFand under0x5555, on main and on this PR, reading the log and the threads' real affinity (Measurements); the no-mask A/B and the keep-a-core vs none A/B under0x0FFF. Game-free:tests/test_reserved_core_mask.pypasses with g++ 16.2 and clang++ 23.1.5, on Windows and WSL Ubuntu, fails with main's sources, and its 6 broken variants each fail;tests/test_reserved_core.pypasses on Windows and Linux; a no-mask differential runs main's and this PR'shos_reserved_cpuson 200,000 random machines (1-64 cores, SMT or not, hybrid or one kind, L3 splits, the Ex call failing,HOS_RESERVE_COREunset/0/1, Linux with and withoutcpu_core), mask = all, unreadable or failing: every choice equal; with random masks every choice of this PR lies inside the mask. After merging main89c3d21e: both tests pass again (g++ and clang++; the new one fails with main 89c3d21e's sources and its broken variants fail), the no-mask differential against main 89c3d21e's code is equal,host/hos_thread.ccompiles whole with llvm-mingw (the same 28 warnings as main),linux_syntax.shok for both files.python -I -B tests/run_all.py --strict --jobs 4(mise run test), Windows, llvm-mingw 20261104: this PR 762 passed, 72 failed, 48 skipped; main89c3d21eon the same PC 761 / 72 / 48, the same 72 failing checks (this Windows checkout's; they fail on main too), the extra pass is the new test.mise run lint: the known SC2016 info atbuild-windows.yml:82only.Test Farm, round 2 on
0573496(no mask, uncapped, windowed, Hyrule Field, 2 runs a side against main3653c9c): Linux pass on an RX 7900 XTX (RADV 26.2.7) and a GTX 1070 (580.196.7), 65.2 vs 65.9 fps, p99 20.1 vs 19.7 ms. Windows NVIDIA: on an RTX 3080 Ti (621.24.0) all four runs clean, this PR 99.21 / 101.01 fps against main 100.22 / 101.89 (flat). On an RTX 4070 Ti SUPER (621.14.0) one PR run crashed with 0xC0000005 inside NVIDIA's shader compiler (nvgpucomp64.dll+0x607360, right after "a C++ allocation refused (at the commit limit?)") and one main run crashed too (0xC0000409): that PC's driver or memory, not this PR (reports rp_fd86096052384aa1, rp_f04e079bcd5c1698). Round 1's Linux RADV runs passed as well (89.2 vs 88.9 fps).Still to test:
start "" /affinity <a mask leaving out the last core>, expecting the log's reserved core inside the mask, the render thread's real affinity as logged and no "NOT kept" line (by hand: the farm can't start the game with an affinity mask)Not covered: the legacy API, dual-CCD X3D (
HOS_RESERVE_CORE=1) and Linux hybrid paths on real hardware (the game-free test and the differential stand in for them); a mask applied to a game already running (Process Lasso's usual way) or changed after start: the choice is made once at start, before and after this PR; Windows with more than 64 logical processors (fixture only); a real 6-core CPU for whether a reserved core pays off there (a question for every 6-core CPU, not this PR).Measurements
Verdict: a fix, not a speed-up. With no mask it is unchanged (A/B within noise). Under a mask the log is now true and the render thread's real affinity matches it; keeping one core of a 6-core mask for the render thread costs at most about 1 % fps (inside the noise) and about 1.5-3 % CPU ms a frame on this PC, the same rule an unmasked 6-core, 12-thread CPU already gets (#522).
Setup: Windows 11, Ryzen 7 5700X3D (8 cores, 16 threads), RX 9070 XT, AMD 26.11.2. Hyrule Field, fast camera rotation, 16:9 window, frame rate unlocked (
HOS_FPS_MAX=240), render thread on, a fixed background CPU load; 3 alternating pairs, a 20 s window each, the median; game clock 1.000 in every run (a <5 % result with 3 pairs is diagnostic only). Thread affinity read from the running game (NtQueryInformationThread, read-only). Masked rows:start "" /affinity 0FFF(or5555); "none kept":HOS_RESERVE_CORE=0.Baseline: measured on main
1055077dwith this PR's commita8476710; main has been merged in since (3653c9c5, then89c3d21e) with no change to these files' code outside this PR, and the farm's no-mask runs above are on the merged head.1055077da8476710Keeping a core under 0x0FFF (this PR) against keeping none (
HOS_RESERVE_CORE=0), 3 pairs: fps 69.94 vs 70.89, CPU ms 61.47 vs 59.77 (medians); per pair fps -5.4 % (a 321 ms frame in this PR's arm, a Presentation Thread hold), +0.6 %, -1.2 %; CPU ms +5.4 %, +0.4 %, +1.5 %. Without the pair with the stall the two are within about 1 % fps.No switch added: the change restores #522's rule on the paths that skipped it.
HOS_RESERVE_CORE=0(none) andHOS_RESERVE_CORE_MASK=<hex>stay the overrides.Risks
Under a mask that keeps whole cores, the game's threads now get one core of the mask fewer (the render thread has it), the same as an unmasked CPU of that size today; measured above at about 1 % fps. With no mask nothing changes. A small leftover: with
HOS_RESERVE_CORE_MASKset outside the process's mask andRX_VK_ASYNC=0, the "replays run on ..." announcement still prints before the new "NOT kept" line (a test override only; the PR no longer picks such a core). Off:HOS_RESERVE_CORE=0keeps no core; otherwise a revert is enough. After updating a player notices nothing: no save, option, shader or pipeline cache, or renderer API change.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
mainand passes here.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, Hyrule Field (16:9 window, uncapped): with no affinity mask the reserved core (0xc000), the log and every thread's real affinity are the same as main's; started under 0x0FFF the reserved core is 0xc00 and the render thread really runs where the log says (main: log 0xcfff, real 0xfff, pin refused); under 0x5555 no core is kept and the game's threads have the whole mask. Standard A/B with no mask, 3 pairs: 72.99 vs 73.79 fps, within noise.
@Beanstalk Check that normal play is unchanged against main with no affinity mask. This PR only changes which core is kept for the render thread when the game runs under a CPU affinity mask; with no mask it must pick the same core and run the same. Targets: Windows and Linux, any GPU; a hybrid Intel CPU (P and E cores) and a dual-CCD Ryzen (7900X, 7950X, 9900X, 9950X, X3D or not) are the most useful, since this PC can't run those paths. Run uncapped so a difference could show:
frame_rate_cap = 6,vsync = 2,frame_generation = 0,fullscreen = 0, the same in every cell. Hyrule Field fromkokiri-start, a 10 s warm-up, then 30 s measured, 2-3 runs a side. Comparefps_meanandframetime_p99_mswith main; keeprun_hitch_countandrun_frametime_max_msreport-only, not pass rules. Also report the log's reserved-core line with alog_matchprobe, report-only (a V-Cache CPU may log no such line): expectedvk: reserved core(one of thereserved core maskorreserved core selectionlines, or the fallback's), and forbiddenNOT kept(the new line for a refused pin, which must not appear with no mask). The fix's own case needs the game started with an affinity mask (start /affinity, taskset), which I don't think the farm can do; a person will be asked for that run, so no masked cell is needed here.Beanstalk test farm · an earlier run: commit
0573496(the newer results are in a comment below)Commit
0573496· tier reviewed · approved by klimovich008 · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)On Windows and Linux, the plan compares unmasked play against main in Hyrule Field with the frame rate uncapped. Two runs per side use a 10-second warm-up and a 30-second measurement, taking about 22 minutes per tester. A crash, an FPS drop over 10%, or a p99 frametime increase over 15% fails the plan; hitch and reserved-core log results are report-only. The affinity-mask case and exact reserved-core selection are not verified by this plan.
kokiri-start(settings vsync=2, fullscreen=0, frame_rate_cap=6, frame_generation=0), then teleport to Hyrule Field, measure field for 30 s (after 10 s warm-up); 2 runs on each side.Done (started 18:53 UTC, last report 19:19 UTC). Comment
@Beanstalkto run it again.NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 4070 Ti, 621.14.0AMD Radeon RX 9070 XT (RADV GFX1201), 26.2.6; 2: linux+amd+radv+dgpuAMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7Measurements · windows
Verdict: could not be judged on windows (2/1 report).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 4070 Ti, 621.14.0AMD Ryzen 9 5900X 12-Core Processor, 64 GB RAMScene: field-unmasked, from the repository's save kokiri-start (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); field-unmasked: 2 game starts a side, field 30 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.
Markdown for the PR description
Measurements · linux
Verdict: pass on linux (2/1 report): no rule failed and no PR run crashed.
Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 9070 XT (RADV GFX1201), 26.2.611th Gen Intel(R) Core(TM) i9-11900KB @ 3.30GHz, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAMScene: field-unmasked, from the repository's save kokiri-start (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); field-unmasked: 2 game starts a side, field 30 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)3653c9c0573496Flags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
@Beanstalk plan Again, with two changes for problems the farm has on many PRs, not only this one.
wait_s) after the save loads, and give the wait forHyruleField_Child120 s. In several timed-out runs here and on other PRs (#1488, #1755, #1574) the teleport never took: the last picture still shows Kokiri Forest, and #1702's runs were refused with "an event is playing".vram_gb = ">= 6". The RTX 3050 Ti Laptop tester fails before building on every PR (git -C Z:\longshot diff --name-only HEADexits 128 indev_packs.py; also on #1815, #1763, #1745, #1702), so this keeps the Windows cell on a tester that can build.Otherwise as before: Windows and Linux, against main, Hyrule Field from
kokiri-start, uncapped and windowed (frame_rate_cap = 6,vsync = 2,frame_generation = 0,fullscreen = 0), 10 s warm-up, 30 s measured, 2 runs a side. Linux RADV already passed (89.2 vs 88.9 fps); the Windows number is the one missing.Beanstalk test farm · an earlier run: commit
0573496, run 2 (the newer results are in a comment below)Commit
0573496· tier reviewed · approved by klimovich008 · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)Compare unmasked gameplay on Windows with at least 6 GB VRAM and on Linux against main, using the Kokiri save and Hyrule Field. Each side runs twice, with uncapped, windowed rendering, a 10-second warm-up and a 30-second measurement; gameplay takes about 23 minutes per tester. The plan compares average FPS and frame-time p99, and reports hitch and reserved-core log data. A crash or a regression greater than 10% in FPS or 15% in frame-time p99 fails the PR; masked affinity behavior is not exercised.
kokiri-start(settings vsync=2, fullscreen=0, frame_rate_cap=6, frame_generation=0), then teleport to Hyrule Field, measure field for 30 s (after 10 s warm-up); 2 runs on each side.Done (started 04:45 UTC, last report 06:38 UTC). Run 2: re-planned by klimovich008. Comment
@Beanstalkto run it again.NVIDIA GeForce RTX 3080 Ti, 621.24.0; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 4070 Ti SUPER, 621.14.0AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7; 2: linux+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce GTX 1070, 580.196.7Measurements · windows+vram-ge6gb
Verdict: fail on windows+vram-ge6gb (2/1 report):
hyrule-field crashfailed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 3080 Ti, 621.24.0AMD Ryzen 9 5900X 12-Core Processor, 64 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 4070 Ti SUPER, 621.14.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMScene: hyrule-field, from the repository's save kokiri-start (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); hyrule-field: 2 game starts a side, field 30 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)3653c9c0573496Flags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
Measurements · linux
Verdict: pass on linux (2/1 report): no rule failed and no PR run crashed.
Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM; 2: linux+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce GTX 1070, 580.196.7Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz, 32 GB RAMScene: hyrule-field, from the repository's save kokiri-start (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); hyrule-field: 2 game starts a side, field 30 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)3653c9c0573496Flags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
Beanstalk test farm · ❌ failed on windows+vram-ge6gb
Commit
7949fcc· approved by klimovich008 (reviewed) · dashboardDone (started 15:51 UTC, last report 17:24 UTC). Comment
@Beanstalkto run it again.windows+vram-ge6gb(6 GB VRAM or more)linuxWhy it failed
windows+vram-ge6gb:hyrule-fieldcrash:1 PR run crashedCouldn'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.
linux, report 1:Insufficient frame-time evidence for 1 required comparison(s). See rule results. a step ran out of time: timeout: the save did not load into play within 900 sWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)On Windows PCs with at least 6 GB VRAM and on Linux PCs, this plan compares uncapped, windowed Hyrule Field gameplay against main over two runs per side, taking about 23 minutes per tester. It measures FPS and frame-time p99 and reports whole-run hitches and reserved-core log matches. A crash, FPS drop over 10%, or p99 increase over 15% fails the PR. The farm does not apply a CPU affinity mask, so the masked-start fix is not directly exercised.
kokiri-start(settings vsync=2, fullscreen=0, frame_rate_cap=6, frame_generation=0), then teleport to Hyrule Field, measure field for 30 s (after 10 s warm-up); 2 runs on each side.Measurements on `windows+vram-ge6gb`, for the PR description
Verdict: fail on windows+vram-ge6gb (2 reports):
hyrule-field crashfailed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 3090, 621.1.0AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 4070 Ti SUPER, 621.14.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMScene: hyrule-field, from the repository's save kokiri-start (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); hyrule-field: 2 game starts a side, field 30 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)89c3d217949fccFlags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `linux`, for the PR description
Verdict: pass on linux (2 reports): no rule failed and no PR run crashed.
Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 5070, 620.70.6AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Steam Machine (RADV NAVI33), 26.1.99AMD Custom CPU 1772, 16 GB RAMScene: hyrule-field, from the repository's save kokiri-start (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); hyrule-field: 2 game starts a side, field 30 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)89c3d217949fccFlags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
windows+vram-ge6gbNVIDIA GeForce RTX 3090, 621.1.0AMD Ryzen 9 5900X 12-Core Processor, 128 GB RAMwindows+vram-ge6gbNVIDIA GeForce RTX 4070 Ti SUPER, 621.14.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMlinuxNVIDIA GeForce RTX 5070, 620.70.6AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMlinuxAMD Steam Machine (RADV NAVI33), 26.1.99AMD Custom CPU 1772, 16 GB RAM🤖 Main (
89c3d21e) merged in, no conflict; no code change beyond the merge. The description is in the new template.Test Farm round 2 on
0573496(no mask, uncapped, windowed, Hyrule Field, 2 runs a side):nvgpucomp64.dll+0x607360, right after "a C++ allocation refused (at the commit limit?)"), and one main run crashed too (0xC0000409). So the "crash" is that tester's driver or memory, not this PR (reports rp_fd86096052384aa1, rp_f04e079bcd5c1698).Still WIP: the masked start on an 8+ core CPU needs a person (the farm can't set an affinity mask).
WIP: fix(host): the render thread's reserved core is one the game may run on, under a launcher's or Process Lasso's affinity mask tooto fix(host): the render thread's reserved core is one the game may run on, under a launcher's or Process Lasso's affinity mask too@Beanstalk plan 🤖 The new head
7949fcconly merges main (89c3d21e) into0573496: no change of its own. The same plan as round 2 (comment 57081):vram_gb = ">= 6") and Linux, any GPU, against main.kokiri-start, uncapped and windowed (frame_rate_cap = 6,vsync = 2,frame_generation = 0,fullscreen = 0). Wait 10 s (wait_s = 10) after the save loads before the teleport, and give the wait forHyruleField_Child120 s. Then a 10 s warm-up and 30 s measured, 2 runs a side.fps_meanandframetime_p99_mswith main;run_hitch_countandrun_frametime_max_msreport-only. A report-onlylog_matchprobe on the reserved-core line: expectedvk: reserved core, forbiddenNOT kept. No masked cell (the farm can't set an affinity mask).@klimovich008
7949fccisn't approved yet: a member ofBigBeansstarts it with@Beanstalkfirst.@Beanstalk Please test
7949fcc(it only merges main89c3d21einto0573496) with the same plan as comment 57081: Windows (vram_gb = ">= 6") and Linux, any GPU, against main; Hyrule Field fromkokiri-start, uncapped and windowed (frame_rate_cap = 6,vsync = 2,frame_generation = 0,fullscreen = 0);wait_s = 10after the save loads, then the teleport, then the map wait withtimeout_s = 120; 10 s warm-up, 30 s measured, 2 runs a side.🤖 About the farm's ❌ on
7949fcc: the crash isn't this PR's.0xc0000005inside NVIDIA's shader compiler,nvgpucomp64.dll+0x607a30;0xc0000409.As the farm's plan says, it doesn't set a CPU affinity mask, so these runs show that the change costs nothing without a mask. They don't exercise the masked start the PR fixes; that was measured on my PC (see Measurements in the description).
Recommendation: Approve. With no affinity mask the choice is provably the same as main's on every path. Under a mask, the reserved core now lands where the render thread can actually be pinned, and the log says what really happened. The one cost, keeping a core of the mask for the render thread, is measured (about 1 %, within noise, on 6 of 8 cores), stated in Risks, and
HOS_RESERVE_CORE=0turns it off. Recommend approval; not approved on the forge.For a player who starts the game under a CPU affinity mask (a launcher, Process Lasso,
start /affinity,taskset), the render thread's reserved core is now one the game may run on. Before, on Windows the pin was silently refused and nothing was kept. On Linux hybrid the render thread left thetasksetset. Under a mask with only one SMT thread per core (0x5555), main also left one logical processor of the mask empty, and that is fixed too. The code is better: the enhanced, legacy and Linux hybrid paths now follow #522's fallback rule through oneprocess_cpus(), and a refused pin is logged instead of hidden.Does it help: not a perf change, it is a fix. The author's PC (Windows 11, 5700X3D, RX 9070 XT, Hyrule Field, 3 alternating pairs each):
The Test Farm's no-mask runs agree:
7949fcc; 65.9 → 65.2 and 89.2 → 88.9 on0573496.The farm's ❌ is the tester, not the change. The RTX 4070 Ti SUPER / 7800X3D tester (driver 621.14) crashed inside NVIDIA's shader compiler (
nvgpucomp64.dll), on main's runs as well as the PR's, in round 2 and round 3. Nothing in this diff runs near shader compilation, and with no mask the code chooses exactly what main chose.Other systems:
allowedholds every logical processor of the group, somasks[i] & ~allowedis 0 and the choice is identical. The missing hybrid-Intel farm run can't show a difference.cpu_corefile): takes the fallback, which already had this rule.process_cpus()there is the same code moved, so nothing changes.GetProcessAffinityMask, which becomes~0, as main's fallback did. A single-group process gets its group's full mask. Unchanged without a mask, but only covered by the fixture.HOS_RESERVE_CORE=1, the mask is the process's, not the cache cores'.GetLogicalProcessorInformationcounts_SC_NPROCESSORS_CONFCPUs and turns an offline CPU, which has no topology directory, into a one-CPU "core". That pseudo-core is outsideprocess_affinity, so it is no longer counted or picked.RX_VK_ASYNC=0:ReplayPinnow logs a refused pin once, and its destructor still restores only when the pin held.Switches: none added or changed.
HOS_RESERVE_CORE(default: one core kept with 8+ logical processors) andHOS_RESERVE_CORE_MASKkeep their meaning. Their defaults stay right, and theswitches.defrow is still accurate.Reviewed:
7949fcc74dagainst main89c3d21e, the firstmainparent of the PR's last merge, so the diff is the PR's own.host/hos_thread.c(pick_reserved_core,process_cpus, bothlast_fastest_core, the legacy path,hos_reserved_cpus,hos_thread_pin),gpu/vk/vk_replay.cpp(replay_pin_mask,ReplayPin, the placement inreplay_thread_main,fastest_kind_cpus),host/posix/win32_posix.c(the shim'sGetProcessAffinityMask,SetThreadAffinityMask,GetLogicalProcessorInformation),tests/test_reserved_core.pyandtests/test_reserved_core_mask.py.Fixed in this review: nothing. I tried to push a one-line doc fix, but the push wasn't allowed from here; it is the first suggestion below.
Checked and fine:
last_fastest_core_legacyreturns*cores = listed, so a mask that excludes every core still ends in that path, with the same result as the fallback.fast < 4andlogical < 8now count only allowed cores, so a mask of 3 P-cores plus E-cores keeps none, as an i5-1235U does.GetLastError()is read in thelogfarguments before anything else can reset it.replay_pin_prev == 0after a refusal means the destructor restores nothing.hos_thread_pin'smay & ~reservednow really leaves the reserved core free, because that core is insidemay.Suggestions (the author may take or leave)
docs/dev/reference/threads.md:89still says the render thread's core is "the last core of the fastest kind". Add the new rule, for example: "...; only a core whose logical processors are all in the process's affinity mask, as a launcher, Process Lasso ortasksetsets it;HOS_RESERVE_CORE=0: none)."host/hos_thread.c:815: under a mask with one SMT thread per core (0x5555), no core is kept. A machine with SMT off in the BIOS and the same 8 single-thread cores does keep one. Takingmasks[i] & allowedas the core when it is non-zero would treat the two alike. Requiring a whole core is also defensible, since the sibling outside the mask is probably busy with something else. Either way, say which in the comment.host/hos_thread.c:800:process_cpus()andprocess_threads()(line 680), plus #1669's Linux branch for it, all read the same mask. Once both PRs are in,process_threads()could countprocess_cpus(). That needsprocess_cpus()moved above it, and the group-count guard kept.Testing:
Overlaps and merge order:
process_threads(), the spin and timer choice, while this PR changes the reserved core's choice. The two hunks are about 100 lines apart, so they merge in either order.vc_acquire, Deck), #1642 and #1666 (the vcore code) touch other parts ofhos_thread.cand don't overlap.@ -798,0 +797,4 @@/* (longshot) The logical processors this process may run on (its affinity mask: `start /affinity`, a launcher's, ProcessLasso's, taskset's), for the reserved core's choice; every one when the mask cannot be read (Windows gives 0 for a processwith threads in more than one processor group) */static uint64_t process_cpus(void) {process_threads() (line 680) and #1669's Linux branch for it read the same mask. Once both are in, process_threads() could count process_cpus() (move this one above it and keep the group-count guard).
@ -799,3 +813,3 @@int best = -1, fast = 0, logical = 0;for (int i = 0; i < n; i++) {if (!masks[i]) continue;if (!masks[i] || (masks[i] & ~allowed)) continue;Under 0x5555 (one SMT thread of each core) no core is kept, but a machine with SMT off in the BIOS and the same 8 single-thread cores keeps one. Taking masks[i] & allowed as the core when it is non-zero would treat them alike. Requiring a whole core is defensible too (the sibling outside the mask is probably busy); say which in the comment.