perf(vk): Threaded rendering's Auto chooses by physical cores, in three tiers #1664

Merged
HumanBean merged 1 commit from GummiNaomi/Longshot:perf/threaded-auto-cores into main 2026-11-18 22:02:05 +00:00
Member

Type: perf · Risk: medium · Tested on: Windows 11, RTX 4070 SUPER, Ryzen 9 9950X3D (SMT off, held to 4, 6 and 8 cores) · Needs: a build of this head; CPUs with SMT (4c/8t, 6c/12t, 8c/16t); Linux; a Steam Deck

TL;DR

Threaded rendering's Auto turned the render thread and the recorder thread on together from 12 logical processors, and left everything below on the slow serial path. Measured by core count on one CPU, the render thread alone already helps on 4 cores, both threads help from 6 cores, and both threads on 4 cores make it worse. This PR makes Auto choose by physical cores in three steps: under 4 off, 4 or 5 the render thread only, 6 or more both. On my PC held to 4, 6 and 8 cores that is +2.3, +4.8 and +6.1 fps over today's Auto, with fewer long frames.

Breakdown

  • Who it helps: players with 4 to 11 logical processors and a discrete card: 4 to 5 cores get the render thread, 6 to 11 logical processors without SMT get both threads.
  • What was wrong: Auto's threshold of 12 logical processors left 6-to-8-core CPUs without SMT on the serial replay, and it counted SMT threads as cores.
  • What changes: Auto counts physical cores (an SMT core's two threads once): under 4 off, 4-5 the render thread only, 6+ the render thread and the recorder thread.
  • What does not change: On and Off; RX_VK_ASYNC and RX_VK_RECORDER still choose over Auto; the unsafe gate (no buffer pool mirrors: integrated GPUs, the Steam Deck) still turns Auto off; 12+ logical processors with 6+ cores choose as before.
  • How it was checked: two runs of each of the three ways at 4, 6 and 8 cores standing in Castle Town's market; then the built rule choosing by itself at 4, 6, 8 and 16; the rule, the core count and the readers compiled in tests with 20 broken copies.
  • What is still open: CPUs with SMT on, Linux, Wine/Proton, a build of this head.
  • Risk: medium: 4-to-11-processor PCs with a discrete card change their default.

Why

On a PC with a few cores the game's frame waits for the replay of its GPU work, which today runs on the game's own Presentation thread unless Threaded rendering moves it. #588 made Auto turn both helper threads on from 12 logical processors and leave everything below serial. Measured core count by core count, the right answer is not one threshold: the render thread alone helps from 4 cores; adding the recorder thread helps from 6 but hurts on 4, where it competes with the game's own threads. And 12 logical processors means very different CPUs with SMT on or off.

Upstream's open #1407 (riqmarmes) also moves Auto's threshold, to 8 logical processors with one tier. This PR differs in what it counts (physical cores, not logical processors) and in having a render-thread-only tier for 4 and 5 cores. Where they choose differently: 4 cores with 8 threads (#1407 both threads, this PR the render thread only: both threads measured worst on 4 cores here), 4 cores with 4 threads (#1407 off, this the render thread), 6 or 7 cores without SMT (#1407 off, this both). #1407 found the 1 % low worse with both threads on an 8-core, 8-thread i7-9700K in Hyrule Field; my 8-core runs (the market, SMT off) had fewer long frames with both. Different CPU and scene: worth looking at together. Whichever merges second will conflict on the kAutoCpus lines.

See #1407, #588, #688.

What changed

Auto asks how many physical cores the game may use and picks a tier. The menu's help for Auto says the rule; the log at the start says what this PC got.

  • rule: gpu/vk/threaded_rendering.h: kAutoCpus (12 logical) is gone; kAutoRenderCores = 4, kAutoRecorderCores = 6; a Choice has two halves (render_thread, recorder_thread); auto_picks(cores), auto_picked(), cores_of() (the cores among the affinity mask's processors), describe() (the start's log line); the measured table in the header's comment.
  • counting: gpu/vk/vk_progcache.cpp usable_cores() beside usable_cpus(): the process's affinity mask and GetLogicalProcessorInformation's per-core masks (on Linux the renderer's copy of the posix shim groups processors by sysfs physical_package_id and core_id); a core counts once when any of its processors is usable; with nothing counted, the logical count as before; never more than the logical count. gpu/vk/vk_internal.h declares it.
  • menu and replay: gpu/vk/vk_menu.cpp threaded_choice() (resolved once from usable_cores(), the mirrors gate asked in both Auto tiers, describe() logged), menu_render_thread() and menu_recorder_thread() in place of menu_threaded_rendering(); gpu/vk/vk_replay.cpp reads the render thread's half, the recorder hook the recorder's; vk_menu.h, vk_recorder.h comments.
  • device policy: gpu/vk/device_policy.h DeviceFacts::cores_usable, the logged flags threaded_auto_render and threaded_auto_recorder in place of threaded_auto_cpus; gpu/vk/vk_main.cpp fills cores_usable.
  • docs: README's option row and Threaded rendering paragraph, docs/development.md's Threaded rendering and RX_VK_ASYNC rows, the RX_VK_ASYNC and RX_VK_RECORDER rows' default text in gpu/vk/switches.def.
  • tests: tests/test_threaded_rendering.py rewritten: the rule compiled for 0 to 256 cores, cores_of on Windows- and Linux-numbered siblings, a hybrid 6P+8E CPU, SMT off and 64 processors; usable_cores cut from vk_progcache.cpp over stand-in Win32 calls (SMT siblings once, failing calls, no core entry, the cap); the readers compiled in 21 environments; source checks of the wiring and the texts; 20 broken copies, each caught. tests/test_device_policy.py: a cores column for its 19 PCs and the flags by cores.

Measurements

Verdict: faster where it changes the default: +2.3 fps on 4 cores (the render thread), +4.8 on 6 and +6.1 on 8 (both threads), frames of 16.7 ms or more down by about 35 % to 75 %; both threads on 4 cores would have been 3.6 fps slower than serial, which the 4-5 tier avoids.

Hardware: Windows 11, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, 32 GB; the game held to 4, 6 or 8 cores by affinity
Scene: Castle Town's market (child), standing after a debug teleport from the kokiri-start save; output 2560x1440, uncapped (HOS_FPS_MAX=1000), no window (HOS_HEADLESS=1), HOS_CACHE_CORES=0
Method: RX_VK_FRAME_TRACE=1; from 300 frames after the teleport to the run's end (about 50 s), fps from the summed frame times, the median frame and the share of frames of 16.7 ms or more; two runs each way, in rounds; the three ways forced with RX_VK_ASYNC=1 and RX_VK_RECORDER=thread
How to reproduce: the same spot, RX_VK_ASYNC=0, RX_VK_ASYNC=1, and RX_VK_ASYNC=1 RX_VK_RECORDER=thread; the runs also had RX_VK_ASTC_BC_ALL=1 RX_VK_IMAGE_BLOCK_MB=32 RX_VK_LOAD=create RX_VK_BC_LAYERS=8 RX_VK_LATE_FIX=0 HOS_THREAD_TIMES=5

Baseline: build @ 54a42715 (main 93 commits before this PR's base) with the 18 Nov changes, the three ways forced by switches in one build (main's Auto is the serial column at 4, 6 and 8 cores: it is off under 12 logical processors). This PR's rule chooses the bold cell in each row. A later build with this rule, left to choose by itself, gave 68.3 fps on 4 cores, 73.9 on 6, 73.6 on 8 and 75.4 on 16 (logs not kept).

cores (the new rule's pick) Before (main's Auto: serial): build @ 54a42715 After (the render thread only, RX_VK_ASYNC=1): build @ 54a42715 After (both threads, + RX_VK_RECORDER=thread): build @ 54a42715
4 (the render thread only) 65.2 / 64.8 fps, 13.4 / 16.1 % >= 16.7 ms 67.3 / 67.3 fps, 8.6 / 10.2 % 60.7 / 62.0 fps, 35.8 / 32.0 %
6 (both) 67.5 / 68.2 fps, 6.9 / 5.0 % 69.3 / 69.1 fps, 3.5 / 4.0 % 73.0 / 72.3 fps, 1.9 / 2.8 %
8 (both) 66.9 / 67.0 fps, 5.9 / 6.3 % 69.8 / 70.0 fps, 3.0 / 2.9 % 72.7 / 73.4 fps, 1.5 / 1.5 %
4 cores (stand-rthr-*): serial      frames 3309 fps 65.2 median 15.00 ms >=16.7 13.4 % | frames 3241 fps 64.8 median 15.11 ms >=16.7 16.1 %
                        render      frames 3410 fps 67.3 median 14.55 ms >=16.7  8.6 % | frames 3494 fps 67.3 median 14.50 ms >=16.7 10.2 %
                        both        frames 3110 fps 60.7 median 16.14 ms >=16.7 35.8 % | frames 3164 fps 62.0 median 16.00 ms >=16.7 32.0 %
6 cores:                serial      frames 3512 fps 67.5 median 14.54 ms >=16.7  6.9 % | frames 3546 fps 68.2 median 14.47 ms >=16.7  5.0 %
                        render      frames 3604 fps 69.3 median 14.27 ms >=16.7  3.5 % | frames 3569 fps 69.1 median 14.29 ms >=16.7  4.0 %
                        both        frames 3830 fps 73.0 median 13.49 ms >=16.7  1.9 % | frames 3696 fps 72.3 median 13.57 ms >=16.7  2.8 %
8 cores:                serial      frames 3423 fps 66.9 median 14.73 ms >=16.7  5.9 % | frames 3553 fps 67.0 median 14.70 ms >=16.7  6.3 %
                        render      frames 3637 fps 69.8 median 14.12 ms >=16.7  3.0 % | frames 3593 fps 70.0 median 14.07 ms >=16.7  2.9 %
                        both        frames 3747 fps 72.7 median 13.59 ms >=16.7  1.5 % | frames 3839 fps 73.4 median 13.43 ms >=16.7  1.5 %
[hos sead::MainThread] vk: Threaded rendering: Auto: off (4 logical processors, on from 12)      (the serial runs: main's rule)

Flags and settings

No switch added; the menu row's Auto changes what it picks.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
Threaded rendering: Auto (menu row, threaded_rendering= in the options file) which replay helper threads Auto turns on both from 12 logical processors, else none none under 4 cores; the render thread at 4-5; both from 6 (where the buffer pools are mirrored) +2 to +6 fps on 4 to 8 cores here helps on 4, 6, 8 cores without SMT; untested with SMT, Linux, Wine Auto, as it ships
RX_VK_ASYNC, RX_VK_RECORDER the two halves by switch override Auto override Auto, each its half none (rows' default text updated) - unchanged

Testing

Tested: the core-count runs above and the rule's own choices on 4, 6, 8 and 16 cores (in the game, at 93 commits behind this base). On this head: tests/test_threaded_rendering.py --cxx clang++ and tests/test_device_policy.py --cxx clang++ pass; of the 257 checks that read the changed files, the 47 that fail on this PC failed the same way on main (run before the rebase onto main's last 11 commits; after it, the two tests above, tests/test_readme_menu_rows.py and tests/test_doc_anchors.py pass again). The branch's own usable_cpus and usable_cores on the real Windows calls of this PC (SMT off), the process held by affinity: 0x3 2 cores, off; 0xF 4, the render thread only; 0x3F 6, both; 0xFF 8, both; 0xFFFF and none 16, both.

Not testable by hand: CPUs with SMT on, Intel hybrid CPUs, and Linux's sysfs core grouping are not on my PC; the counting is checked with stand-in Win32 calls and sibling masks for each of those layouts, and Linux uses the posix shim's existing GetLogicalProcessorInformation.

Not tested: a build of this exact head; threaded_choice() itself is not compiled by a test (its pieces are: the rule, the count, the gate's source); Wine/Proton's GetLogicalProcessorInformation.

Must be tested:

  • Windows, a CPU of 4 cores and 8 threads with a discrete card: the log's vk: Threaded rendering: Auto: the render thread only (4 cores of 8 logical processors; ...) line, and the market's fps against Threaded rendering Off, expecting Auto no slower (Test Farm: @Beanstalk windows, a 4-core 8-thread CPU, Castle Town's market standing 60 s with Threaded rendering Auto and Off)
  • Windows, 6 cores and 12 threads: the start's line, expecting both threads, as before (by hand or the Test Farm: @Beanstalk windows, a 6-core 12-thread CPU, the start's Threaded rendering line)
  • linux: the start's line, expecting it to count physical cores (a 6-core 12-thread CPU: 6 cores of 12 logical processors) (Test Farm: @Beanstalk linux, the start's Threaded rendering line)
  • steamdeck: the start's line, expecting off (the buffer pools have no mirrors), as before (Test Farm: @Beanstalk steamdeck, the start's Threaded rendering line)

Risks

What could break: PCs of 4 or 5 cores and 6 to 11 logical processors without SMT with a discrete card now run the render thread (and from 6 cores the recorder thread) by default; Threaded rendering's known costs apply to them as to 12+ processors today (GPU-written tables read a frame later where the header says so). A miscount (a system whose core information is missing or odd) falls back to the logical count.

Turning it off: Threaded rendering Off in the menu, or RX_VK_ASYNC=0.

Compatibility: nothing changes for saves, options or caches; the options file's value is the same Auto.

Issues

See #1407, #688

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. (In the game 93 commits back; this head not built yet.)
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). (The changed files' checks on this PC; failures are main's own here.)
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (Not built on Linux yet.)
  • Docs updated.

🤖 Generated with Claude Code

**Type:** perf · **Risk:** medium · **Tested on:** Windows 11, RTX 4070 SUPER, Ryzen 9 9950X3D (SMT off, held to 4, 6 and 8 cores) · **Needs:** a build of this head; CPUs with SMT (4c/8t, 6c/12t, 8c/16t); Linux; a Steam Deck ## TL;DR Threaded rendering's Auto turned the render thread and the recorder thread on together from 12 logical processors, and left everything below on the slow serial path. Measured by core count on one CPU, the render thread alone already helps on 4 cores, both threads help from 6 cores, and both threads on 4 cores make it worse. This PR makes Auto choose by physical cores in three steps: under 4 off, 4 or 5 the render thread only, 6 or more both. On my PC held to 4, 6 and 8 cores that is +2.3, +4.8 and +6.1 fps over today's Auto, with fewer long frames. ## Breakdown - **Who it helps:** players with 4 to 11 logical processors and a discrete card: 4 to 5 cores get the render thread, 6 to 11 logical processors without SMT get both threads. - **What was wrong:** Auto's threshold of 12 logical processors left 6-to-8-core CPUs without SMT on the serial replay, and it counted SMT threads as cores. - **What changes:** Auto counts physical cores (an SMT core's two threads once): under 4 off, 4-5 the render thread only, 6+ the render thread and the recorder thread. - **What does not change:** On and Off; `RX_VK_ASYNC` and `RX_VK_RECORDER` still choose over Auto; the unsafe gate (no buffer pool mirrors: integrated GPUs, the Steam Deck) still turns Auto off; 12+ logical processors with 6+ cores choose as before. - **How it was checked:** two runs of each of the three ways at 4, 6 and 8 cores standing in Castle Town's market; then the built rule choosing by itself at 4, 6, 8 and 16; the rule, the core count and the readers compiled in tests with 20 broken copies. - **What is still open:** CPUs with SMT on, Linux, Wine/Proton, a build of this head. - **Risk:** medium: 4-to-11-processor PCs with a discrete card change their default. ## Why On a PC with a few cores the game's frame waits for the replay of its GPU work, which today runs on the game's own Presentation thread unless Threaded rendering moves it. #588 made Auto turn both helper threads on from 12 logical processors and leave everything below serial. Measured core count by core count, the right answer is not one threshold: the render thread alone helps from 4 cores; adding the recorder thread helps from 6 but hurts on 4, where it competes with the game's own threads. And 12 logical processors means very different CPUs with SMT on or off. Upstream's open #1407 (riqmarmes) also moves Auto's threshold, to 8 logical processors with one tier. This PR differs in what it counts (physical cores, not logical processors) and in having a render-thread-only tier for 4 and 5 cores. Where they choose differently: 4 cores with 8 threads (#1407 both threads, this PR the render thread only: both threads measured worst on 4 cores here), 4 cores with 4 threads (#1407 off, this the render thread), 6 or 7 cores without SMT (#1407 off, this both). #1407 found the 1 % low worse with both threads on an 8-core, 8-thread i7-9700K in Hyrule Field; my 8-core runs (the market, SMT off) had fewer long frames with both. Different CPU and scene: worth looking at together. Whichever merges second will conflict on the `kAutoCpus` lines. See #1407, #588, #688. ## What changed Auto asks how many physical cores the game may use and picks a tier. The menu's help for Auto says the rule; the log at the start says what this PC got. - rule: `gpu/vk/threaded_rendering.h`: `kAutoCpus` (12 logical) is gone; `kAutoRenderCores = 4`, `kAutoRecorderCores = 6`; a `Choice` has two halves (`render_thread`, `recorder_thread`); `auto_picks(cores)`, `auto_picked()`, `cores_of()` (the cores among the affinity mask's processors), `describe()` (the start's log line); the measured table in the header's comment. - counting: `gpu/vk/vk_progcache.cpp` `usable_cores()` beside `usable_cpus()`: the process's affinity mask and `GetLogicalProcessorInformation`'s per-core masks (on Linux the renderer's copy of the posix shim groups processors by sysfs `physical_package_id` and `core_id`); a core counts once when any of its processors is usable; with nothing counted, the logical count as before; never more than the logical count. `gpu/vk/vk_internal.h` declares it. - menu and replay: `gpu/vk/vk_menu.cpp` `threaded_choice()` (resolved once from `usable_cores()`, the mirrors gate asked in both Auto tiers, `describe()` logged), `menu_render_thread()` and `menu_recorder_thread()` in place of `menu_threaded_rendering()`; `gpu/vk/vk_replay.cpp` reads the render thread's half, the recorder hook the recorder's; `vk_menu.h`, `vk_recorder.h` comments. - device policy: `gpu/vk/device_policy.h` `DeviceFacts::cores_usable`, the logged flags `threaded_auto_render` and `threaded_auto_recorder` in place of `threaded_auto_cpus`; `gpu/vk/vk_main.cpp` fills `cores_usable`. - docs: README's option row and Threaded rendering paragraph, `docs/development.md`'s Threaded rendering and `RX_VK_ASYNC` rows, the `RX_VK_ASYNC` and `RX_VK_RECORDER` rows' default text in `gpu/vk/switches.def`. - tests: `tests/test_threaded_rendering.py` rewritten: the rule compiled for 0 to 256 cores, `cores_of` on Windows- and Linux-numbered siblings, a hybrid 6P+8E CPU, SMT off and 64 processors; `usable_cores` cut from `vk_progcache.cpp` over stand-in Win32 calls (SMT siblings once, failing calls, no core entry, the cap); the readers compiled in 21 environments; source checks of the wiring and the texts; 20 broken copies, each caught. `tests/test_device_policy.py`: a cores column for its 19 PCs and the flags by cores. ## Measurements **Verdict:** faster where it changes the default: +2.3 fps on 4 cores (the render thread), +4.8 on 6 and +6.1 on 8 (both threads), frames of 16.7 ms or more down by about 35 % to 75 %; both threads on 4 cores would have been 3.6 fps slower than serial, which the 4-5 tier avoids. Hardware: Windows 11, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, 32 GB; the game held to 4, 6 or 8 cores by affinity Scene: Castle Town's market (child), standing after a debug teleport from the `kokiri-start` save; output 2560x1440, uncapped (`HOS_FPS_MAX=1000`), no window (`HOS_HEADLESS=1`), `HOS_CACHE_CORES=0` Method: `RX_VK_FRAME_TRACE=1`; from 300 frames after the teleport to the run's end (about 50 s), fps from the summed frame times, the median frame and the share of frames of 16.7 ms or more; two runs each way, in rounds; the three ways forced with `RX_VK_ASYNC=1` and `RX_VK_RECORDER=thread` How to reproduce: the same spot, `RX_VK_ASYNC=0`, `RX_VK_ASYNC=1`, and `RX_VK_ASYNC=1 RX_VK_RECORDER=thread`; the runs also had `RX_VK_ASTC_BC_ALL=1 RX_VK_IMAGE_BLOCK_MB=32 RX_VK_LOAD=create RX_VK_BC_LAYERS=8 RX_VK_LATE_FIX=0 HOS_THREAD_TIMES=5` Baseline: build @ 54a42715 (main 93 commits before this PR's base) with the 18 Nov changes, the three ways forced by switches in one build (main's Auto is the serial column at 4, 6 and 8 cores: it is off under 12 logical processors). This PR's rule chooses the bold cell in each row. A later build with this rule, left to choose by itself, gave 68.3 fps on 4 cores, 73.9 on 6, 73.6 on 8 and 75.4 on 16 (logs not kept). | cores (the new rule's pick) | Before (main's Auto: serial): build @ 54a42715 | After (the render thread only, `RX_VK_ASYNC=1`): build @ 54a42715 | After (both threads, `+ RX_VK_RECORDER=thread`): build @ 54a42715 | |---|---|---|---| | 4 (the render thread only) | 65.2 / 64.8 fps, 13.4 / 16.1 % >= 16.7 ms | **67.3 / 67.3 fps, 8.6 / 10.2 %** | 60.7 / 62.0 fps, 35.8 / 32.0 % | | 6 (both) | 67.5 / 68.2 fps, 6.9 / 5.0 % | 69.3 / 69.1 fps, 3.5 / 4.0 % | **73.0 / 72.3 fps, 1.9 / 2.8 %** | | 8 (both) | 66.9 / 67.0 fps, 5.9 / 6.3 % | 69.8 / 70.0 fps, 3.0 / 2.9 % | **72.7 / 73.4 fps, 1.5 / 1.5 %** | ``` 4 cores (stand-rthr-*): serial frames 3309 fps 65.2 median 15.00 ms >=16.7 13.4 % | frames 3241 fps 64.8 median 15.11 ms >=16.7 16.1 % render frames 3410 fps 67.3 median 14.55 ms >=16.7 8.6 % | frames 3494 fps 67.3 median 14.50 ms >=16.7 10.2 % both frames 3110 fps 60.7 median 16.14 ms >=16.7 35.8 % | frames 3164 fps 62.0 median 16.00 ms >=16.7 32.0 % 6 cores: serial frames 3512 fps 67.5 median 14.54 ms >=16.7 6.9 % | frames 3546 fps 68.2 median 14.47 ms >=16.7 5.0 % render frames 3604 fps 69.3 median 14.27 ms >=16.7 3.5 % | frames 3569 fps 69.1 median 14.29 ms >=16.7 4.0 % both frames 3830 fps 73.0 median 13.49 ms >=16.7 1.9 % | frames 3696 fps 72.3 median 13.57 ms >=16.7 2.8 % 8 cores: serial frames 3423 fps 66.9 median 14.73 ms >=16.7 5.9 % | frames 3553 fps 67.0 median 14.70 ms >=16.7 6.3 % render frames 3637 fps 69.8 median 14.12 ms >=16.7 3.0 % | frames 3593 fps 70.0 median 14.07 ms >=16.7 2.9 % both frames 3747 fps 72.7 median 13.59 ms >=16.7 1.5 % | frames 3839 fps 73.4 median 13.43 ms >=16.7 1.5 % [hos sead::MainThread] vk: Threaded rendering: Auto: off (4 logical processors, on from 12) (the serial runs: main's rule) ``` ### Flags and settings No switch added; the menu row's Auto changes what it picks. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | Threaded rendering: Auto (menu row, `threaded_rendering=` in the options file) | which replay helper threads Auto turns on | both from 12 logical processors, else none | none under 4 cores; the render thread at 4-5; both from 6 (where the buffer pools are mirrored) | +2 to +6 fps on 4 to 8 cores here | helps on 4, 6, 8 cores without SMT; untested with SMT, Linux, Wine | Auto, as it ships | | `RX_VK_ASYNC`, `RX_VK_RECORDER` | the two halves by switch | override Auto | override Auto, each its half | none (rows' default text updated) | - | unchanged | ## Testing **Tested:** the core-count runs above and the rule's own choices on 4, 6, 8 and 16 cores (in the game, at 93 commits behind this base). On this head: `tests/test_threaded_rendering.py --cxx clang++` and `tests/test_device_policy.py --cxx clang++` pass; of the 257 checks that read the changed files, the 47 that fail on this PC failed the same way on main (run before the rebase onto main's last 11 commits; after it, the two tests above, `tests/test_readme_menu_rows.py` and `tests/test_doc_anchors.py` pass again). The branch's own `usable_cpus` and `usable_cores` on the real Windows calls of this PC (SMT off), the process held by affinity: 0x3 2 cores, off; 0xF 4, the render thread only; 0x3F 6, both; 0xFF 8, both; 0xFFFF and none 16, both. **Not testable by hand:** CPUs with SMT on, Intel hybrid CPUs, and Linux's sysfs core grouping are not on my PC; the counting is checked with stand-in Win32 calls and sibling masks for each of those layouts, and Linux uses the posix shim's existing `GetLogicalProcessorInformation`. **Not tested:** a build of this exact head; `threaded_choice()` itself is not compiled by a test (its pieces are: the rule, the count, the gate's source); Wine/Proton's `GetLogicalProcessorInformation`. **Must be tested:** - Windows, a CPU of 4 cores and 8 threads with a discrete card: the log's `vk: Threaded rendering: Auto: the render thread only (4 cores of 8 logical processors; ...)` line, and the market's fps against Threaded rendering Off, expecting Auto no slower (Test Farm: @Beanstalk windows, a 4-core 8-thread CPU, Castle Town's market standing 60 s with Threaded rendering Auto and Off) - Windows, 6 cores and 12 threads: the start's line, expecting both threads, as before (by hand or the Test Farm: @Beanstalk windows, a 6-core 12-thread CPU, the start's Threaded rendering line) - linux: the start's line, expecting it to count physical cores (a 6-core 12-thread CPU: 6 cores of 12 logical processors) (Test Farm: @Beanstalk linux, the start's Threaded rendering line) - steamdeck: the start's line, expecting off (the buffer pools have no mirrors), as before (Test Farm: @Beanstalk steamdeck, the start's Threaded rendering line) ## Risks **What could break:** PCs of 4 or 5 cores and 6 to 11 logical processors without SMT with a discrete card now run the render thread (and from 6 cores the recorder thread) by default; Threaded rendering's known costs apply to them as to 12+ processors today (GPU-written tables read a frame later where the header says so). A miscount (a system whose core information is missing or odd) falls back to the logical count. **Turning it off:** Threaded rendering Off in the menu, or `RX_VK_ASYNC=0`. **Compatibility:** nothing changes for saves, options or caches; the options file's value is the same Auto. ## Issues See #1407, #688 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [ ] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. (In the game 93 commits back; this head not built yet.) - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). (The changed files' checks on this PC; failures are main's own here.) - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. (Not built on Linux yet.) - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
perf(vk): Threaded rendering's Auto chooses by physical cores, in three tiers
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 12s
PR description / Description follows the template (pull_request_target) Failing after 16s
CI / Workflow lint (actionlint) (pull_request) Successful in 17s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 13s
Third-party parts / As their notes say (pull_request) Successful in 12s
Website / Website on Cloudflare (pull_request_target) Has been skipped
4055976a36
Auto counted logical processors and turned on both threads from 12, so a
6-core CPU without SMT stayed serial and a 4-core, 8-thread one counted as 8.
It now counts the physical cores the process may run on (usable_cores: an SMT
core's siblings once, from GetLogicalProcessorInformation; on Linux the posix
shim's sysfs topology) and picks: 6 or more cores, the render thread and the
recorder thread; 4 or 5, the render thread alone (RX_VK_ASYNC's half: the
recorder thread beside it was the slowest of the three on 4 cores); fewer, off.
Both tiers stay off where the mode is not safe (no buffer pool mirrors, so an
integrated GPU such as the Steam Deck's), and behind kAutoEnabled.

The row's answer now has two halves (menu_render_thread, menu_recorder_thread),
each read by its own reader; the start's log line and the device policy's
flags say the tier and the counts.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean deleted branch perf/threaded-auto-cores 2026-11-18 22:02:06 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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!1664
No description provided.