WIP: perf(vk): a whole push's words made in one pass, into vectors sized once #3304
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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!3304
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:perf/vk-push-words-once"
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
The lean descriptor path (
bind_descriptors_lean,RX_VK_DRAW_OVERHEAD_LEAN, on by default) remembers what it pushed aswords, so that the next draws of a program push only the writes that changed. A program change pushes every write, and
the render thread made that push's words with
words_append: apush_backfor each word and one for each write's offset,each with its capacity check, ~2.7 % of the render thread's replay of a Market frame.
words_build(gpu/vk/draw_key.h) counts the words first (words_of:words_append's own rule, whichwords_same_storenow takes too, so the three cannot disagree), sizes the two vectors once and writes through a pointer:the same words and offsets.
RX_VK_DRAW_OVERHEAD_LEAN=check(2) makeswords_append's too, compares them (a newwords_buildentry beside its other checks) and keeps those on a difference.bind_descriptors(=0, and computedispatches) is unchanged.
On the render thread's replay of one Market frame (2,226 draws, 8.74 ms) it takes 0.201 ms off (95 % interval
0.139-0.280 ms, about 2.3 %). In play at Market, against main: the render thread's command phase, where the push
runs, is 0.15 ms a frame less (both of this change's runs below both of main's); fps +1.1 %, from two runs a side of two
builds, too few for an interval (Measurements).
Overlaps siantm's #2946 (
RX_VK_MESH_FAST), whose descriptor partresizes once inside
words_appendandwords_same_store, as part of a larger change. This one is that step alone, forthe lean path's full push, held to
words_appendby its check mode and a test; whichever lands second rebases over theother.
Read first:
gpu/vk/draw_key.h(words_of,words_build,words_same_store),gpu/vk/vk_draw.cpp(
bind_descriptors_lean's full push).Testing
Tested: Windows 11 (22631), Ryzen 9 3900X, RTX 3080 (NVIDIA 621.47). This change over main
de091ae29, packed over the3b3ea2cb3base, withRX_VK_DRAW_OVERHEAD_LEAN=check: Continue, then a teleport to Market, Hyrule Field and Kakariko,45 s of play in each, threaded rendering on: 165.8 million, 60.5 million and 98.6 million lean checks, words_build's among
them, 0 mismatches. The A/B in Measurements ran 2 more runs of play with this change (and 2 of main).
tests/test_push_state.py:draw_key.h's own functions:words_buildgiveswords_append's words and offsets overevery kind of write, those the draws make today and those they don't (several images or texel views, a write with no
descriptor pointer, one with two), into vectors that held a longer push, a shorter one and none;
words_ofandwords_same_storeagree with them on each.tests/test_vk_draw_overhead_lean.py: the lean path's full push and its=check(the comparison, the note, thefallback) held to their text.
words_of's rule and order, the offsets,the
=checklines) each make one of the two fail (checked).=checklines not held)are in.
tests/run_all.py --strict(Windows, llvm-mingw) on this head,3155cef9d: 884 passed, 17 failed, 55 skipped. 15 ofthem fail on main
0b284cc76run the same way on this PC (884 passed, 17 failed there: these 15, andtest_run_all_outputandtest_seed_reader, which pass here). Ten lack a tool this PC doesn't have under--strict(glslang, spirv-val, llvm-mc, zstandard:
test_fixed_share_upscale_shader,test_framegen_hdr,test_fsr3fi_hud_layer,test_fsr3fi_hudless_colour,test_fsr4_tune,test_gfx_effects,test_lifter,test_native_zstd,test_rt_refl_lamps,test_temporal_present_bandwidth); five fail on main here for reasons oftheir own (
test_dev_update,test_float_add_subgroup,test_helpers_extract,test_longshot_ctl,test_rt_light_grid). The other two pass on their own, three runs out of three:test_ci_source_times(itstemporary folder still locked at its cleanup, WinError 32) and
test_sync_watch_event(itsgpu_waitcase's timingwith 24 checks at once; it reads only
vk_replay.cpp, which this doesn't touch). This change's run before its rebase(over
0b284cc76) failed only the 15: 886 passed.Still to test:
RX_VK_DRAW_OVERHEAD_LEAN=check, expectingvk: draw_overhead_lean check: N checks, ... 0 mismatcheslines and no difference in the picture (@Beanstalk play Market for a minute on theSteam Deck with RX_VK_DRAW_OVERHEAD_LEAN=check and report the "draw_overhead_lean check" lines)
Measurements
Setup: Windows 11 (22631), Ryzen 9 3900X, RTX 3080 (NVIDIA 621.47); Market, child (crowded): Continue, then a
teleport; window 1720x720, output 3440x1440, render resolution 67 %, quality Custom, frame generation off, V-Sync off,
uncapped (
HOS_FPS_MAX=1000), threaded rendering on; the frame trace (RX_VK_FRAME_TRACE=1), 40 s in each run after awarm-up until no frame waits for a pipeline.
dev.py ab --scene market --runs 2 --a-runtime <main's> --runtime <this change's> --separate, four runs interleaved (main, this, main, this), each a timing job of the PC's queue.Baseline: two builds packed over the same base (
3b3ea2cb3): mainde091ae29, and this change over it (7e4f8f7d8, with atest-only commit since dropped, as main's #3294 made the same fix).
RX_VK_DRAW_OVERHEAD_LEAN=0turns the whole leanpath off, so it can't stand for main; hence two builds in separate runs. The head is the same renderer code rebased onto
a2b7abf9e; the six commits between touch no file undergpu/.The render thread's phases are the frame trace's columns, the mean a frame over each run's frames; fps and frame times
are
dev.py ab's per run (its write-up refuses two builds of different versions), the mean of the two.de091ae29cmds_ms(commands: the push)draw_ms(the draw translation, all of it)desc_ms(descriptors)programs_ms(program_for)Verdict: the phase the push is timed in is 0.15 ms a frame less, both of this change's runs below both of main's;
the whole draw translation's −0.05 ms is inside its run-to-run spread (main's two runs differ by 0.26 ms). fps is up
1.1 %, both of this change's runs above both of main's, but that is more than the render thread's saving explains (the
present waits for the render thread under 0.01 ms a frame,
wait_render_ms): with two builds in separate runs, two aside, read it as no loss, not as a measured gain.
Risks
words_append's would make the next draws push too little or too much; the test holdsthe two to each other over every write kind, and
=checkfound no mismatch in play.RX_VK_DRAW_OVERHEAD_LEAN=0turnsthe whole lean path off (bind_descriptors, as before it); a revert is enough.
settings.tomlor the caches.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:tests/test_push_state.pyandtests/test_vk_draw_overhead_lean.pytakewords_of/words_buildand the new=checkentry.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11 (22631), Ryzen 9 3900X, RTX 3080 (NVIDIA 621.47), threaded rendering on. This change over main
de091ae29with RX_VK_DRAW_OVERHEAD_LEAN=check: Continue, then a teleport to Market, Hyrule Field and Kakariko, 45 s of play in each, each run played to its end: 165.8 million, 60.5 million and 98.6 million lean checks, words_build's among them, 0 mismatches. Then 4 runs of 40 s at Market against main, interleaved (Measurements): the phase the push runs in 0.15 ms a frame less on the render thread.@Beanstalk play Market for a minute on the Steam Deck with RX_VK_DRAW_OVERHEAD_LEAN=check and report the "draw_overhead_lean check" lines (expected:
vk: draw_overhead_lean check: N checks, ... 0 mismatches), and whether the picture looks as on main.Beanstalk test farm · ⚠️ couldn't be judged on steamdeck
Commit
3155cef· approved by dyst (reviewed) · dashboard⚠️ Note: The check count is reported from matching log lines; the plan also rejects any matching line with nonzero mismatches.
⚠️ Note: Check-mode overhead means these frame times do not establish the claimed default-path speed-up or isolate the render-thread command phase.
Done (started 02:57 UTC, last report 08:09 UTC). Comment
@Beanstalkto run it again.steamdeckCouldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
steamdeck, report 1:the main base failed (exit 1): 11 shader cache files from <data>/builder/bases/main-seedsteamdeck, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'sWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)On Steam Deck, the PR and main will run Market in check mode for a 60-second measurement, with movement before the measurement and a stationary picture compared against main. The plan records the logged check counts and fails on a missing check line, nonzero mismatches, a crash, a substantial picture difference, or a frame-time regression over 15%. The runs are uncapped at 1280x720 to favor the CPU-side draw path.
market-entrance(settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0; switchesHOS_OUTPUT_RES=1280x720,RX_VK_AUTO_TUNE=0,RX_VK_DRAW_OVERHEAD_LEAN=check), then teleport to Market, take the picture market to compare with main, move the stick, measure market-play for 60 s (after 10 s warm-up); 3 runs on each side.Measurements on `steamdeck`, for the PR description
Verdict: could not be judged on steamdeck (2 reports).
Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAM; 2: linux+amd+radv+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMScene: market-check, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0, RX_VK_DRAW_OVERHEAD_LEAN=check); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-check: 3 game starts a side, market-play 60 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
steamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMsteamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.