WIP: perf(os): HOS_RESERVE_LEND=1 lends the render thread's reserved core to the game's threads while it idles (off by default) #2436

Draft
klimovich008 wants to merge 7 commits from klimovich008/Longshot:perf/reserved-core-lent-while-idle into main
Member

Summary

From 8 logical processors the host keeps one whole core for the render thread, and no game thread may use it. On a CPU
with 4 or 6 cores that is a quarter or a sixth of the CPU, held for a thread that in CPU-heavy scenes sleeps more than
half the frame. This PR adds a switch, HOS_RESERVE_LEND=1, off unless set, that lends the reserved core to the
game's threads while the render thread is idle, and takes it back when the render thread gets busy. Measured on one
8-core PC held to 4 and 6 cores by an affinity mask, it gets back what HOS_RESERVE_CORE=0 gains in Lost Woods without
losing what keeping the core gains in Hyrule Field. Whether it becomes a default is the maintainers' call after real 4-
and 6-core CPUs have run it.

Where it acts. Only when a core is reserved, the game may use fewer than 8 whole cores (counted as the reserved
core's own rule counts them: inside the process's mask and the cache cores), and the cores are of one kind (a hybrid CPU
declines). It also declines under HOS_RESERVE_CORE_MASK and HOS_PIN_BY_CORE. One log line at start says what it does
or why it does nothing: threads: HOS_RESERVE_LEND=1: the reserved core 0xc0 is lent to the game's threads while the render thread idles (...) / threads: HOS_RESERVE_LEND=1 does nothing here: <why>. With threaded rendering off
nothing asks the host, and the core stays kept as today.

The decision (gpu/vk/rt_lend.h, a pure header, on the render thread, from its own job times over windows of
presents):

  • Lend: two windows of 300 presents in a row with the render thread idle over 40 %, and the game paced at most
    0.5 % of the window (a frame cap's waits are not idle: at a cap the core stays kept).
  • Take back: one window of 120 presents with the render thread idle under 30 % (the game's pacing is subtracted
    from idle, so a heavily paced window takes it back), or a window that decides nothing (a present over 250 ms, or under
    20 presents a second: a load, a pause, a menu).
  • No lend within 20 s after any take-back (20 s of the windows' own time). This bounds the changes by construction:
    a lend, a take-back, then nothing for 20 s, so no 20 s holds more than two changes, whatever the scene does. Without
    it, three earlier rules each still cycled in some steady sequence (at the 60 cap with a large gain, uncapped with a
    large gain, or a long hitch every 10 s); with it a 20,000-run fuzz of random windows never had more than 2 changes in
    any 20 s. It changed none of the measured runs: the shortest take-back-to-lend gap in any game run was about 21.7 s.
  • On a change the host walks its thread table and sets each live game thread's mask to the lent or kept one (threads
    HOS_PIN places are skipped; threads made or renamed while lent get the lent mask). The render thread's own mask is
    not touched. A log line names each change and its reason (vk: HOS_RESERVE_LEND: the reserved core lent to the game's threads|taken back: the render thread idle NN % ...), and a line after the 600-present line counts them.

Also changed:

  • MKWVK_API_VERSION 45 -> 46: MkwVkHost gains reserved_lend, appended. An exe and a renderer of different
    versions refuse each other, as before. vk_api.h is not a shader-cache stamp file: no re-prepare.
  • host/posix/win32_posix.c (Linux), a change on every path: SetThreadAffinityMask now takes the thread's lock
    and refuses a thread that has ended (ERROR_INVALID_PARAMETER, as Windows refuses one). This applies with the switch
    unset too, to every caller of the shim's call (hos_thread_pin, pin_by_core, the replay thread's pin,
    RX_VK_RECORDER_PIN). Why: an ended detached pthread_t may already name another thread, and setting its affinity
    could move that one. The existing callers set running threads' masks, so it refuses nothing they did before; a call
    on an ended thread used to reach pthread_setaffinity_np (undefined there) and now fails. It is one self-contained
    function and can be split into its own PR if preferred.
  • host/nn_vi.c: the host's frame pacing adds its planned sleep to a counter while the rule applies (no new clock
    read). host/rx_backend.c: the API field. host/hos_thread.c: the rule, the topology reader, the walk.
    gpu/vk/vk_replay.cpp: counting at the two job-timing sites and the present. gpu/vk/switches.def,
    docs/dev/reference/switches.md, docs/dev/reference/threads.md. Tests: tests/test_reserved_lend.py (new),
    tests/test_reserved_core.py, tests/test_pacing_policy.py (two stub definitions).

With our other two placement PRs (neither on main):

  • #2240 (RX_VK_RT_HOME): this PR sets a reserved_lent flag with no reader yet. Whichever of the two merges
    second adds the one test in rt_home_frame (the home guard off while lent, its counters cleared at the take-back) and
    its case in tests/test_rt_pin.py. Both edit the same render-thread bullet in threads.md.
  • #2360 (HOS_WORKERS_SPREAD): the walk skips threads HOS_PIN places; the workers' set needs the same skip
    (spread && !strncmp(name, "BaseProcExecutor", 16)), added by whichever merges second. They can meet only at exactly 7
    whole cores.
  • One topology reader: this PR's lend_cores and #2360's worker_cores read the same thing; whichever merges
    second should share one. This PR already folds the Linux reserved-core reader into one reader (cpu_core_list,
    sys_cores), with unset reading exactly what main read.
  • The three switches were never run together.

Read first: gpu/vk/rt_lend.h (decide), then host/hos_thread.c (lend_rule_cpus, lend_applies,
hos_reserved_lend, hos_lend_affinity), then vk_replay.cpp's lend_job / lend_present.

Testing

