WIP: perf(vk): Threaded rendering's Auto runs the recorder thread from 4 cores, not 6 #2232
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2232
Loading…
Reference in a new issue
No description provided.
Delete branch "klimovich008/Longshot:perf/auto-recorder-4-cores"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On a PC whose CPU has 4 or 5 physical cores, Threaded rendering's Auto runs the render thread alone today, so that one
thread makes every one of the driver's calls itself. This PR makes Auto run the recorder thread beside it from 4 cores,
as it already does from 6. WIP until the Test Farm and players have run it on real 4-core PCs: the numbers below
come from one 8-core PC held to 4 cores by an affinity mask. They are a diagnostic, not the claim.
Who changes and who doesn't. Only PCs where all of these hold change:
device_policy.hp.mirrors = f.discrete());Nothing changes on:
menu's
threaded_choiceturns Auto off for that reason, on main and here alike. The start line saysvk: Threaded rendering: Auto: off (not safe on this run: the buffer pools have no mirrors)on both builds;The rule (
gpu/vk/threaded_rendering.h, from #1664):kAutoCores= 4 gives both threads from 4 cores and off below.The "render thread alone" tier is gone (
Why::AutoRenderThread, itsdescribecase, its half ofauto_picked).The header keeps the 18 Nov table as the record and puts the 22 Nov masked numbers beside it, labelled as masks of an
8-core CPU.
Neighbours: #1407 (riqmarmes, WIP) asks the same header's question for low-core CPUs, for the mode's own threshold,
before #1664's tiers. #1763 and #1866 rewrote the threads and the recorder after #1664's table was measured. That is
why the 4-core tier is being looked at again.
Read first:
gpu/vk/threaded_rendering.h(auto_picks), thentests/test_threaded_rendering.py.Other files: the words that named the tiers (
gpu/vk/menu/threads.cpp,vk_menu.h,vk_menu.cpp,device_policy.h,vk_replay.cpp,vk_recorder.h,switches.def,docs/dev/reference/threads.md,architecture.md,switches.md,docs/user/graphics-and-controls.md), andtests/test_device_policy.py's five 4-core PCs.Testing
Tested: Windows 11, Ryzen 7 5700X3D (8 cores, 16 threads), RX 9070 XT, AMD 26.11.2.
In the game: Hyrule Field turning, 3 alternating pairs held to 4 cores by the process's affinity mask (
0xff: 4cores with their SMT siblings), and one pair unmasked. Every masked run logged the line its build should:
Auto: the render thread only (4 cores of 8 logical processors; the recorder thread too from 6 cores);Auto: on, the render thread and the recorder thread (4 cores of 8 logical processors).Unmasked, both builds log the same line (
Auto: on, the render thread and the recorder thread (8 cores of 16 logical processors)). The clock read 0.999-1.001 in every run. There were no new error lines in the PR's logs against main's.Every run passed the harness's screen check.
tests/test_threaded_rendering.py, with g++ and clang++: the rule, the readers and the menu'sthreaded_choicearerun whole, in 15 environments, with 39 broken copies, each caught. The menu's cases include:
RX_VK_CAPTURE=0,RX_VK_LOW_SPEC,RX_VK_DUMPorRX_VK_BENCH.This branch's test fails on main's code.
tests/test_device_policy.py, with both compilers: it passes after merging maina2dc5385.Failures that main has too:
tests/test_switch_table.pyfails onRX_VK_GRASS_DISTANCE's order inswitches.def, a line this PR doesn't touch.run_all.py, run ondd5ffe6a, the branch has no failure that main lacks.mise run lint's only failure is main's own (shellcheck on.forgejo/workflows/build-windows.yml).menu/threads.cpp,threaded_rendering.handvk_recorder.hbeside thefiles it already lists on main (main
a2dc5385fails it with 10). Threaded rendering is on the Debug tab, not thepictured Graphics view, and
vk_recorder.h's change is a comment.linux_syntax.sh(clang 21): ok onmenu/threads.cpp,vk_menu.cpp,vk_replay.cppandvk_progcache.cpp.Still to test:
Linux): main against this PR, both on Auto with no switch, uncapped, in Hyrule Field and the Market. Expected: fps up
and p99 down or level, with no more frames over 50 or 100 ms. The start line should read as under Tested
(
@Beanstalk, request below).i7-9700K's did before #1866): the same comparison (
@Beanstalkif the farm has one, else by hand).builds. A separate, data-only question for Deck players (forced recorder thread against Auto, both on this PR's
build) is in a comment below. It informs a possible later Deck change and is not this PR's claim (by hand).
Measurements
Verdict: on this PC held to 4 cores with SMT (
--affinity 0xff), +21.0 % fps in Hyrule Field, p99 4.3 ms lower.This is a mask of an 8-core CPU (its 96 MB cache is kept, and the driver's and Windows' threads run on the other 4
cores), a diagnostic, not the claim: real 4-core CPUs are for the farm. Unmasked (8 cores), both builds run the same
mode.
Setup: Windows 11, Ryzen 7 5700X3D, RX 9070 XT, AMD 26.11.2. Hyrule Field turning.
HOS_FPS_MAX=240with the optionsfile's
frame_rate_cap=0,vsync=0,frame_generation=0, a fixed light GPU load beside the game, andRX_VK_ASYNC=1in both arms. Three alternating pairs, no warm-ups, no run rejected, medians. The PR's side is a pack built from
43280cfa; every later gpu/ change on the branch is a comment. Both sides used the same exe.These were measured on main
dd5ffe6a, and the PR is now on maina2dc5385. Main's 7 commits since then don't touch theThreaded rendering rule, the recorder or the replay's submit. #2174 changes Hyrule Field's simulated turf on the way in,
so the absolute numbers may move. Not re-measured here: the farm runs the head.
--affinity 0xff(4 cores, 8 logical; a mask of an 8-core CPU)dd5ffe6a43280cfaThe GPU clock was 3001 MHz on main's side and 3208 MHz on this PR's. The game is CPU-bound here, and AMD's clock rises
with GPU work.
On the unmasked pair (one run each, 8 cores, the same mode on both builds), the gap was 86.29 → 92.34 fps. The code
path is the same there, so that gap is one pair's noise, not this change. It shows that a few % in any single pair can
be noise.
Risks
recorder beside the render thread was the slowest of the three modes, with a third of the frames long. On today's
code, masked, this PC shows no more frames over 50 or 100 ms. The farm's Market run on real 4-core CPUs is the check.
control slow every core before #1866. A power-saving 4-core laptop is where that could come back.
virtual cores follow the render thread, unchanged (no host file changes).
/sys's CPU topology can't be read,usable_coresfalls back to the logical count, soa 2-core, 4-thread PC there now gets both threads (it got the render thread alone).
RX_VK_RECORDER=0for the recorder alone. A revert is enough.Nothing changes in saves,
longshot_options.inior the caches (no shader-cache stamp file touched).Follow-ups, older than this change, not in it:
vk_recorder.h:8says unsetRX_VK_RECORDERis off. The row decides.threads.md:44calls the hand-off by part unmeasured.vk_menu.cpp's comment lists GCN among unmirrored GPUs, but an RX 580 has mirrors.steam-deck-playbook.md:107puts "measured the same or worse" under Auto, but Auto is Off on a stock Deck. It shouldsay On.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
- tests/test_threaded_rendering.py: the capture's switch must be read (getenv("RX_VK_CAPTURE")), with a broken copy that reads nothing. - threaded_rendering.h: the 22 Nov runs had the frame rate held only by HOS_FPS_MAX=240 and the standard test's light GPU load beside the game; #1866's recorder waits on its ring after a 10 us spin where it spun 20-200 us. - The settings paragraph, threads.md's "Who records" and architecture.md's threads line say Auto's threads come only where its mode is safe (an integrated GPU's pools have no mirrors: Auto stays off there); threads.md's start line has no counts on an unsafe run. Co-Authored-By: Claude Opus 5.5 <[email protected]>a2dc5385) into perf/auto-recorder-4-coresTested in game: Windows 11, Ryzen 7 5700X3D (8C/16T), RX 9070 XT, AMD 26.11.2: Hyrule Field turning, uncapped (HOS_FPS_MAX=240), 3 alternating pairs held to 4 cores by the affinity mask 0xff (a mask of an 8-core CPU: a diagnostic, not the claim) and one unmasked pair. Each run's 'vk: Threaded rendering:' start line was the one its build should log (main: the render thread only; this PR: the render thread and the recorder thread; unmasked: both threads on both). Game clock 0.999-1.001, no new error lines against main, the picture shown in every run. Not run on a real 4-core CPU, on NVIDIA or Intel, on Linux in the game, or on a Steam Deck (where this PR changes nothing).
@Beanstalk main against this PR, both on Threaded rendering Auto, no switch on either side: this PR changes what Auto picks on CPUs with 4 or 5 physical cores and a discrete GPU, so only those PCs can show a difference.
Targets: PCs with a discrete GPU (the dgpu tag) and a CPU of 4 physical cores or fewer, by model. With SMT (4C/8T): i7-6700K, i7-7700K, i7-6700, i7-7700, i3-10100, i3-12100, i3-13100, Ryzen 3 3300X. Without SMT (4C/4T): i5-6500, i5-6600K, i5-7400, i5-7500, i5-7600K, Ryzen 3 1200, 1300X, 3100. An NVIDIA and an AMD card if the testers have them, Windows and Linux both. 2- and 3-core PCs log the same "Auto: off" line on both builds, and 6-core and bigger PCs run both threads on both builds: those compare the same mode. No Steam Deck target here (Auto is off there on both builds: no mirrors).
Settings, both sides: frame_rate_cap = 6 (Uncapped), vsync = 2 (Off), frame_generation = 0. Headless is fine (the change is in the replay, not the present path); no window scenario.
Scenario: Hyrule Field (HyruleField_Child) measured 30 s, then the Market (Market_Child) measured 30 s in the same start; 3 game starts a side (2 at least). Rules, PR vs main: fps_mean.min_delta_pct = 5 and frametime_p99_ms.max_delta_pct = 10 on each segment, crash = false. Hitch counts (run_hitch_count, run_frametime_max_ms) report-only.
Log check on the PR side: "vk: Threaded rendering: Auto: on, the render thread and the recorder thread (4 cores" expected, and main's "Auto: the render thread only (4 cores" shown, so we can see the tester's PC was in the tier that changes.
Beanstalk test farm · 🔄 testing (0 of 2 reports so far)
Commit
f554451· approved by klimovich008 (reviewed) · dashboard⚠️ Note: The model groups permit either operating system and GPU maker, but do not guarantee coverage of both; none of the listed CPUs appears in the current online inventory.
⚠️ Note: Threaded rendering uses its default Auto value because it is not an exposed plan setting; the main-side Auto line is available in its log but cannot be separately enforced by a PR-only expected-log rule.
⚠️ Note: The farm cannot select a power-saving plan or target an unspecified four-core laptop.
Started.
⚠ No tester has a PC for
dgpu+cpu-1300x_3100_i5-6500_i5-6600k_i5-7400_i5-7500_i5-7600k_ryzen-3-1200(none seen in 14 days): it waits until one signs in.dgpu+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")dgpu+cpu-1300x_3100_i5-6500_i5-6600k_i5-7400_i5-7500_i5-7600k_ryzen-3-1200(CPU "1300x" or "3100" or "i5 6500" or "i5 6600k" or "i5 7400" or "i5 7500" or "i5 7600k" or "ryzen 3 1200")What was tested
What will be tested · AI plan (
gpt-6.1-terra)Compare main and the PR on discrete-GPU PCs with the requested four-core CPU models, using Threaded rendering Auto with no switches. Three starts per build measure 30 seconds each in Hyrule Field and the Market, taking roughly 32 minutes per tester; no matching CPU is currently online, so the targets will wait. The PR fails on a crash, a missing expected Auto-mode log line, a 5% FPS loss, a 10% p99 frame-time increase, or a substantial screenshot difference. Whole-run hitch counts and maximum frame times are reported without limits. No tester online now matches dgpu+cpu-3300x_i3-10100_i3-12100_i3-13100_i7-6700_i7-6700k_i7-7700_i7-7700k, dgpu+cpu-1300x_3100_i5-6500_i5-6600k_i5-7400_i5-7500_i5-7600k_ryzen-3-1200: those targets wait for one.
castle-gate(settings vsync=2, frame_rate_cap=6, frame_generation=0), then teleport to Hyrule Field, measure field for 30 s (after 10 s warm-up), take the picture field to compare with main, teleport to Market, measure market for 30 s (after 10 s warm-up), take the picture market to compare with main; 3 runs on each side.Steam Deck: data only, not this PR's claim.
This PR changes nothing on the Deck. The Deck's GPU is integrated, so the buffer pools have no mirrors, and Auto stays off for that reason on main and on this PR alike. The start line reads
vk: Threaded rendering: Auto: off (not safe on this run: the buffer pools have no mirrors)on both. A run of main against this PR on Auto would compare the same mode on both sides.Deck players who'd like to help with a possible later Deck change can answer a separate question. It is about the recorder thread alone, with the render thread left off. Both runs use this PR's build:
RX_VK_RECORDER=threadas the only line inlongshot_env.txt.Play the same spot uncapped (Frame rate cap Uncapped, V-Sync Off, no frame generation), Hyrule Field and the Market if you can, 2-3 times each, alternating A and B. Please report:
longshot_log.txt, thevk: Threaded rendering:line and thevk: RX_VK_RECORDER=threadline (B only).Please don't set
RX_VK_ASYNC=1on the Deck for this. The render thread replays a frame behind the game. Without mirrors it would read the game's memory while the game writes the next frame. That is the reason Auto turns it off there.The result won't decide this PR. It would only show whether a recorder-alone mode is worth a Deck change of its own.
Steam Deck: the data we have so far (context for the Deck question above, not this PR's claim).
Nobody has run this PR's build on a Deck yet. The only Deck numbers are omgitsgela's field data from main, posted in #agent-updates on 2026-11-21 and on #402 (#402 (comment)):
game_cpu, against 54.1 % on Windows 11 at the same cap;So on the Deck the CPU, not the GPU, is most of the frame. That's why the recorder-thread-alone question above (no switch against
RX_VK_RECORDER=thread, both on this PR's build,RX_VK_ASYNC=1not set) is worth answering. This PR doesn't change the Deck: Auto stays off there because the buffer pools have no mirrors. Deck results for this PR will be posted here when they come in.Read of the head
f5544516(a merge of current maina2dc5385; basea2dc5385). The rule, the count and the off path are consistent, and the test is real. The one thing it cannot settle from code is whether the new default is right on a real 4-core PC — the evidence is a mask of an 8-core CPU — so I stop at the code finding.1. The decision needs a real 4-core run. The measured After is a Ryzen 7 5700X3D (8 cores/16 threads) held to 4 cores by
--affinity 0xff: it keeps the 96 MB cache, and the driver's and Windows' threads run on the other 4 cores. The only real 4-core data in the header is the 18 Nov table (a 9950X3D with SMT off, 4 cores/4 threads): there the render thread and the recorder thread were the worst of the three (60.9 / 62.1 fps, 34.7 / 31.5 % of frames ≥ 16.7 ms, against 67.6 / 67.9 fps render-only). The PR reverses that on the strength of #1763/#1866's rewrite plus the mask, and the masked 4c/4t row (89.2 vs 78.7 fps) is not a 4-core CPU. The riskiest case is therefore 4c/4t, where the recorder's 20-25 wakeups a frame and its short sleeps are the documented cost (the header's own i7-9700K note: Kokiri Forest 15 fps against 48). 4c/8t has the SMT headroom to make the change plausible; 4c/4t is the farm run that decides it. Still to test lists both, which is right; 5-core PCs (which the rule also flips) are not in the list and are rare enough to ignore. Until one real 4c/4t and one 4c/8t run exist, this is a default change with a diagnostic, not a measured claim — and the body says exactly that.2. What "4 cores" means, and the count.
threaded::cores_of(threaded_rendering.h:119-123) counts a physical core once when any of its logical processors is in the process's affinity mask, andusable_cores(vk_progcache.cpp:1321-1340, with the Linux shim) feeds it. So 4c/8t → 4, 4c/4t → 4, 5c → 5, 6c/12t → 6, 2c/4t → 2; an 8c/16t pinned to0xff→ 4 (the masked measurement's case); a launcher pinning a 4c/8t to 4 logical processors that are 2 cores × 2 siblings → 2 → Auto off. That last detail is worth keeping in the row's words: the count follows the affinity mask, not the PC's cores. The test covers the Deck's 4c/8t (one mask per core, both numbering schemes), the one-sibling masks and0xFF/0x55/0x0Fboundaries. One fallback remains: when the core masks cannot be read,usable_coresreturns the logical count, so a 2c/4t on such a PC would count 4 and run both threads where the real 2 cores would leave Auto off; that is pre-existing, and rare, but the row/comment could say the fallback counts logical processors.3. Default and off path. Only 4-5 physical cores with a discrete GPU (mirrors) and the row on Auto change. The Deck and every iGPU PC still turn Auto off (
pools_mirrored()false, asked only where Auto picked the threads,vk_menu.cpp:4398-4408); 2-3 cores off; 6+ both, as before; explicit On/Off unchanged;RX_VK_ASYNC/RX_VK_RECORDERstill override their halves;kAutoEnabledis the single gate. TheRX_VK_RECORDERrow's 6 → 4 matches the code, and theRX_VK_ASYNCrow already said 4 on main, so the PR resolves a pre-existing mismatch rather than creating one. Thedevice_policyflags (auto_picks(f.cores_usable)) now agree with the rule; they do not include the unsafe gate, which is the menu's, as intended.4. The measurement is not at this head and not against current main. Before is
main @ dd5ffe6a(seven commits beforea2dc5385, including #2174, which changes Hyrule Field on the way in — the measured scene), and After is43280cfa, older than the head; the body says every latergpu/change is a comment and that the farm runs the head. That is a fair description, and the numbers are labelled a mask, so the only gap is that+21.0 %/ p9923.04 → 18.74 msare not a current-main comparison. The farm run will produce the head's own numbers.5. The test is the strongest part: the rule at every core count to 256, the gate and the unsafe gate,
On/Offwhatever the CPU,cores_ofon Deck/Linux/Windows sibling numbering,usable_coreson the affinity masks, the start line for each answer (so the removed render-only tier's words are gone), the menu'sthreaded_choicecompiled and run in the capture/low-spec/dump/bench/no-mirrors environments, and 39 broken copies each caught; it fails on main's code. It cannot measure, and that is the point of 1.One comment nit: the
kAutoCoresnote (threaded_rendering.h:72-75) says "on 4 cores 67.6 / 67.9 fps with the render thread alone against 65.5 / 65.0 serial, 18 Nov", but 67.6 / 67.9 is the render-only row; the both-threads row on 4 cores on 18 Nov was 60.9 / 62.1 (the table just above). As written a reader can take 67.6 as the old both-threads number; worth rewording to "the render thread alone was 67.6 / 67.9 against 60.9 / 62.1 for both".No approval (WIP), no claim, and no machine run from me.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.