WIP: perf(vk): derive Auto threaded rendering's threshold from the game's cores #1407
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1407
Loading…
Reference in a new issue
No description provided.
Delete branch "riqmarmes/Longshot:perf/threaded-auto-8-cpus"
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?
Type: perf · Risk: medium · Tested on: Windows 11 22631, RTX 3080 Ti, i7-9700K (8 logical) · Needs: a PC with 8-11 logical processors, with 1 % lows
Why
#588 turned Threaded rendering on by default (Auto) from 12 logical processors. This header's own words for that rule are "the game's own threads, the replay, the recorder and the parallel replay's workers beside one another": six game cores plus the replay thread and the recorder thread is 8 — the count at which the mode fits exactly. 12 was the same rule with a four-thread margin, and it leaves 8-processor CPUs, which run the mode well, on the serial replay.
GrimVisage's Market measurement in #688 (a 6-core/12-thread Ryzen 5 5600X, above the current cutoff) shows why average fps alone does not settle the cutoff: +17 % fps on the gate scene, but +8 % fps with -7 % 1 % low on the laps. The 8-11 band is the one that needs 1 % lows, which this PR does not have yet (WIP).
What changed
The patch replaces Auto's hard-coded 12-processor threshold with the count the mode actually needs: the game's six cores, the replay thread and the recorder thread. Only PCs with 8 to 11 logical processors change behaviour; at 12 or more Auto chooses exactly as before.
gpu/vk/threaded_rendering.h: newkGameCores = 6(the game's own virtual cores,vc_cores);kAutoCpusiskGameCores + 2(the replay and the recorder threads) instead of the hard-coded 12, and the comment records the derivation and the measurement.tests/test_threaded_rendering.py: the fixture checks the derivation and the boundary —kAutoCpus == kGameCores + 2 == 8,!auto_picks(7),auto_picks(8), and thechoose(AUTO, …)cases moved from 8/11/12 to 4/7/8.auto_picksiscpus >= kAutoCpus).Measurements
Verdict: the median frame time improves (replay submit 8.78/9.15 -> 6.51/6.65 ms, +6 % fps at matched draws) but the 1 % low is worse with the render thread on (64.2 -> 53.7 fps, p99 15.6 -> 18.6 ms) at 8 logical processors. 12+ is unchanged by construction. Not ready: the trade needs the team's call, and the 1 % low needs more pairs and a 10-11 processor machine.
Hardware: i7-9700K (8 cores/8 logical), 32 GB, RTX 3080 Ti 12 GB (driver 621.24), Windows 11 22631, output 3440x1440 at the game's resolution with DLSS, V-Sync off, cap 165.
Scene: Hyrule Field (child), save slot 04, teleported to the field arrival point, standing still (1,219-1,234 draws a frame, 162 passes), 45 s a run after 20 s of warm-up.
Method: one game folder (development build of main
544229a2), warm shader and program caches, onlylongshot_vk.dllswapped between the arms (base pack, then this branch's renderer pack); two interleaved pairs; pinned options file,RX_VK_FRAME_TRACE=1; fps medians of the log's per-120-present samples, draws from the same lines.544229a2c4f2d5bTransition check, four teleports each (Kakariko <-> Hyrule Field): base 8 frames over 150 ms totalling 2,354 ms and one 360 ms GPU wait; this branch 7 frames totalling 1,996 ms and no GPU wait over 100 ms.
1 % low (one pair, same scene,
RX_VK_FRAME_TRACEframe times over the last 40 % of each run, 2,338 and 2,374 frames): Off median 12.8 ms, p99 15.6 ms, 1 % low 64.2 fps; On median 12.6 ms, p99 18.6 ms, 1 % low 53.7 fps. The median is the same and the 1 % low is 16 % worse with the render thread on, which is the direction #688 saw on its laps (-7 %). This is the reason this PR stays WIP and should be read before the threshold moves to 8: at 8 logical processors the mode has no spare thread, and the tail is where that shows.How to reproduce: build a base and a pack of this branch (
scripts/dev_packs.py base / pack, the workflow in docs/development.md), then run the same save and spot on each (python -I scripts/longshot_ctl.py launch <runtime> --user <run>/user --save <save> --slot 04 --ready present --env HOS_OPTIONS_FILE=<pinned ini> --env RX_VK_FRAME_TRACE=1,teleport 1 --arrive 120, 20 s of warm-up, 45 s standing still) and compare the log'sN presents, F fps; a frame: D drawslines andlongshot_frames.csv.Flags and settings
None: the patch reads no new switch. The runs used
RX_VK_FRAME_TRACE=1(diagnostics only), a pinned options file, and the base and renderer packs of one base.Testing
Tested:
python -I -B tests/test_threaded_rendering.py --cxx <clang++>passes (the derivation and boundary above);python -I -B tests/run_all.pygives the same 154 failure lines as main on this PC (pre-existing Windows-side checks, 420 skipped for lack of gcc/g++); in the game, four scripted runs on the scene above and four teleports, this build only.Not tested: any build of this branch other than the renderer pack over the base; 1 % lows and p99 frame times for the pair; any CPU other than 8 logical processors; HDR, frame generation and non-DLSS upscalers.
Must be tested:
@Beanstalk8-11 logical processors, 10-11 first, Windows or Linux with any Tier 1 GPU: the Market lap scene from #688 with Threaded rendering Auto against Off, expecting fps to hold or rise and the 1 % low not to fall below the Off run by more than the run-to-run spread; by hand on such a PC also says what to look at (the row, the caches and the culling artifacts in Hyrule Field and the Market).Risks
Compatibility: nothing changes for saves,
longshot_options.ini, the shader and pipeline caches, the vk ABI (MKWVK_API_VERSIONuntouched) or the builder's tools; on 8-11 logical processors the visible change is the render thread on by default, and the log line naming the new threshold.What could break, and where: on an 8-11 logical processor PC the render thread can make a scene slower instead of faster (the 1 % low is the number to watch), and the frame-lag caveat
threaded_rendering.hrecords can show as culling artifacts in Hyrule Field or the Market (a GPU-written table read a frame old). It shows in the heavy outdoor scenes; this PC's Hyrule Field is the measured case.How to turn it off: Insert menu -> Gameplay -> Threaded rendering -> Off, which is saved in
longshot_options.ini(threaded_rendering=2) and applies from the next start.How to revert:
git revertthis one commit, or setkAutoCpusback to 12 — the constant is the whole change.12 or more logical processors: no code path changes at all.
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks. Not ticked yet: Measurements show the 1 percent low worse with the render thread on, 64.2 to 53.7 fps, and the default still ships on.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.Assisted-by: DeepSeek Harness (agent), for the measurement runs and the patch text.
Tested in game: Hyrule Field (child) and Kakariko Village on an i7-9700K / RTX 3080 Ti / Windows 11: four scripted runs at a fixed view (1,219-1,234 draws) and four area teleports, this build only
1 % lows measured at 8 logical processors (one pair, same Hyrule Field scene, frame trace over the last 40 % of each run): Threaded rendering Off median 12.8 ms / p99 15.6 ms / 1 % low 64.2 fps; On median 12.6 ms / p99 18.6 ms / 1 % low 53.7 fps. The median improves and the tail is 16 % worse, the same direction as #688's laps. That is why this stays WIP: the threshold at 8 needs the team's call on the tail, and a 10-11 processor machine to show whether the spare threads change it.
Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.