Tested: Windows 11, Ryzen 7 5700X3D (8 cores, 16 threads), RX 9070 XT, AMD 26.11.2. The PR's build over main 0e32bc10
(the code of 297aa184; API 46; shaders byte-identical to main's), the switch on against HOS_RESERVE_CORE=0 and against
unset. Every masked number is this 8-core CPU held to 4 cores (0xff) or 6 cores (0xfff) by an affinity mask, not a
real 4- or 6-core CPU.
Each A/B is 3 alternating pairs, the fixed test profile, a fixed light GPU load beside the game,
uncapped unless marked. Lost Woods and Hyrule Field are kept apart.

  • The masked numbers rely on a harness fix: the test harness used to set the game's affinity mask again after the
    launch, which put 21 early threads (the main thread, the Presentation thread, the loaders) back on the reserved core
    in every "kept" arm. From the second round on it no longer does, so unset arms have every game thread off the reserved
    core, as on a player's PC. The first round's larger gains (+8.4 / +6.3 %) were against that partly-kept control and
    are not quoted.
  • Lost Woods (Measurements): lent before the window in every switch-on run, 0 changes in any window.
  • Hyrule Field: within 1 % of today on both masks; kept for the whole window in every switch-on run, masks as the
    control's.
  • The 60 cap (0xff, Lost Woods and Hyrule, 3 pairs each, two rounds): fps flat (59.9-60.0 both arms), kept, 0
    changes after the save load.
  • Unset is main: Lost Woods 0xff, the PR's build unset against main's: 64.49 vs 64.49 fps; the placement of every
    thread identical by name and mask in all 6 runs; no log line.
  • Crossing scenes (title, save load, Lost Woods, teleport to Hyrule Field): lent at the title, taken back at the save
    load, lent in Lost Woods, taken back at the teleport; the long frames are the loads', no worse than the control's.
  • Frames over 50/100/250 ms: 0/0/0 in every uncapped switch-on run of the A/Bs; clock 0.998-1.002; no error lines.
  • tests/test_reserved_lend.py (llvm-mingw clang and MSYS2 gcc): the real rt_lend.h over window sequences (lend,
    take-back, loads, the 60 cap, steady cycles and periodic hitches each held to at most 2 changes in any 20 s, the 20 s
    quiet and its edge, the pacing veto's level); the host's rule and walk over stubbed topologies and thread tables
    (masks inside the process's mask and cache cores, HOS_PIN threads untouched, threads made while lent, declines); the
    two renderer call sites cut from vk_replay.cpp and run. 26 broken variants, each failing; a static_assert pins the
    constants an equivalence argument depends on. It fails on main.
  • After merging main 8aa5ab87: main merged cleanly (35 commits, among them threads.md, vk_main.cpp, vk_replay.cpp, hos_thread.c: no conflict); on the merged head tests/test_reserved_lend.py passes with clang and gcc (26 broken variants fail), and the focused checks pass (test_reserved_core, test_reserved_core_mask, test_fps_stats, test_frame_overlap, test_threaded_rendering, test_switch_table, test_env_on, test_switches_removed, test_doc_anchors, test_hos_ab, byte_compile). run_all.py --changed 8aa5ab87: 277 passed, 13 failed; each failure also fails on main (four of them, test_menu_text_field, test_rdna2_mesh_only, test_rumble_menu, test_vibration_menu, fail on main 8aa5ab87 itself; the rest on this PC on 0e32bc10 too). The changed host files compile whole (MSVC-target clang, llvm-mingw with main's warning counts, Linux clang and gcc); nn_vi.c shows only the two rx_option errors main's file has against the same headers. Not re-run in the game after the merge (the merge changed no line this PR adds).
  • mise run lint: only main's shellcheck SC2016 on .forgejo/workflows/build-windows.yml:82.

Still to test:

  • Windows, a real 4-core / 8-thread CPU and a real 6-core / 12-thread CPU: HOS_RESERVE_LEND=1 against 0 on the PR's
    build, Lost Woods and Hyrule Field, uncapped, 3 starts a cell, expecting Lost Woods up, Hyrule level, no long frames
    (@Beanstalk).
  • The same at the 60 cap, one run, counting the log's HOS_RESERVE_LEND lines, expecting none after the save load
    (@Beanstalk).
  • The Steam Deck (Linux, 4 cores / 8 threads): the same as the 4-core case; while lent the render thread shares its core
    there (@Beanstalk, if a Deck tester is online).

Measurements

Verdict: on this PC's 4- and 6-core masks, Lost Woods gains +5.6 % and +5.4 % against today (unset), within 0.5 % of
HOS_RESERVE_CORE=0; Hyrule Field stays within 1 % of today; the 60 cap is unchanged. Off by default.

Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2. Lost Woods as child (the profile save, then the teleport),
fast rotation, 16:9, RX_VK_ASYNC=1, frame rate unlocked (HOS_FPS_MAX=240), the fixed test profile and GPU load, 20 s
window, 3 alternating pairs, medians, the game's mask set at launch (--affinity). Before: main's placement (the PR's
build unset, shown equal to main's above, or main's own build); After: the PR's build with HOS_RESERVE_LEND=1.

Before: main @ 0e32bc10 After: this PR @ 297aa184, HOS_RESERVE_LEND=1
Lost Woods, 4 cores (0xff), fps median 64.24 67.84 (+5.6 %)
Lost Woods, 6 cores (0xfff), fps median 75.59 79.64 (+5.4 %)
Lost Woods, 4 cores, CPU ms a frame 75.68 73.51
Lost Woods, 6 cores, CPU ms a frame 63.55 61.04
Hyrule Field, 4 cores, fps median 77.54 77.04 (-0.6 %)
Hyrule Field, 6 cores, fps median 83.04 83.29 (+0.3 %)
frames over 50 / 100 / 250 ms (switch on, all 18 runs) 0 / 0 / 0

Against HOS_RESERVE_CORE=0 (the core never kept), Lost Woods: 4 cores 69.09 -> 68.79 (-0.43 %) and, on the final
code, 67.54 -> 67.29 (-0.37 %); 6 cores 79.74 -> 79.39 (-0.44 %). The 60 cap: Lost Woods 60.00 / 59.99 and Hyrule 59.99 /
59.94 fps (control / on), 0 changes after the save load. The first four rows are from the round before the 20 s quiet
(head 47b18d90); the quiet changes none of those runs (their shortest take-back-to-lend gap was 21.7 s), and the final
code was re-measured against =0 (-0.37 %). Std_test labels every A/B here "diagnostic" (under 5 % with 3 pairs, or
within 1 %); the Hyrule 4-core arm had every switch-on run below every control run (76.99-77.04 against 77.49-78.09)
with the same placement in the window, inside the 1 % bar.

Risks

  • A wrong lend costs the render thread its core for at least one window: the replay runs about 1.7x slower on a
    shared core (the reason the core is kept). The take-back needs one 120-present window; loads take it back at once.
  • Affinity changes during play: at most 2 in any 20 s by construction; measured 0 in every window and 2 per scene
    change (title, loads).
  • Not covered:
    • no real 4C/8T or 6C/12T CPU, no Steam Deck, no Linux run, no hybrid CPU (masks of an 8-core CPU only);
    • V-Sync on (FIFO) and caps other than 60 not run; a limiter the host does not see (the game's own, a driver's) is
      not counted as pacing;
    • the three placement switches (#2240, #2360, this) never run together;
    • a process mask changed by another program during play: the take-back's threads keep the new mask (on main any
      change of the process mask in play does the same to every thread); on Linux the shim's process mask is the launch
      mask, so a take-back can widen threads taskset -a narrowed later;
    • thread start or rename racing a walk: the placement after a start or rename runs under the same lock and ends with
      the current mask;
    • RX_VK_PRESENTS_AHEAD=2 and a timed-out drain miscount the render thread's job time slightly (as the 600-present
      line does);
    • Zen 5 + Zen 5c on Linux without the hybrid PMU file reads as one kind (main's reserved-core rule has the same limit);
    • sessions past a few minutes, area changes beyond one teleport, full screen.
  • The Linux ended-thread refusal applies to every path, switch or not (above).
  • To turn it off: unset the switch. Unset makes main's affinity calls, reads no topology and logs nothing (tested,
    and the same placement thread for thread in the game). API 46 means the exe and the renderer go together, as every
    build ships them.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • MKWVK_API_VERSION bumped (MkwVkHost or MkwVkRenderer in gpu/vk/vk_api.h changed).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary From 8 logical processors the host keeps one whole core for the render thread, and no game thread may use it. On a CPU with 4 or 6 cores that is a quarter or a sixth of the CPU, held for a thread that in CPU-heavy scenes sleeps more than half the frame. This PR adds a switch, **`HOS_RESERVE_LEND=1`, off unless set**, that lends the reserved core to the game's threads while the render thread is idle, and takes it back when the render thread gets busy. Measured on one 8-core PC held to 4 and 6 cores by an affinity mask, it gets back what `HOS_RESERVE_CORE=0` gains in Lost Woods without losing what keeping the core gains in Hyrule Field. Whether it becomes a default is the maintainers' call after real 4- and 6-core CPUs have run it. **Where it acts.** Only when a core is reserved, the game may use fewer than 8 whole cores (counted as the reserved core's own rule counts them: inside the process's mask and the cache cores), and the cores are of one kind (a hybrid CPU declines). It also declines under `HOS_RESERVE_CORE_MASK` and `HOS_PIN_BY_CORE`. One log line at start says what it does or why it does nothing: `threads: HOS_RESERVE_LEND=1: the reserved core 0xc0 is lent to the game's threads while the render thread idles (...)` / `threads: HOS_RESERVE_LEND=1 does nothing here: <why>`. With threaded rendering off nothing asks the host, and the core stays kept as today. **The decision** (`gpu/vk/rt_lend.h`, a pure header, on the render thread, from its own job times over windows of presents): - **Lend:** two windows of 300 presents in a row with the render thread idle over 40 %, and the game paced at most 0.5 % of the window (a frame cap's waits are not idle: at a cap the core stays kept). - **Take back:** one window of 120 presents with the render thread idle under 30 % (the game's pacing is subtracted from idle, so a heavily paced window takes it back), or a window that decides nothing (a present over 250 ms, or under 20 presents a second: a load, a pause, a menu). - **No lend within 20 s after any take-back** (20 s of the windows' own time). This bounds the changes by construction: a lend, a take-back, then nothing for 20 s, so no 20 s holds more than two changes, whatever the scene does. Without it, three earlier rules each still cycled in some steady sequence (at the 60 cap with a large gain, uncapped with a large gain, or a long hitch every 10 s); with it a 20,000-run fuzz of random windows never had more than 2 changes in any 20 s. It changed none of the measured runs: the shortest take-back-to-lend gap in any game run was about 21.7 s. - On a change the host walks its thread table and sets each live game thread's mask to the lent or kept one (threads `HOS_PIN` places are skipped; threads made or renamed while lent get the lent mask). The render thread's own mask is not touched. A log line names each change and its reason (`vk: HOS_RESERVE_LEND: the reserved core lent to the game's threads|taken back: the render thread idle NN % ...`), and a line after the 600-present line counts them. **Also changed:** - **`MKWVK_API_VERSION` 45 -> 46:** `MkwVkHost` gains `reserved_lend`, appended. An exe and a renderer of different versions refuse each other, as before. `vk_api.h` is not a shader-cache stamp file: no re-prepare. - **`host/posix/win32_posix.c` (Linux), a change on every path:** `SetThreadAffinityMask` now takes the thread's lock and refuses a thread that has ended (`ERROR_INVALID_PARAMETER`, as Windows refuses one). This applies with the switch unset too, to every caller of the shim's call (`hos_thread_pin`, `pin_by_core`, the replay thread's pin, `RX_VK_RECORDER_PIN`). Why: an ended detached `pthread_t` may already name another thread, and setting its affinity could move that one. The existing callers set running threads' masks, so it refuses nothing they did before; a call on an ended thread used to reach `pthread_setaffinity_np` (undefined there) and now fails. It is one self-contained function and can be split into its own PR if preferred. - `host/nn_vi.c`: the host's frame pacing adds its planned sleep to a counter while the rule applies (no new clock read). `host/rx_backend.c`: the API field. `host/hos_thread.c`: the rule, the topology reader, the walk. `gpu/vk/vk_replay.cpp`: counting at the two job-timing sites and the present. `gpu/vk/switches.def`, `docs/dev/reference/switches.md`, `docs/dev/reference/threads.md`. Tests: `tests/test_reserved_lend.py` (new), `tests/test_reserved_core.py`, `tests/test_pacing_policy.py` (two stub definitions). **With our other two placement PRs** (neither on main): - **#2240 (`RX_VK_RT_HOME`):** this PR sets a `reserved_lent` flag with no reader yet. Whichever of the two merges second adds the one test in `rt_home_frame` (the home guard off while lent, its counters cleared at the take-back) and its case in `tests/test_rt_pin.py`. Both edit the same render-thread bullet in `threads.md`. - **#2360 (`HOS_WORKERS_SPREAD`):** the walk skips threads `HOS_PIN` places; the workers' set needs the same skip (`spread && !strncmp(name, "BaseProcExecutor", 16)`), added by whichever merges second. They can meet only at exactly 7 whole cores. - **One topology reader:** this PR's `lend_cores` and #2360's `worker_cores` read the same thing; whichever merges second should share one. This PR already folds the Linux reserved-core reader into one reader (`cpu_core_list`, `sys_cores`), with unset reading exactly what main read. - The three switches were never run together. Read first: `gpu/vk/rt_lend.h` (`decide`), then `host/hos_thread.c` (`lend_rule_cpus`, `lend_applies`, `hos_reserved_lend`, `hos_lend_affinity`), then `vk_replay.cpp`'s `lend_job` / `lend_present`. ## Testing **Tested:** Windows 11, Ryzen 7 5700X3D (8 cores, 16 threads), RX 9070 XT, AMD 26.11.2. The PR's build over main 0e32bc10 (the code of 297aa184; API 46; shaders byte-identical to main's), the switch on against `HOS_RESERVE_CORE=0` and against unset. **Every masked number is this 8-core CPU held to 4 cores (`0xff`) or 6 cores (`0xfff`) by an affinity mask, not a real 4- or 6-core CPU.** Each A/B is 3 alternating pairs, the fixed test profile, a fixed light GPU load beside the game, uncapped unless marked. Lost Woods and Hyrule Field are kept apart. - **The masked numbers rely on a harness fix:** the test harness used to set the game's affinity mask again after the launch, which put 21 early threads (the main thread, the Presentation thread, the loaders) back on the reserved core in every "kept" arm. From the second round on it no longer does, so unset arms have every game thread off the reserved core, as on a player's PC. The first round's larger gains (+8.4 / +6.3 %) were against that partly-kept control and are not quoted. - **Lost Woods (Measurements):** lent before the window in every switch-on run, 0 changes in any window. - **Hyrule Field:** within 1 % of today on both masks; kept for the whole window in every switch-on run, masks as the control's. - **The 60 cap** (`0xff`, Lost Woods and Hyrule, 3 pairs each, two rounds): fps flat (59.9-60.0 both arms), kept, 0 changes after the save load. - **Unset is main:** Lost Woods `0xff`, the PR's build unset against main's: 64.49 vs 64.49 fps; the placement of every thread identical by name and mask in all 6 runs; no log line. - **Crossing scenes** (title, save load, Lost Woods, teleport to Hyrule Field): lent at the title, taken back at the save load, lent in Lost Woods, taken back at the teleport; the long frames are the loads', no worse than the control's. - Frames over 50/100/250 ms: 0/0/0 in every uncapped switch-on run of the A/Bs; clock 0.998-1.002; no error lines. - **`tests/test_reserved_lend.py`** (llvm-mingw clang and MSYS2 gcc): the real `rt_lend.h` over window sequences (lend, take-back, loads, the 60 cap, steady cycles and periodic hitches each held to at most 2 changes in any 20 s, the 20 s quiet and its edge, the pacing veto's level); the host's rule and walk over stubbed topologies and thread tables (masks inside the process's mask and cache cores, `HOS_PIN` threads untouched, threads made while lent, declines); the two renderer call sites cut from `vk_replay.cpp` and run. 26 broken variants, each failing; a `static_assert` pins the constants an equivalence argument depends on. It fails on main. - **After merging main 8aa5ab87:** main merged cleanly (35 commits, among them `threads.md`, `vk_main.cpp`, `vk_replay.cpp`, `hos_thread.c`: no conflict); on the merged head `tests/test_reserved_lend.py` passes with clang and gcc (26 broken variants fail), and the focused checks pass (`test_reserved_core`, `test_reserved_core_mask`, `test_fps_stats`, `test_frame_overlap`, `test_threaded_rendering`, `test_switch_table`, `test_env_on`, `test_switches_removed`, `test_doc_anchors`, `test_hos_ab`, `byte_compile`). `run_all.py --changed 8aa5ab87`: 277 passed, 13 failed; each failure also fails on main (four of them, `test_menu_text_field`, `test_rdna2_mesh_only`, `test_rumble_menu`, `test_vibration_menu`, fail on main 8aa5ab87 itself; the rest on this PC on 0e32bc10 too). The changed host files compile whole (MSVC-target clang, llvm-mingw with main's warning counts, Linux clang and gcc); `nn_vi.c` shows only the two `rx_option` errors main's file has against the same headers. Not re-run in the game after the merge (the merge changed no line this PR adds). - `mise run lint`: only main's shellcheck SC2016 on `.forgejo/workflows/build-windows.yml:82`. **Still to test:** - Windows, a real 4-core / 8-thread CPU and a real 6-core / 12-thread CPU: `HOS_RESERVE_LEND=1` against `0` on the PR's build, Lost Woods and Hyrule Field, uncapped, 3 starts a cell, expecting Lost Woods up, Hyrule level, no long frames (@Beanstalk). - The same at the 60 cap, one run, counting the log's `HOS_RESERVE_LEND` lines, expecting none after the save load (@Beanstalk). - The Steam Deck (Linux, 4 cores / 8 threads): the same as the 4-core case; while lent the render thread shares its core there (@Beanstalk, if a Deck tester is online). ## Measurements **Verdict:** on this PC's 4- and 6-core masks, Lost Woods gains +5.6 % and +5.4 % against today (unset), within 0.5 % of `HOS_RESERVE_CORE=0`; Hyrule Field stays within 1 % of today; the 60 cap is unchanged. Off by default. Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2. Lost Woods as child (the profile save, then the teleport), fast rotation, 16:9, `RX_VK_ASYNC=1`, frame rate unlocked (`HOS_FPS_MAX=240`), the fixed test profile and GPU load, 20 s window, 3 alternating pairs, medians, the game's mask set at launch (`--affinity`). Before: main's placement (the PR's build unset, shown equal to main's above, or main's own build); After: the PR's build with `HOS_RESERVE_LEND=1`. | | Before: main @ 0e32bc10 | After: this PR @ 297aa184, `HOS_RESERVE_LEND=1` | |---|---|---| | Lost Woods, 4 cores (`0xff`), fps median | 64.24 | **67.84 (+5.6 %)** | | Lost Woods, 6 cores (`0xfff`), fps median | 75.59 | **79.64 (+5.4 %)** | | Lost Woods, 4 cores, CPU ms a frame | 75.68 | 73.51 | | Lost Woods, 6 cores, CPU ms a frame | 63.55 | 61.04 | | Hyrule Field, 4 cores, fps median | 77.54 | 77.04 (-0.6 %) | | Hyrule Field, 6 cores, fps median | 83.04 | 83.29 (+0.3 %) | | frames over 50 / 100 / 250 ms (switch on, all 18 runs) | | 0 / 0 / 0 | Against `HOS_RESERVE_CORE=0` (the core never kept), Lost Woods: 4 cores 69.09 -> 68.79 (-0.43 %) and, on the final code, 67.54 -> 67.29 (-0.37 %); 6 cores 79.74 -> 79.39 (-0.44 %). The 60 cap: Lost Woods 60.00 / 59.99 and Hyrule 59.99 / 59.94 fps (control / on), 0 changes after the save load. The first four rows are from the round before the 20 s quiet (head 47b18d90); the quiet changes none of those runs (their shortest take-back-to-lend gap was 21.7 s), and the final code was re-measured against `=0` (-0.37 %). Std_test labels every A/B here "diagnostic" (under 5 % with 3 pairs, or within 1 %); the Hyrule 4-core arm had every switch-on run below every control run (76.99-77.04 against 77.49-78.09) with the same placement in the window, inside the 1 % bar. ## Risks - **A wrong lend costs the render thread its core** for at least one window: the replay runs about 1.7x slower on a shared core (the reason the core is kept). The take-back needs one 120-present window; loads take it back at once. - **Affinity changes during play:** at most 2 in any 20 s by construction; measured 0 in every window and 2 per scene change (title, loads). - **Not covered:** - no real 4C/8T or 6C/12T CPU, no Steam Deck, no Linux run, no hybrid CPU (masks of an 8-core CPU only); - V-Sync on (FIFO) and caps other than 60 not run; a limiter the host does not see (the game's own, a driver's) is not counted as pacing; - the three placement switches (#2240, #2360, this) never run together; - a process mask changed by another program during play: the take-back's threads keep the new mask (on main any change of the process mask in play does the same to every thread); on Linux the shim's process mask is the launch mask, so a take-back can widen threads `taskset -a` narrowed later; - thread start or rename racing a walk: the placement after a start or rename runs under the same lock and ends with the current mask; - `RX_VK_PRESENTS_AHEAD=2` and a timed-out drain miscount the render thread's job time slightly (as the 600-present line does); - Zen 5 + Zen 5c on Linux without the hybrid PMU file reads as one kind (main's reserved-core rule has the same limit); - sessions past a few minutes, area changes beyond one teleport, full screen. - **The Linux ended-thread refusal** applies to every path, switch or not (above). - **To turn it off:** unset the switch. Unset makes main's affinity calls, reads no topology and logs nothing (tested, and the same placement thread for thread in the game). API 46 means the exe and the renderer go together, as every build ships them. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] `MKWVK_API_VERSION` bumped (`MkwVkHost` or `MkwVkRenderer` in `gpu/vk/vk_api.h` changed). - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
From 8 logical processors one whole core is kept from the game's threads for the render thread. On a CPU with few cores
that is a large share of the game's, and where the game's threads hold the frame the render thread sleeps more than half
of it (Lost Woods on 4 cores of 2: 64.59 fps kept, 70.14 with HOS_RESERVE_CORE=0, the render thread idle 57-59 %); where
the render thread holds the frame the core pays (Hyrule Field, 4 cores: 78.04 kept, 75.64 without, idle about 16 %).

With the switch on, the render thread decides from its own idle share (gpu/vk/rt_lend.h: lend above 40 % for two windows
of 300 presents, take back below 30 % in one window of 120; the game's frame-pacing sleeps are not idle, and a paced
window never lends; a window with a present over 250 ms or under 20 presents a second decides nothing) and asks the host
through a new MkwVkHost reserved_lend (MKWVK_API_VERSION 46). The host (host/hos_thread.c hos_reserved_lend) gives each
live game thread the mask hos_thread_pin would give it with no core reserved, or takes it back; threads placed meanwhile
get the state's mask; a thread HOS_PIN places is never moved. Only where a core is reserved, the game may use fewer than
8 whole cores and they are of one kind; not with HOS_RESERVE_CORE_MASK or HOS_PIN_BY_CORE. win32_posix.c's
SetThreadAffinityMask now refuses an ended thread, as Windows does. Unset or 0: main's calls.

tests/test_reserved_lend.py: the real decision over window sequences and the real host code over a stub thread table,
with eight broken variants that must fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- At the 60 cap the core flapped (Lost Woods, 4 cores: kept, the game paced 5-6 % and the core was lent; lent, 11-12 %
  and it was taken back; 4 changes in every 20 s). A window the limiter held at all (over 0.5 %) no longer lends; over
  10 % still takes a lent core back. Uncapped, every window that lent had no pacing.
- vk_main.cpp's copy ladder has a rung for version 46, and the render thread asks reserved_lend only from a host of 46.
- A reserved core outside the cores the game may use (the cache cores) is no core to lend: the rule declines.
- The walk works the masks out at each change from the process's mask as it is then (a launcher may change it in play),
  and says when a thread could not be moved.
- A HOS_PIN mask the system refuses no longer keeps its thread out of the walk.
- One reader of the cores: group_cores (Windows) and sys_cores (Linux), shared by last_fastest_core and HOS_RESERVE_LEND.
- The lend and take-back lines carry now_ns.
- tests/test_reserved_lend.py: the 60 cap's sequence, the new host cases, and lend_job/lend_present cut whole over a stub
  host (the first present only asks, windows of 300/120, a 300 ms present, the pacing delta, a host that says no, a host
  of 45); 16 broken variants, the held present's call among them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Just under a cap the round-2 rule flapped (sol r2): kept, the game paced 0.4 % and the core was lent; lent, it reached
  the cap and paced 11 % and the core was taken back; 26 changes in 161 s at 60 fps. A lent core is now taken back only
  when the render thread's idle falls under 30 %, or by a window that decides nothing (a present over 250 ms, under 20
  presents a second: a load, a pause, a menu), so the title screen's lend is taken back at the save's load. The lend's
  0.5 % pacing veto stays.
- Linux: the cpu_core file is read before the cores (cpu_core_list), so a CPU without it reads nothing more than main.
- tests/test_reserved_lend.py: the flap sequence, the title-then-load sequence, both call sites of the render thread cut
  and run in the fixture (busy, held-only, deferred presents); 21 broken variants, sol r2's if (false) lend_job(job);
  among them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- No lend within 20 s of the windows' time after a take-back (the high windows still count meanwhile): any 20 s holds at
  most two changes, whatever the scene does. Sol r3's steady cycles (the 60 cap with 9.5 / 10 ms of render jobs and 0.4 /
  11 % pacing; uncapped with 9 ms of jobs at 16 / 12 ms frames) and a 300 ms hitch every 10 s are now bounded. The
  shortest take-back-to-lend gap measured in any run was about 21.7 s, so no measured run changes.
- The comment says what the code does: pacing is subtracted from idle, so a heavily paced window takes a lent core back
  (that is how the title's lend is returned at the save's load).
- The held present's run reads the clock once (as main), with the switch set or not.
- tests/test_reserved_lend.py: the three cycles (at most two changes in any 20 s), the measured gap, the pacing veto's
  level, the hold's own statement (deferred = true) cut and run; 25 broken variants.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A decision case from sol r4: lent, taken back by a 0.5 s window, then qualifying windows of 9.375 and 9.625 s (19.0 s)
  must not lend yet; with a 19 s quiet that is three changes in 19.5 s. A broken variant with a 19 s quiet fails at it.
- A static_assert that kLendWindows is 2 and a qualifying kept window is shorter than the quiet: the premises of the
  argument (impl.md round 4) that removing the high count's reset on a lend changes no outcome. A lockstep fuzz found no
  difference with the shipped constants (10 M windows) and 237 differing runs in 50,000 with kLendWindows = 3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge origin/main (8aa5ab87) into perf/reserved-core-lent-while-idle
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 10s
PR description / Description follows the template (pull_request_target) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Website build and checks (pull_request) Failing after 56s
beanstalk/approval approved by klimovich008 (reviewed)
beanstalk/windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k 0/1 pass, 0 running, 2 queued
beanstalk/windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 2/1 pass
d453599b04
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11, Ryzen 7 5700X3D (8C/16T) held to 4 cores (0xff) and 6 cores (0xfff) by an affinity mask, RX 9070 XT, AMD 26.11.2; not a real 4- or 6-core CPU. 3 alternating pairs each, uncapped (HOS_FPS_MAX=240), RX_VK_ASYNC=1, the fixed test profile. Lost Woods (child): +5.6 % (0xff) and +5.4 % (0xfff) against unset, within 0.5 % of HOS_RESERVE_CORE=0 (final code: -0.37 % on 0xff); Hyrule Field within 1 % of today on both masks; the 60 cap flat in both scenes; 0 lend/take-back changes inside any measured window; 0 frames over 50 ms in the uncapped switch-on runs; clock 0.998-1.002; unset = main thread for thread. Crossing run (title, save load, Lost Woods, teleport to Hyrule Field): changes only at the title and the loads. Not run: real 4C/8T or 6C/12T CPUs, the Steam Deck, Linux, V-Sync on, other caps, with #2240 or #2360.

Tested in game: Windows 11, Ryzen 7 5700X3D (8C/16T) held to 4 cores (0xff) and 6 cores (0xfff) by an affinity mask, RX 9070 XT, AMD 26.11.2; not a real 4- or 6-core CPU. 3 alternating pairs each, uncapped (HOS_FPS_MAX=240), RX_VK_ASYNC=1, the fixed test profile. Lost Woods (child): +5.6 % (0xff) and +5.4 % (0xfff) against unset, within 0.5 % of HOS_RESERVE_CORE=0 (final code: -0.37 % on 0xff); Hyrule Field within 1 % of today on both masks; the 60 cap flat in both scenes; 0 lend/take-back changes inside any measured window; 0 frames over 50 ms in the uncapped switch-on runs; clock 0.998-1.002; unset = main thread for thread. Crossing run (title, save load, Lost Woods, teleport to Hyrule Field): changes only at the title and the loads. Not run: real 4C/8T or 6C/12T CPUs, the Steam Deck, Linux, V-Sync on, other caps, with #2240 or #2360.
Author
Member

@Beanstalk the PR's own build only, its switch against itself: baseline ref = pr, [matrix.pr_only] HOS_RESERVE_LEND = ["0", "1"], and pass.compare HOS_RESERVE_LEND = "1" against "0" on the pr side (0 is exactly unset: today's placement). It is a runtime switch, so one build serves both sides. 3 game starts a cell.

What it does: on CPUs with fewer than 8 whole cores and 8 or more logical processors, the host keeps one core for the render thread; with the switch on it lends that core to the game's threads while the render thread is idle and takes it back when it gets busy. On 8+ cores, hybrid CPUs or without SMT it declines (logged), so only these targets can show anything. Our numbers are an 8-core CPU held to 4 and 6 cores by a mask; we need real ones.

Targets, 1-2 reports each, by model; don't let the plan wait on any one:

  • Windows, 4 cores / 8 threads: i7-6700K, i7-7700K, i7-6700, i7-7700, i3-10100, i3-12100, i3-13100, Ryzen 3 3300X;
  • Windows, 6 cores / 12 threads: Ryzen 5 3600, 5600X, 5600, 7600X, 7600, i5-10400, i5-11400, i7-8700K;
  • the Steam Deck (4 cores / 8 threads, Linux), if a tester with that tag is online.

Scenes, in one start: Lost Woods as child Link (from the save kokiri-start, teleport destination 5) measured 30 s, where the game's threads hold the frame (expect a gain); then Hyrule Field (HyruleField_Child) measured 30 s, where the render thread holds it (expect level). Settings: frame_rate_cap = 6 (Uncapped), vsync = 2 (Off), frame_generation = 0; headless is fine. Compare rules, pr side, =1 vs =0, per scene: fps_mean min_delta_pct = 3 (fail on a loss of more than 3 %), frametime_p99_ms max_delta_pct = 10; crash = false. Hitch counts (run_hitch_count, run_frametime_max_ms) report-only.

Plus one start a side at the 60 fps cap (frame_rate_cap at 60, vsync off), the same scenes, on the 4C/8T target if it fits the time (else any of the three): report-only, counting the log lines "vk: HOS_RESERVE_LEND: the reserved core lent" and "... taken back" in the =1 start. Expected at the cap: one lend at the title screen and one take-back at the save load, then none in play.

Log on the =1 cells: "threads: HOS_RESERVE_LEND=1: the reserved core" expected on these targets ("does nothing here" on a PC where the rule doesn't apply: please show which line came).

@Beanstalk the PR's own build only, its switch against itself: baseline ref = pr, [matrix.pr_only] HOS_RESERVE_LEND = ["0", "1"], and [[pass.compare]] HOS_RESERVE_LEND = "1" against "0" on the pr side (0 is exactly unset: today's placement). It is a runtime switch, so one build serves both sides. **3 game starts a cell.** What it does: on CPUs with fewer than 8 whole cores and 8 or more logical processors, the host keeps one core for the render thread; with the switch on it lends that core to the game's threads while the render thread is idle and takes it back when it gets busy. On 8+ cores, hybrid CPUs or without SMT it declines (logged), so only these targets can show anything. Our numbers are an 8-core CPU held to 4 and 6 cores by a mask; we need real ones. Targets, 1-2 reports each, by model; don't let the plan wait on any one: - Windows, 4 cores / 8 threads: i7-6700K, i7-7700K, i7-6700, i7-7700, i3-10100, i3-12100, i3-13100, Ryzen 3 3300X; - Windows, 6 cores / 12 threads: Ryzen 5 3600, 5600X, 5600, 7600X, 7600, i5-10400, i5-11400, i7-8700K; - the Steam Deck (4 cores / 8 threads, Linux), if a tester with that tag is online. Scenes, in one start: Lost Woods as child Link (from the save kokiri-start, teleport destination 5) measured 30 s, where the game's threads hold the frame (expect a gain); then Hyrule Field (HyruleField_Child) measured 30 s, where the render thread holds it (expect level). Settings: frame_rate_cap = 6 (Uncapped), vsync = 2 (Off), frame_generation = 0; headless is fine. Compare rules, pr side, =1 vs =0, per scene: fps_mean min_delta_pct = 3 (fail on a loss of more than 3 %), frametime_p99_ms max_delta_pct = 10; crash = false. Hitch counts (run_hitch_count, run_frametime_max_ms) report-only. Plus one start a side at the 60 fps cap (frame_rate_cap at 60, vsync off), the same scenes, on the 4C/8T target if it fits the time (else any of the three): report-only, counting the log lines "vk: HOS_RESERVE_LEND: the reserved core lent" and "... taken back" in the =1 start. Expected at the cap: one lend at the title screen and one take-back at the save load, then none in play. Log on the =1 cells: "threads: HOS_RESERVE_LEND=1: the reserved core" expected on these targets ("does nothing here" on a PC where the rule doesn't apply: please show which line came).
Member

Beanstalk test farm · 🔄 testing (2 of 3 reports so far)

Commit d453599 · approved by klimovich008 (reviewed) · dashboard

⚠️ Note: The requested three starts per cell and an additional capped run exceed the 60-minute limit with this two-cell matrix, so the plan uses two starts per cell and omits the capped run.
⚠️ Note: Log counts show whether lending applied or was declined and how often transitions occurred, but do not establish exactly when transitions happened within a scene.
⚠️ Note: Using only the PR build does not compare its switch-off changes, including the Linux affinity shim, against main.

Started at 05:03 UTC.

Target Result Reports VRAM peak (MB) Crashes
windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k (CPU "3300x" or "i3 10100" or "i3 12100" or "i3 13100" or "i7 6700" or "i7 6700k" or "i7 7700" or "i7 7700k") ⏳ queued 0 of 1 — —
windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k (CPU "3600" or "5600" or "5600x" or "7600" or "7600x" or "i5 10400" or "i5 11400" or "i7 8700k") ⏳ queued 0 of 1 — —
steamdeck ✅ pass 2 1 2 — none

uncapped-scenes · frame time p99 (ms)

Target switch off HOS_RESERVE_LEND=0 (reference) HOS_RESERVE_LEND=1
windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k (CPU "3300x" or "i3 10100" or "i3 12100" or "i3 13100" or "i7 6700" or "i7 6700k" or "i7 7700" or "i7 7700k") — — —
windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k (CPU "3600" or "5600" or "5600x" or "7600" or "7600x" or "i5 10400" or "i5 11400" or "i7 8700k") — — —
steamdeck 58.4 58.3 58.3 (+0%)
What was tested

What will be tested · AI plan (gpt-6.1-terra)

On real 4-core and 6-core Windows CPUs and the Steam Deck, the PR build will run with core lending off and on, measuring 30 seconds each in child Lost Woods and Hyrule Field with the frame cap disabled. Two starts per cell provide FPS and frame-time comparisons, while hitch metrics and lending log counts are reported. A crash, an FPS loss over 3%, or a p99 frame-time increase over 10% in either scene fails the test. The Windows CPU groups have no matching models listed online and will wait for eligible testers; Steam Deck testers are online. No tester online now matches windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k, windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k: those targets wait for one.

  • Where: windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k (CPU "3300x" or "i3 10100" or "i3 12100" or "i3 13100" or "i7 6700" or "i7 6700k" or "i7 7700" or "i7 7700k", 1-2 reports), windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k (CPU "3600" or "5600" or "5600x" or "7600" or "7600x" or "i5 10400" or "i5 11400" or "i7 8700k", 1-2 reports), steamdeck (1-2 reports).
  • Against: the PR itself, switch on (HOS_RESERVE_LEND) and off; main is not built or run.
  • Matrix: 2 cells, each with the switch on and off: HOS_RESERVE_LEND 0 or 1 (PR only).
  • uncapped-scenes: from the repository's save kokiri-start (settings vsync=2, frame_rate_cap=6, frame_generation=0), then teleport to Lost Woods, measure lost-woods for 30 s (after 25 s warm-up), teleport to Hyrule Field, measure hyrule-field for 30 s (after 10 s warm-up); 2 runs on each side for each of 2 cells (2 game starts a run).
  • Measured: crashes, frame times, stutters and hitches, draws and frame rate, numbers from the game's log.
  • The PR fails if: it crashes; or the PR's frame rate with HOS_RESERVE_LEND=1 is more than 3% below HOS_RESERVE_LEND=0; or the PR's frame time (p99) with HOS_RESERVE_LEND=1 is more than 10% above HOS_RESERVE_LEND=0.
  • Time: about 53 min of game runs per tester (8 game starts), plus the two builds.
Measurements on `steamdeck`, for the PR description

Verdict: pass on steamdeck (2 reports): no rule failed and no PR run crashed.

Hardware: 1: linux+amd+radv+igpu+handheld AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99 AMD Custom APU 0405, 12 GB RAM; 2: linux+amd+radv+igpu+handheld AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99 AMD Custom APU 0405, 12 GB RAM
Scene: uncapped-scenes, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6, frame_generation=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: this PR built once and run with its PR-only switches on and off on the same PC in one session, game starts alternating (ABBA); uncapped-scenes: 2 game starts a side, lost-woods 30 s after 25 s warm-up, hyrule-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 (@Beanstalk on this PR runs it again)

Before: this PR @ d453599, switch off After: this PR @ d453599, switch on
uncapped-scenes · HOS_RESERVE_LEND=0 (PR only) · lost-woods · frame time (p99) (ms) 58.4 58.3 (−0%)
uncapped-scenes · HOS_RESERVE_LEND=0 (PR only) · hyrule-field · frame time (p99) (ms) 41.8 42.3 (+1%)
uncapped-scenes · HOS_RESERVE_LEND=1 (PR only) · lost-woods · frame time (p99) (ms) 57.6 58.3 (+1%)
uncapped-scenes · HOS_RESERVE_LEND=1 (PR only) · hyrule-field · frame time (p99) (ms) 42.5 41.9 (−2%)

Flags and settings

Flag What it is Values tried Before this PR After this PR Effect (frame time (p99)) Helps / doesn't help / untested
HOS_RESERVE_LEND switch the PR adds (set on the PR side only) 0, 1 off (the switch's default) the PR's default uncapped-scenes, main without it → the PR with 0: 58.4 → 58.3 (−0%) no clear effect

As Markdown for the PR description:

## Measurements

**Verdict:** pass on steamdeck (2 reports): no rule failed and no PR run crashed.

Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 12 GB RAM`; 2: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 12 GB RAM`  
Scene: uncapped-scenes, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6, frame_generation=0); each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: this PR built once and run with its PR-only switches on and off on the same PC in one session, game starts alternating (ABBA); uncapped-scenes: 2 game starts a side, lost-woods 30 s after 25 s warm-up, hyrule-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 (`@Beanstalk` on this PR runs it again)

| | Before: this PR @ d453599, switch off | After: this PR @ d453599, switch on |
|---|---|---|
| uncapped-scenes · `HOS_RESERVE_LEND=0 (PR only)` · lost-woods · frame time (p99) (ms) | 58.4 | 58.3 (−0%) |
| uncapped-scenes · `HOS_RESERVE_LEND=0 (PR only)` · hyrule-field · frame time (p99) (ms) | 41.8 | 42.3 (+1%) |
| uncapped-scenes · `HOS_RESERVE_LEND=1 (PR only)` · lost-woods · frame time (p99) (ms) | 57.6 | 58.3 (+1%) |
| uncapped-scenes · `HOS_RESERVE_LEND=1 (PR only)` · hyrule-field · frame time (p99) (ms) | 42.5 | 41.9 (−2%) |

**Flags and settings**

| Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested |
|---|---|---|---|---|---|---|
| `HOS_RESERVE_LEND` | switch the PR adds (set on the PR side only) | `0`, `1` | off (the switch's default) | the PR's default | uncapped-scenes, main without it → the PR with 0: 58.4 → 58.3 (−0%) | no clear effect |
The testers' hardware
Target Report Ran on
steamdeck 1 linux+amd+radv+igpu+handheld AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99 AMD Custom APU 0405, 12 GB RAM
steamdeck 2 linux+amd+radv+igpu+handheld AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99 AMD Custom APU 0405, 12 GB RAM
<!-- beanstalk:sticky --> ### Beanstalk test farm · 🔄 testing (2 of 3 reports so far) Commit `d453599` · approved by klimovich008 (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/2436) ⚠️ **Note:** The requested three starts per cell and an additional capped run exceed the 60-minute limit with this two-cell matrix, so the plan uses two starts per cell and omits the capped run. ⚠️ **Note:** Log counts show whether lending applied or was declined and how often transitions occurred, but do not establish exactly when transitions happened within a scene. ⚠️ **Note:** Using only the PR build does not compare its switch-off changes, including the Linux affinity shim, against main. Started at 05:03 UTC. | Target | Result | Reports | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | | `windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k` (CPU "3300x" or "i3 10100" or "i3 12100" or "i3 13100" or "i7 6700" or "i7 6700k" or "i7 7700" or "i7 7700k") | ⏳ queued | 0 of 1 | — | — | | `windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k` (CPU "3600" or "5600" or "5600x" or "7600" or "7600x" or "i5 10400" or "i5 11400" or "i7 8700k") | ⏳ queued | 0 of 1 | — | — | | `steamdeck` | ✅ pass | 2 [1](https://beanstalk.magicbean.dev/reports/rp_337b376f305bfbad) [2](https://beanstalk.magicbean.dev/reports/rp_52675fee323b35ec) | — | none | **`uncapped-scenes`** · frame time p99 (ms) | Target | switch off | `HOS_RESERVE_LEND=0` (reference) | `HOS_RESERVE_LEND=1` | | --- | --- | --- | --- | | `windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k` (CPU "3300x" or "i3 10100" or "i3 12100" or "i3 13100" or "i7 6700" or "i7 6700k" or "i7 7700" or "i7 7700k") | — | — | — | | `windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k` (CPU "3600" or "5600" or "5600x" or "7600" or "7600x" or "i5 10400" or "i5 11400" or "i7 8700k") | — | — | — | | `steamdeck` | 58.4 | 58.3 | 58.3 (+0%) | <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) On real 4-core and 6-core Windows CPUs and the Steam Deck, the PR build will run with core lending off and on, measuring 30 seconds each in child Lost Woods and Hyrule Field with the frame cap disabled. Two starts per cell provide FPS and frame-time comparisons, while hitch metrics and lending log counts are reported. A crash, an FPS loss over 3%, or a p99 frame-time increase over 10% in either scene fails the test. The Windows CPU groups have no matching models listed online and will wait for eligible testers; Steam Deck testers are online. No tester online now matches windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k, windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k: those targets wait for one. - **Where:** windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k (CPU "3300x" or "i3 10100" or "i3 12100" or "i3 13100" or "i7 6700" or "i7 6700k" or "i7 7700" or "i7 7700k", 1-2 reports), windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k (CPU "3600" or "5600" or "5600x" or "7600" or "7600x" or "i5 10400" or "i5 11400" or "i7 8700k", 1-2 reports), steamdeck (1-2 reports). - **Against:** the PR itself, switch on (`HOS_RESERVE_LEND`) and off; main is not built or run. - **Matrix:** 2 cells, each with the switch on and off: HOS_RESERVE_LEND `0` or `1` (PR only). - **uncapped-scenes:** from the repository's save `kokiri-start` (settings vsync=2, frame_rate_cap=6, frame_generation=0), then teleport to Lost Woods, measure lost-woods for 30 s (after 25 s warm-up), teleport to Hyrule Field, measure hyrule-field for 30 s (after 10 s warm-up); 2 runs on each side for each of 2 cells (2 game starts a run). - **Measured:** crashes, frame times, stutters and hitches, draws and frame rate, numbers from the game's log. - **The PR fails if:** it crashes; or the PR's frame rate with HOS_RESERVE_LEND=1 is more than 3% below HOS_RESERVE_LEND=0; or the PR's frame time (p99) with HOS_RESERVE_LEND=1 is more than 10% above HOS_RESERVE_LEND=0. - **Time:** about 53 min of game runs per tester (8 game starts), plus the two builds. </details> <details><summary>Measurements on `steamdeck`, for the PR description</summary> **Verdict:** pass on steamdeck (2 reports): no rule failed and no PR run crashed. Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 12 GB RAM`; 2: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 12 GB RAM` Scene: uncapped-scenes, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6, frame_generation=0); each cell's settings and switches as the table names them Method: the Beanstalk test farm: this PR built once and run with its PR-only switches on and off on the same PC in one session, game starts alternating (ABBA); uncapped-scenes: 2 game starts a side, lost-woods 30 s after 25 s warm-up, hyrule-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 (`@Beanstalk` on this PR runs it again) | | Before: this PR @ d453599, switch off | After: this PR @ d453599, switch on | |---|---|---| | uncapped-scenes · `HOS_RESERVE_LEND=0 (PR only)` · lost-woods · frame time (p99) (ms) | 58.4 | 58.3 (−0%) | | uncapped-scenes · `HOS_RESERVE_LEND=0 (PR only)` · hyrule-field · frame time (p99) (ms) | 41.8 | 42.3 (+1%) | | uncapped-scenes · `HOS_RESERVE_LEND=1 (PR only)` · lost-woods · frame time (p99) (ms) | 57.6 | 58.3 (+1%) | | uncapped-scenes · `HOS_RESERVE_LEND=1 (PR only)` · hyrule-field · frame time (p99) (ms) | 42.5 | 41.9 (−2%) | **Flags and settings** | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `HOS_RESERVE_LEND` | switch the PR adds (set on the PR side only) | `0`, `1` | off (the switch's default) | the PR's default | uncapped-scenes, main without it → the PR with 0: 58.4 → 58.3 (−0%) | no clear effect | As Markdown for the PR description: ```markdown ## Measurements **Verdict:** pass on steamdeck (2 reports): no rule failed and no PR run crashed. Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 12 GB RAM`; 2: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 12 GB RAM` Scene: uncapped-scenes, from the repository's save kokiri-start (vsync=2, frame_rate_cap=6, frame_generation=0); each cell's settings and switches as the table names them Method: the Beanstalk test farm: this PR built once and run with its PR-only switches on and off on the same PC in one session, game starts alternating (ABBA); uncapped-scenes: 2 game starts a side, lost-woods 30 s after 25 s warm-up, hyrule-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 (`@Beanstalk` on this PR runs it again) | | Before: this PR @ d453599, switch off | After: this PR @ d453599, switch on | |---|---|---| | uncapped-scenes · `HOS_RESERVE_LEND=0 (PR only)` · lost-woods · frame time (p99) (ms) | 58.4 | 58.3 (−0%) | | uncapped-scenes · `HOS_RESERVE_LEND=0 (PR only)` · hyrule-field · frame time (p99) (ms) | 41.8 | 42.3 (+1%) | | uncapped-scenes · `HOS_RESERVE_LEND=1 (PR only)` · lost-woods · frame time (p99) (ms) | 57.6 | 58.3 (+1%) | | uncapped-scenes · `HOS_RESERVE_LEND=1 (PR only)` · hyrule-field · frame time (p99) (ms) | 42.5 | 41.9 (−2%) | **Flags and settings** | Flag | What it is | Values tried | Before this PR | After this PR | Effect (frame time (p99)) | Helps / doesn't help / untested | |---|---|---|---|---|---|---| | `HOS_RESERVE_LEND` | switch the PR adds (set on the PR side only) | `0`, `1` | off (the switch's default) | the PR's default | uncapped-scenes, main without it → the PR with 0: 58.4 → 58.3 (−0%) | no clear effect | ``` </details> <details><summary>The testers' hardware</summary> | Target | Report | Ran on | | --- | --- | --- | | `steamdeck` | [1](https://beanstalk.magicbean.dev/reports/rp_337b376f305bfbad) | linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 12 GB RAM` | | `steamdeck` | [2](https://beanstalk.magicbean.dev/reports/rp_52675fee323b35ec) | linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 12 GB RAM` | </details>
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 10s
PR description / Description follows the template (pull_request_target) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Website build and checks (pull_request) Failing after 56s
beanstalk/approval approved by klimovich008 (reviewed)
beanstalk/windows+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k 0/1 pass, 0 running, 2 queued
beanstalk/windows+cpu-3600_5600_5600x_7600_7600x_i5-10400_i5-11400_i7-8700k 0/1 pass, 0 running, 2 queued
beanstalk/steamdeck 2/1 pass
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/reserved-core-lent-while-idle:klimovich008-perf/reserved-core-lent-while-idle'
git switch 'klimovich008-perf/reserved-core-lent-while-idle'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2436
No description provided.