perf(vk): the small pools' capture ranges rebuilt in one x86-64 assembly pass #2135
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2135
Loading…
Reference in a new issue
No description provided.
Delete branch "siantm/Longshot:perf/asm-pool-ranges"
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
Before each capture the renderer rebuilds the list of the host's small pools to capture
(
refresh_pool_ranges_lockedingpu/vk/vk_memory.cpp): it copied the pools, sorted them withstd::sortand mergedthe ones that overlap or touch.
This adds
gpu/vk/asm/memory.Son the asm kit:lsasm_pool_rangeskeeps the pools of 1 toRX_VK_CAPTURE_POOL_MBbytes below 1 TB, rounds them to whole pages and merges those that overlap or touch, in one branch-free pass over the
list in address order (
hos_gpu_poolsgives its mappings that way); it answers -1 when a pool starts below the openrange or an end wraps.
refresh_pool_ranges_lockedtakes that pass (pool_ranges: the kernel on x86-64, the same loopin C elsewhere) without
RX_VK_CAPTURE_EAGER, in place of the copy, sort and merge; with it, or for a list the passrefuses, the path below runs as before. The version moves only when the ranges did, as before. Main's own part: #1553
already keeps no map of the pools' ages without
RX_VK_CAPTURE_EAGER. The result expected: the same ranges, therefresh faster.
No switch: the same ranges either way.
From 12168bb8 on
exp/x86-asm-sync(only its pass; the retired pools' list there is another change). Depends on #1947(the asm kit, which now carries the GPU-visible ranges' sort,
lsasm_sort_ranges): its commits show in this diff until#1947 merges.
Read first:
gpu/vk/asm/memory.S, thenpool_rangesandrefresh_pool_ranges_lockedingpu/vk/vk_memory.cpp.Testing
Tested: Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23 (
CC/CXX,RX_CPMset); head8df7cd73on #1947's head
cffa2f46(the asm kit, on main9dd41326). Through the PC's job queue, each run in a hidden console,tests/run_all.py --strict --exact --jobs 2 --timeout 1200: the change's own checks (light jobpr-tb-AsmCut5-light,log
t-AsmCut5-asm-pool-ranges):test_asm_memory.py,test_capture_pool_refresh.pypass (2 of 2).--changed cffa2f46(build jobpr-tb-AsmCut5-build, logt-AsmCut5-chg-asm-pool-ranges): 78 checks, 70 pass, 8 fail, each ofwhich fails on #1947's head @
cffa2f46too (a worktree atcffa2f46in the queue's jobs, logst-AsmCut5-base-kit-changedandt-AsmCut5-base-kit-more):test_capture_read_once.py,test_frame_overlap.py,test_guest_imported.py,test_linux_pressure.py,test_pending_guest_import.py,test_replay_write_order.py,test_sparse_mirror.py,test_texel_buffer_ownership.py.It has run in the game on this PC once: the in-play A/B in Measurements (held job
fb-g2135, the Market, 19 runs), withno FATAL, device lost or Vulkan error in any run.
Still to test:
uncapped (
HOS_FPS_MAX=240), on #1947's head and on this PR, each warmed a minute, then at least three interleavedthree-minute runs of each (AB AB AB), and one run of each with
HOS_PROFILE=1(python -I scripts/perf.py reporton its folder: the share of
refresh_pool_ranges_lockedon its threads), expecting the same picture, no FATAL, thatshare lower and fps and frame times of this PR at least the base's; a difference beyond the runs' spread is a gain
or a loss, one within it is no difference measured (by hand)
this PR, warmed and interleaved, expecting the same picture and frame times within the runs' spread or better on
this PR (@Beanstalk linux+nvidia, linux+amd, windows+amd, windows+intel, steamdeck: Kokiri Forest three minutes,
#1947's head against this PR, warmed and interleaved, frame times and a screenshot)
python3 -I -B tests/test_asm_memory.py --cxx g++and--cxx clang++, expecting PASS (by hand)Measurements
Verdict: a gain: a rebuild of the ranges takes 3.2-3.3× less time over 1,465 pools listed by address, 4.3-4.5×
when eight lists alternate with other work between refreshes, 4.7× over 200 pools and 7.0-7.1× over 6,000. Slower,
0.81-0.84×, when the list is not by address: the pass refuses it and the sort runs after it (hos_gpu_pools lists its
mappings by address). The pass in C (other CPUs) is 2.1-5.6× faster than the sort, and behind the kernel where the
lists alternate and over 6,000 pools. A micro-benchmark on authored input.
In play (the Market, this head against its parent, the asm kit
cffa2f46, below): the rebuild's own stage is faster inthe loads, -26 % (p = 0.002 in a test that swaps runs between the sides). In steady play it is not shown; the saving
there is about 4 µs a frame. Nothing is shown in frame time.
Baseline: the C this PR replaces, as #1947's head
cffa2f46has it (the asm kit on main9dd41326, which this PR depends on), not main itself.The micro-benchmark:
refresh_pool_ranges_lockedascffa2f46has it (copy, sort, merge) against this PR's (the pass,lsasm_pool_ranges), with this PR's C pass beside them, each cut fromgpu/vk/vk_memory.cppwith the host's list and generation stubbed; every refresh timed is a rebuild;RX_VK_CAPTURE_EAGERunset, a 64 MB cap; authored lists by address (~70% pools of 1-256 pages, ~25% of 1-64 MB, the rest larger). A script on this PC, not in this PR (asm_pool_ranges_bench.py, PrTrials'trials/tools/bench), run alone in the PC's job queue on 2026-11-22: 3 rounds of 201 repetitions per case and arm, i7-9700, llvm-mingw clang 23.1.5-O2 -ffp-contract=off, arms SSE2 (-march=x86-64) and AVX2 (-march=x86-64-v3, what the release builds the back end for). The arms take turns at going first; their outputs were compared at every repetition and were equal. Each cell: the median of the three rounds' medians, [lowest–highest round median], in µs per refresh. Change: before ÷ after (above 1: this PR faster).cffa2f468df7cd738df7cd73In play (held job
fb-g2135, 06:22 to 07:15 UTC on 2026-11-23): the Market, 60 s a run. The two builds are thishead
8df7cd73(rt-apr-8df7cd73) and its parent, the asm kitcffa2f46(rt-kit-cffa2f46): a warm-up each, then kitand head interleaved (kit head head kit, four times), every run loading at create. The output was pinned at 2560x1440,
on a desktop at 800x600 at 30 Hz (the PC's only screen then), so the swapchain and refresh are not those of a
2560x1440 desktop; the runs are alike among themselves. One head run (head6) is held: in it the game's first uses
waited 2,081 ms in all for shader loads (the longest wait 239 ms), so it wrote the load marker. Its draw figures are the
lowest of the 16 runs, and it has 2 bursts. The marker was moved out before the next run, and every later run logged
loading at create. That leaves 8 kit runs against 7 head runs.
Reach, from a diagnostic build of this head that is local and never pushed (one uncounted Market run, a counter added in
the capture's 600-submit line): in its last 24,000 submits (about 4,000 frames)
pool_rangesrebuilt the ranges 640times over about 3,700 pools each, about once every 6 frames. 627 of the rebuilds changed the ranges, and none fell back
to the sort, so the host's list always came by address: the micro-benchmark's 3.2× case, never its 0.82× one. The
rebuild runs at the start of each capture, before its lock is taken. The capture's 600-submit line times that part as
"lock" (ms a submit, printed to two decimals, so its averages are coarse). That part is the figure for this change's
stage.
cffa2f46(C sort and merge), 8 runs8df7cd73, 7 runsa frame's replay time (ms): submitSo the kernel's stage is faster where the rebuilds cluster, in the loads. In steady play, at about 23 µs saved a
rebuild and one rebuild every 6 frames, the saving is about 4 µs a frame, too small for any frame figure to show. In the
same loads the capture's other parts were slower with this head, at the edge (scan +5.1 %, copying +7.0 %, the whole
capture +5.3 %). They are code this pull request does not touch, and the head's loads copied 3.3 % more pages a
submit. That is not claimed either way. This is this head against its parent: two builds, not one build's switch (this
PR has none). The play profile the back end is built with was recorded before this change, so functions this change
edits can build without their profile in the head's build (a compile with clang's profile warnings on showed that for
#1994's file; not checked for this PR's).
Risks
What could break: a range left out of the list would leave that pool's writes uncaptured (stale data on the GPU); the
test runs
pool_rangesandrefresh_pool_ranges_lockedcut from the source against main's refresh and its sort andmerge over lists with gaps, overlaps, touching and repeated starts, empty and too large pools, starts at and past 1 TB,
lists out of order and ends that wrap, between pages that fault, with and without
RX_VK_CAPTURE_EAGER. A revert isenough. Renderer files: the runtime is rebuilt; nothing changes for players' saves, options or caches.
Checklist
Ready for review
main; the title is a Conventional Commit. (Stacked on #1947b71bdb57onmain @ 01d6878b.)mise run testpasses (any failure that also fails onmainis named). Targeted checks pass on#1947(b71bdb57,main @ 01d6878b):test_asm_memory.py(SSE2/AVX2, native/sysv, 4 ELF/COFF clang assemblies),test_capture_pool_refresh.py(asm + C),gpu/vk/vk_memory.cppsyntax check; full CI suite awaits CI approval.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.@Beanstalk This rebuilds the capture's ranges of small pools, when the pools change, with a hand-written x86-64 kernel (gpu/vk), mostly while loading. It sits on #1947 (
cffa2f46, the asm kit), so its diff against its merge base includes that PR's commits; the farm cannot take it as the comparison, so please compare with main. No switch: a revert gives back main's code. Please start from the kokiri-start save and take the picture right after it loads and settles, before any input, with a main-against-itself picture on the same PC at that point; then, for frame times only, play Kokiri Forest for two minutes and go into Hyrule Field (one scene load) and play it for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; frame time p99 equal to main's or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line.@siantm only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.Measurements: the micro-benchmark (trials script, run alone on this PC 2026-11-22, 3 rounds, SSE2 and AVX2): figures and Verdict
@Beanstalk One correction to my request 69767 above, for its picture point: please take each picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between, and take the main-against-itself picture from the same point. A picture taken during the load's fade-in from black is not comparable: run 70269 on #2156 caught the fade in 3 of 4 starts.
@siantm only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@Beanstalk This replaces my request 69767 on this head and the corrections under it, in a form the farm can run: it cannot time a picture from the first frame that is not a uniform colour (its answer on #2131), so each picture here follows a fixed wait after the map event. This rebuilds the capture's ranges of small pools, when the pools change, with a hand-written x86-64 kernel (gpu/vk), mostly while loading. It sits on #1947 (
cffa2f46, the asm kit), so its diff against its merge base includes that PR's commits; the farm cannot take it as the comparison, so please compare with main. No switch: a revert gives back main's code. Please start from the kokiri-start save and take the picture 10 s (600 frames at 60 fps) after the map event that ends the load, a fixed wait with no input in between (the farm cannot time it from the first frame that is not a uniform colour), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest for two minutes and go into Hyrule Field (one scene load) and play it for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on Windows with an RTX 4070, Windows with an Arc B580, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; frame time p99 equal to main's or better, within the run-to-run spread. The log must have no FATAL, device lost or validation error line.@siantm only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for8df7cd7, and the PR has changed since (4f97859), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.8df7cd73b14f9785931aWIP: perf(vk): the small pools' capture ranges rebuilt in one x86-64 assembly passto perf(vk): the small pools' capture ranges rebuilt in one x86-64 assembly passRebased cleanly onto Rust-builder
#1947(b71bdb57, onmain @ 01d6878b) ->4f978593and taking out of WIP.Post-rebase verification on Windows 11 (
llvm-mingw clang 23):tests/test_asm_memory.pypasses (all 4 SSE2/AVX2 × native/sysv variants, 4,003 lists + 120×200 refreshes, 4 ELF/COFF clang assemblies),tests/test_capture_pool_refresh.pypasses (asm + C), andgpu/vk/vk_memory.cppsyntax-checks cleanly. Positive in-play gain (-26%in loads,p = 0.002) and 3.2–7.1× micro-benchmark gain are in Measurements.@review
@beanstalk
Beanstalk test farm · an earlier run: commit
4f97859(the newer results are in a comment below)Commit
4f97859· approved by HumanBean (reviewed) · dashboard⚠️ Note: The farm compares with main, not the asm-kit parent, and cannot isolate the refresh routine's microbenchmark speedup, profiling share, or exact range correctness.
⚠️ Note: The requested compiler-specific unit tests and continuous two-minute gameplay routes cannot be run by this plan; the measured intervals follow brief scripted movement and are mostly stationary.
⚠️ Note: GPU model availability is inferred from online inventory; exact OS and driver combinations may still wait for matching testers.
Started at 2026-11-29 17:02 UTC.
windows+nvidia+gpu-rtx-4070(GPU "rtx 4070")windows+intel+gpu-arc-b580(GPU "arc b580")linux+radv+gpu-rx-6600(GPU "rx 6600")steamdecklinux+nvidialinux+amdwindows+amdwindows+intelWhy it failed
linux+radv+gpu-rx-6600:build times (lift)build_s.max_delta_pct:340.9 → 469.4 (+37.7%); limit 20.0linux+radv+gpu-rx-6600:build times (lift)build_compile_s.max_delta_pct:297.8 → 438.4 (+47.2%); limit 20.0steamdeck:forest-and-fieldscreenshot.max_diff:0.7 → 0.7; limit 0.2steamdeck:forest-and-fieldload_time_max_s.max_delta_pct:1.2 → 6.4 (+455.2%); limit 30.0linux+nvidia:forest-and-fieldfield.frametime_p99_ms.max_delta_pct:17.7 → 23.1 (+30.3%); limit 15.0linux+nvidia:forest-and-fieldfield.frametime_1pct_low_ms.max_delta_pct:17.9 → 24.3 (+35.9%); limit 15.0linux+nvidia:forest-and-fieldscreenshot.max_diff:0.7 → 0.7; limit 0.2Couldn'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.
windows+nvidia+gpu-rtx-4070, report 1:every timed build of the pull request (lift) failed: timed build 2 of the pull request (lift) failed (exit 1): 2 file(s) did not compile: ranges.S, memory.S (compile_failed)windows+intel+gpu-arc-b580, report 1:every timed build of the pull request (lift) failed: timed build 2 of the pull request (lift) failed (exit 1): 2 file(s) did not compile: ranges.S, memory.S (compile_failed)steamdeck, report 2:main's longshot-builder failed (exit 1): Traceback (most recent call last):windows+amd, report 1:every timed build of the pull request (lift) failed: timed build 2 of the pull request (lift) failed (exit 1): 2 file(s) did not compile: ranges.S, memory.S (compile_failed)windows+amd, report 2:every timed build of the pull request (lift) failed: timed build 2 of the pull request (lift) failed (exit 1): 2 file(s) did not compile: ranges.S, memory.S (compile_failed)windows+intel, report 1:every timed build of the pull request (lift) failed: timed build 2 of the pull request (lift) failed (exit 1): 2 file(s) did not compile: ranges.S, memory.S (compile_failed)windows+intel, report 2:every timed build of the pull request (lift) failed: timed build 2 of the pull request (lift) failed (exit 1): 2 file(s) did not compile: ranges.S, memory.S (compile_failed)What was tested
What will be tested · AI plan (
gpt-6.1-terra)The plan compares the PR with main in Kokiri Forest and Hyrule Field across the requested GPUs, Steam Deck, and additional named OS and GPU combinations; the RTX 4070, Arc B580, and RX 6600 targets may wait for matching testers. Three interleaved starts per side include a settled Forest screenshot and two-minute frame-time measurements in each area, for about 56 minutes of game runs per tester. Timed lift builds also check for build regressions. A crash, fatal or Vulkan error, excessive screenshot difference, or a frame-time or build-time regression beyond the configured limits fails the PR. No tester online now matches windows+intel+gpu-arc-b580, linux+radv+gpu-rx-6600, linux+nvidia: those targets wait for one.
kokiri-start, then teleport to Kokiri Forest, take the picture forest-settled to compare with main, move the stick, measure forest for 2 min (after 10 s warm-up), teleport to Hyrule Field, take the picture field-settled to compare with main, measure field for 2 min (after 10 s warm-up); 3 runs on each side.Measurements on `windows+nvidia+gpu-rtx-4070`, for the PR description
Verdict: queued on windows+nvidia+gpu-rtx-4070 (1 report).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAMScene: forest-and-field, from the repository's save kokiri-start; 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); forest-and-field: 3 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
01d68784f97859Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `windows+intel+gpu-arc-b580`, for the PR description
Verdict: queued on windows+intel+gpu-arc-b580 (1 report).
Hardware: 1: windows+intel+intel-proprietary+dgpu+window
Intel(R) Arc(TM) B580 Graphics, 0.406.98312th Gen Intel(R) Core(TM) i9-12900K, 32 GB RAMScene: forest-and-field, from the repository's save kokiri-start; 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); forest-and-field: 3 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
01d68784f97859Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `linux+radv+gpu-rx-6600`, for the PR description
Verdict: fail on linux+radv+gpu-rx-6600 (1 report):
build times (lift) build_s.max_delta_pct (+37.7%);build times (lift) build_compile_s.max_delta_pct (+47.2%)failed.Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 6600 (RADV NAVI23), 26.3.1AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAMScene: forest-and-field, from the repository's save kokiri-start; 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); forest-and-field: 3 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)01d68784f97859Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
01d68784f97859Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `steamdeck`, for the PR description
Verdict: fail on steamdeck (2 reports):
forest-and-field screenshot.max_diff;forest-and-field load_time_max_s.max_delta_pct (+455.2%)failed.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, 16 GB RAMScene: forest-and-field, from the repository's save kokiri-start; 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); forest-and-field: 3 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); 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)01d68784f97859Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
01d68784f97859Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `linux+nvidia`, for the PR description
Verdict: fail on linux+nvidia (2 reports):
forest-and-field field.frametime_p99_ms.max_delta_pct (+30.3%);forest-and-field field.frametime_1pct_low_ms.max_delta_pct (+35.9%);forest-and-field screenshot.max_difffailed.Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 5070, 620.73.4AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM; 2: linux+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce GTX 1660 Ti, 620.73.4Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz, 16 GB RAMScene: forest-and-field, from the repository's save kokiri-start; 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); forest-and-field: 3 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); 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)01d68784f97859Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
01d68784f97859Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `linux+amd`, for the PR description
Verdict: pass on linux+amd (2 reports): no rule failed and no PR run crashed.
Hardware: 1: linux+amd+radv+igpu
AMD Radeon 8060S Graphics (RADV STRIX_HALO), 26.99.99AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, 64 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 9070 (RADV GFX1201), 26.0.8AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAMScene: forest-and-field, from the repository's save kokiri-start; 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); forest-and-field: 3 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); 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)01d68784f97859Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
01d68784f97859Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `windows+amd`, for the PR description
Verdict: could not be judged on windows+amd (2 reports).
Hardware: 1: windows+amd+amd-proprietary+igpu+xess
AMD Radeon(TM) Graphics, 2.0.279AMD Ryzen 5 5600G with Radeon Graphics, 28 GB RAM; 2: windows+amd+amd-proprietary+dgpu+xessAMD Radeon RX 6700 XT, 2.0.353AMD Ryzen 7 2700X Eight-Core Processor, 16 GB RAMScene: forest-and-field, from the repository's save kokiri-start; 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); forest-and-field: 3 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); 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)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
01d68784f97859Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `windows+intel`, for the PR description
Verdict: could not be judged on windows+intel (2 reports).
Hardware: 1: windows+intel+intel-proprietary+igpu
Intel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM; 2: windows+intel+intel-proprietary+dgpu+windowIntel(R) Arc(TM) B580 Graphics, 0.406.98312th Gen Intel(R) Core(TM) i9-12900K, 32 GB RAMScene: forest-and-field, from the repository's save kokiri-start; 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); forest-and-field: 3 game starts a side, forest 120 s after 10 s warm-up, field 120 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); 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)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
01d68784f97859Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
windows+nvidia+gpu-rtx-4070NVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAMwindows+intel+gpu-arc-b580Intel(R) Arc(TM) B580 Graphics, 0.406.98312th Gen Intel(R) Core(TM) i9-12900K, 32 GB RAMlinux+radv+gpu-rx-6600AMD Radeon RX 6600 (RADV NAVI23), 26.3.1AMD Ryzen 5 5600X 6-Core Processor, 64 GB RAMsteamdeckAMD 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, 16 GB RAMlinux+nvidiaNVIDIA GeForce RTX 5070, 620.73.4AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMlinux+nvidiaNVIDIA GeForce GTX 1660 Ti, 620.73.4Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz, 16 GB RAMlinux+amdAMD Radeon 8060S Graphics (RADV STRIX_HALO), 26.99.99AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, 64 GB RAMlinux+amdAMD Radeon RX 9070 (RADV GFX1201), 26.0.8AMD Ryzen 7 5800X 8-Core Processor, 32 GB RAMwindows+amdAMD Radeon(TM) Graphics, 2.0.279AMD Ryzen 5 5600G with Radeon Graphics, 28 GB RAMwindows+amdAMD Radeon RX 6700 XT, 2.0.353AMD Ryzen 7 2700X Eight-Core Processor, 16 GB RAMwindows+intelIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMwindows+intelIntel(R) Arc(TM) B580 Graphics, 0.406.98312th Gen Intel(R) Core(TM) i9-12900K, 32 GB RAMRecommendation: Approve. The code is ready: only testing is left. The range rebuild is faster in the reported Windows loading runs, but a player-visible gain has not been established and the current head has not completed the required hardware runs. The stacked host sort also needs its own measurement against main. Recommend approval; not approved on the forge.
The change replaces two range sorts with x86-64 assembly kernels and adds build and test support for them. The capture rebuild is faster on authored inputs and in the measured loading stage, at the cost of assembly maintenance and extra persistent scratch memory.
Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:1679: The measured loading-stage saving has not yet shown a gain at player settings on the current head. (more on the line) Do: Run the proposed warmed, interleaved current-head comparison against the merged assembly-kit baseline at the display's native resolution, recording rebuild time, load time and frame-time distribution.host/nvdrv.c:216: The stacked host range sort has no separate in-game gain or cost measurement against main in this PR. (more on the line) Do: Measure the host range rebuild and player frame times against main on the stacked head, including memory use and clean and incremental build time.gpu/vk/asm/memory.S:16: The changed capture and host tracking paths still need their requested cross-platform game runs. (more on the line) Do: Complete the requested warmed, interleaved game runs and picture comparisons on those systems, checking frame times and logs against the appropriate baseline.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for players. On the author's Windows PC, the reported capture rebuild and lock stage fell 26% during loads across eight base and seven head runs; steady-play and frame-time improvements were within the runs' spread. Those builds predate the rebase, and the host sort is not separately measured against main in this PR.
Other systems: Both kernels affect CPU-side range tracking across GPU vendors and operating systems. Windows NVIDIA had one in-game comparison; Linux NVIDIA and AMD, Windows AMD and Intel, and Steam Deck runs are outstanding. The build also gains assembly compilation units; its clean and incremental build costs are not reported.
Switches: None added, changed or removed. RX_VK_CAPTURE_EAGER retains its existing default of off and selects the original capture refresh path when enabled.
Reviewed:
4f9785931aagainst01d6878b3f: Read the repository rules, PR template, commits, assembly kernels and headers, changed refresh and host range code with surrounding callers, build integration diff, shared assembly test kit and capture tests. Skimmed the remaining ABI and sort fixtures, profiling metadata and build documentation; the full surrounding builder, host and renderer files were not read. docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run, as required for this review. The author reports targeted Windows checks and one in-game comparison; CI is still running.
Overlaps and merge order: Depends on #1947; merge that assembly-kit PR first and compare this change against its merged head.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +13,4 @@The open range r8, r9, stored at [rax] every pool; r14 counts the pools out of order (a start below the open range's)and the ends that wrapped */LSASM_FUNC lsasm_pool_rangesLSASM_ARGS 4L3 (should fix): The changed capture and host tracking paths still need their requested cross-platform game runs.
When: Only Windows NVIDIA has a reported in-game run; Linux NVIDIA and AMD, Windows AMD and Intel, and Steam Deck have no reported result for these paths.
Do: Complete the requested warmed, interleaved game runs and picture comparisons on those systems, checking frame times and logs against the appropriate baseline.
@ -1651,0 +1676,4 @@if (!expiry && n >= 0) {static std::vector<std::pair<uint64_t, uint64_t>> fresh;fresh.resize((size_t)n);const int64_t k = pool_ranges(list.data(), n, capture_pool_max(), fresh.data());L1 (should fix): The measured loading-stage saving has not yet shown a gain at player settings on the current head.
When: The reported Market comparison used the pre-rebase builds and a 30 Hz desktop; steady-play frame figures were within the spread, while capture time during loads increased 5.3%.
Do: Run the proposed warmed, interleaved current-head comparison against the merged assembly-kit baseline at the display's native resolution, recording rebuild time, load time and frame-time distribution.
@ -197,0 +213,4 @@uint64_t (*grown)[2] = (uint64_t (*)[2])realloc(sorting, (size_t)capmerged * sizeof *sorting);if (grown) sorting = grown, capsorting = capmerged;}if (capsorting >= nall) lsasm_sort_ranges(merged, sorting, (size_t)nall);L2 (should fix): The stacked host range sort has no separate in-game gain or cost measurement against main in this PR.
When: Every changed mapping can trigger this sort under the host mapping lock, and the new scratch allocation persists; the capture-only comparison uses a baseline that already contains this change.
Do: Measure the host range rebuild and player frame times against main on the stacked head, including memory use and clean and incremental build time.
Looks good!
Local test of
4f978593(this PR, with #1947 under it) on Linux, RTX 3090 (driver 620.70.06). CPU-bound: output 1920x1080, Render resolution 100%, the game's own upscaler (none), frame generation and V-Sync off, uncapped.dev.py ab --scene market, 2 interleaved pairs, 45 s measured each, after a warm-up. Basemain@01d6878b.Tests
test_capture_pool_refresh.pypasses (asm and Cpool_ranges).test_asm_memory.pydoes not compile on Linux with g++:asm_memory.cpp:219: no matching function for call to 'max(uint64_t&, long long unsigned int)'(uint64_tisunsigned longhere). It is in the test's own C++ harness, not the kernel, but the check can't run on Linux until that line is fixed.A/B (Market, child, crowded)
B is ahead in both pairs, on fps, 1% low and p99, but the gap (+0.2% and +2.6%) is as large as the run-to-run spread, so this is no difference shown, leaning slightly positive. The change targets a small part of the capture refresh, so a gain this size is plausible and a larger one would be a surprise. No crash or cold frames. This is a main-against-branch comparison, so #1947's commits are in B too.
dev.py abprinted no write-up (it flagged foursim_turf_*options as differing between runs, "Load an area" in one; the same options file started every run, so a snapshot-timing quirk of the tool). The numbers are its per-run lines.Not tested: Windows, AMD, Intel, the full
mise run test.Retest with 8 interleaved pairs.
4f978593(with #1947 under it) againstmain@01d6878b, Linux, RTX 3090 (driver 620.70.06). CPU-bound: output 1920x1080, Render resolution 100%, the game's own upscaler (none), uncapped, Market, 45 s measured a run.Pairs 1 to 6 (the quiet part of the batch): no difference, the sides within 1.2% either way, medians 113.9 and 113.5 fps, 1% low and p99 mixed. Pairs 7 and 8 are where A dropped (107.7 and 104.9, with 2 cold frames in A8) while B stayed at 112; I read that as machine noise late in the batch (another job shares the queue), since B was 111.8 and 112.5, in the same range as every quiet run. Over all 8 pairs: medians A 113.7, B 113.1 (-0.6%); mean of the pair deltas +1.0%, but that is carried by the two noisy pairs.
So no fps gain shown, which is what the description expects: it puts the saving at about 4 us a frame in steady play (0.05% of this 8.7 ms frame) and the measurable gain in the loads (-26% in the rebuild's stage). I did not time the loads here, so I can't confirm or contradict that. A gain in frame time should not be expected from this PR in steady play. Not tested: the loads, Windows, AMD, Intel.
4f9785931a7701d41e73Beanstalk test farm
Commit
7701d41· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Rebased onto
main@b4d56f52, on #1947's new head057dfb77, and pushed as7701d41e. Since the farm run on4f978593and HumanBean's tests:Every Windows tester failed to compile the
.Sfiles: found, and fixed in #1947 (057dfb77). Every Windows report says2 file(s) did not compile: ranges.S, memory.S (compile_failed), with no compiler line. Linux built the same commit. The cause is in Beanstalk's Windows sandbox:Z:\builder\tools\tools\llvm-mingw)..Scompile is two jobs, preprocessing and then assembling (clang -###here showsclang-23.exe -cc1 -E …andclang-23.exe -cc1as …). Clang runs a compile of more than one job as child processes, started from its canonical, real folder.C:\Users. Beanstalk fixed this forld.lldonly, through llvm-mingw's config files..cor.cppis one job, which clang runs inside its own process. That is why only the.Sfiles failed, and why the compiler printed nothing.#1947's fix gives the
.Sunits-no-canonical-prefixes, so the children start from the folder clang was started from. Beanstalk'sdocs/windows-clang.mdnotes that this argument passes in its sandbox.What I checked here (Windows 11, i7-9700, llvm-mingw clang 23.1.5):
host/asm/ranges.Sandgpu/vk/asm/memory.Scompile with the builder's flags plus-no-canonical-prefixes, for bothx86_64-w64-mingw32andx86_64-pc-windows-msvc: all 4 compiles exit 0. I can't run Beanstalk's sandbox here, so a farm run on this head is what confirms the Windows build. Until then, the Windows rows of the run on4f978593say nothing about this PR's code.HumanBean's Linux g++ error in
test_asm_memory.py(asm_memory.cpp:219,std::max(uint64_t&, unsigned long long)): fixed in7701d41e(std::max<uint64_t>). I couldn't compile it with g++ on Linux here, sopython3 -I -B tests/test_asm_memory.py --cxx g++on Linux still needs a run.The farm's other failures on
4f978593, from the reports:linux+radv+gpu-rx-6600, build time +38 % / compile +47 %: the median of two builds a side, and the second pair was slow on both sides.maintook 118.6 s and then 563.3 s, and the PR 129.6 s and then 809.2 s. The first pair is +9 %, with two more.Sunits in the PR. The second pair is that PC's load.linux+nvidia, field p99 +30 %: one report (rp_830bc382). The farm flags it as disagreeing with its peer, which has +0.8 %.steamdeck,linux+nvidia,0.7 → 0.7in the sticky): on these testersmainagainst itself already reaches 0.73 (Deck, forest shot) and 0.72 (secondlinux+nvidiareport, forest shot). The PR's worst shots, 0.69 and 0.67 on the field shot, are inside that range. Its forest shots are 0.03 and 0.07.steamdeck,load_time_max_s+455 %: per run,maintook 4.36, 1.12 and 1.14 s, and the PR 1.18, 4.00 and 4.04 s. Both sides have loads of about 4 s, the PR two of its three andmainone, so three runs a side can't tell the difference from the spread. The range rebuild does run during loads, so this one is worth a rerun with more starts:mainagainst this head, load times per start.Checks on this head (through the PC's job queue):
python -I -B tests/run_all.py --changed origin/mainreaches the whole suite, because #1947 changes the builder: 821 passed, 13 failed, 53 skipped (Linux-only checks, or spirv-val). Of the 13:test_helpers_extract.py,test_i18n_complete.pyandtest_longshot_builder.py(they fail onmainon this PC too).--exact … --jobs 2on this head, all 9 pass, and so do the ones that timed out in #1947's own run.test_parity_gates.py'stest_the_session_is_stopped, which fails the same way onmain@b4d56f52run from the same drive ("path is on mount 'E:', start on mount 'C:'": the checkout is on E:, the temp folder on C:).dev.py cargo -- test --locked -p build-compilepasses (exit 0) andcargo fmt --check -p build-compileis clean.Still open (Testing before merging):
main(host range rebuild, frame times, memory, build time).I haven't run any of them: no game runs on this PC this round. HumanBean's 8 pairs on Linux / RTX 3090 show no fps difference in the Market, as the description expects, and didn't time the loads. A farm rerun on this head would give the Windows rows (L3) and more load-time starts. L1 and L2 need a person with a free GPU.
Recommendation: Request changes. The one-pass rebuild is correct and faster than the sort, but the C loop already in this PR gets most of that gain without assembly. On top of that loop, the x86-64 kernel saves a few µs per rebuild, about 1 µs a frame at the rate counted in play. For that it adds a hand-written unit, in two ABIs, to every player's build, plus a dependency on #1947's
.Sbuild jobs, and the last farm run couldn't build those jobs on any Windows tester. Ship the C pass on every CPU and drop the kernel.For a player: nothing visible. The renderer rebuilds its list of small-pool capture ranges a little faster, mostly while loading. The code gets better with the one-pass merge (no copy,
std::sortand second merge for a list the host already gives by address). It doesn't get better with a second, assembly copy of that loop.Does it help: Yes for the rebuild itself. Unproven, and not expected, for players. Micro-benchmark (author, i7-9700): 12.9–16.7 µs down to 3.7–4.1 µs at 1,465 pools for the kernel, and 3.5–7.7 µs for this PR's own C pass. In play (author, Market, 8 against 7 runs at
8df7cd73over the kit): the rebuild+lock stage fell 26 % in the loads (p = 0.002). That is about 1.3 µs per submit. Frame figures sat within the spread. HumanBean's 8 interleaved pairs at4f978593(Linux, RTX 3090, Market) show no fps difference. The kernel's own share against the C pass is 0–4 µs per rebuild at 1,465 pools (the C pass is faster in two AVX2 rows) and ~12 µs at 6,000. At the one rebuild every 6 frames the diagnostic run counted, that is ≲ 2 µs a frame.Other systems: the change runs on every CPU and GPU (CPU side, under
cap_ranges_mu, incapture_makeandcapture_ranges_merged). Its riskiest effect is on the build, which runs on players' PCs. At4f97859every Windows farm tester failed to compilememory.S(and #1947'sranges.S). The fix (-no-canonical-prefixes) is in #1947's057dfb77, and no farm run has confirmed it yet. Build time at4f97859: linux+radv +38 % whole and +47 % compile (one report; the author reads the second pair as that PC's load, and the first pair as +9 %). It is unmeasured on this head.Switches: none.
RX_VK_CAPTURE_EAGERkeeps the original path, as before.Reviewed:
7701d41e7against mainb4d56f526. Read in full: this PR's two commits (gpu/vk/asm/memory.S,gpu/vk/asm/memory.h,pool_rangesandrefresh_pool_ranges_lockedingpu/vk/vk_memory.cppwith both callers,tests/test_asm_memory.py, thetests/test_capture_pool_refresh.pydiff);gpu/asm/lsasm.h(the macros this kernel uses);hos_gpu_poolsandmap_addinhost/nvdrv.c;asm_unitsinbuilder/crates/build-compile/src/plan.rs. Not reviewed here, because they belong to #1947's review: #1947's own commits in this diff (host/asm/ranges.S, thehost/nvdrv.csort, the rest ofplan.rs, the kit's tests). Nothing run.Fixed in this review: nothing.
Checked and fine:
lsasm_pool_rangesmatches the C loop and main's sort-and-merge:size - 1 >= max, compared unsigned, drops both size 0 and size > max;start >> 40drops starts past 1 TB.sbb r14, -1aftercmp lo, hicounts a wrapped or empty range, andadc r14, 0aftercmp lo, r8counts a start below the open range's start.check_passasserts this.raxmoves at most 16 bytes per pool after the first one kept, so the room ofnentries is never exceeded. An empty list, or one with nothing kept, returns 0 and writes nothing.LSASM_ARGS 4moves rcx/rdx/r8/r9 into rdi/rsi/rdx/rcx in a safe order.hos_gpu_poolswalksmaps(kept sorted by va) and returns identity maps only, at mostmax. The list is therefore by address, and the fallback shouldn't run in play (0 of 640 rebuilds in the author's diagnostic run).refresh_pool_ranges_locked:RX_VK_CAPTURE_EAGER.n < 0, the old path runs as before.cap_ranges_mu, which guards the staticfresh.gpu/vk/asm/*.Sinto the renderer (asm_units). There is no other build path left.test_capture_pool_refresh.pyruns the refresh with both the kernel and the C loop. A divergence in the kernel would fail them.third_party/untouched, AI trailers present.Blocking
gpu/vk/vk_memory.cpp:1654(pool_ranges) andgpu/vk/asm/memory.S: the kernel's gain over the C loop right below it is ≲ 2 µs a frame (figures above). That doesn't pay for a 100-line hand-written unit that must stay correct in two ABIs, or for putting one more.Scompile into every player's build: the build that failed on every Windows farm tester last time. Fix: drop the#ifx86-64 branch,memory.S/memory.hand the asm half of the tests, and keep the C pass for every CPU. The PR then no longer depends on #1947 and can merge on main by itself. To keep the kernel, show a gain over the C pass that a player could notice, together with a farm run that builds this head on Windows.8df7cd73and4f978593, not7701d41e7. The only farm run (4f97859) built nothing on Windows. Tested still names8df7cd73. After the change above, at least one in-game run on the new head plus a farm run, Tested updated to that head, and the build-time row re-read on it.Suggestions
gpu/vk/vk_memory.cpp:1684:fresh.resize(n)zero-fillsn - k_oldentries on every rebuild (~1,400 at the counts above). The in-repo--benchtimespool_rangesagainst a preallocated room, so it doesn't see that cost. A static room oflist.size()entries, likelist, avoids it: compare withstd::equal(room, room + k, pool_cap_ranges.begin(), pool_cap_ranges.end()), thenpool_cap_ranges.assign(room, room + k)andcap_ranges_ver++only when the ranges differ.Testing:
8df7cd73.4f978593, with no fps difference.4f97859: the Windows builds failed, and the Linux and Deck failures are read as noise.test_asm_memory.pywith g++ on Linux after7701d41e7; the load-time rerun the author asks for.Overlaps and merge order:
4627366f1and057dfb77fare in this diff), so #1947 merges first. Without the kernel, this PR needs nothing first.pool_rangesorrefresh_pool_ranges_locked, so none is a duplicate.#if x86-64 #include "asm/…"block at the same place invk_memory.cpp's includes (line 56). Whichever merges second gets a simple textual conflict, resolved by keeping both.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.