perf(vk): hierarchical sub-region summary and scratch reuse in mirror_sync #2978
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
6 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2978
Loading…
Reference in a new issue
No description provided.
Delete branch "siantm/Longshot:perf/vk-memsync-fast"
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
Speeds up mirror synchronization and written-page traversal in
gpu/vk/vk_memory.cppunderRX_VK_MEMSYNC_FAST(default on1).Before this change:
mirror_sync()skipped clean 2 MB regions viaregion_gen, then walked all 512 individual pages of any touched 2 MB region linearly (page_gen(page)), performing per-pagecap_bufs.find(e.gen)hash lookups and inserting copies into per-call heap-allocatedstd::map<VkBuffer, std::vector<VkBufferCopy>>+std::vector<VkBufferCopy>containers.msync_pass_add()andmemory_end_submission()repeatedly re-queried buffer device addresses (vkGetBufferDeviceAddress) andprot_page_since()took a mutex even when no pages were protected.With
RX_VK_MEMSYNC_FAST:256 KB)SubRegionTable(8 × uint64_tmax-gen per 2 MB region,alignas(64)) maintained alongsideregion_gensowalk_dirty_pages()skips clean 256 KB sub-regions in O(1) insidemirror_sync(),memory_written_since(), andmemory_written_runs().mirror_sync()uses reusable sorted flatSmallCapRunsscratch (preservingVkBufferorder with O(1) last-buffer cache and retained capacities), single-entryGenBufCache(eliminating redundantcap_bufs.find(e.gen)lookups across consecutive pages), batched pool stats updates, cachedPool::mirror_address/CapBuf::addressdevice addresses, and lock-freeprot_pages_anyfast-outs.RX_VK_MEMSYNC_FAST=checkrunsmirror_sync_reference_scan()in parallel and asserts 1:1 parity on bothrunsandcap_runsacross all 256 KB skips and flat scratch paths.First read memsync_fast.h and vk_memory.cpp.
Testing
Tested: Windows 11, NVIDIA GeForce RTX 4060 (driver 621.40, Vulkan 1.4).
python -X utf8 -I tests/test_vk_memsync_fast.py --cxx clang++ --headers ...passed (SubRegionTableskip & boundary alignment,SmallCapRunssorted coalescing,GenBufCache, 500-round randomizedmirror_syncparity, source wiring, and 5 broken variants caught).python -X utf8 -I tests/test_hos_ab.py,tests/test_flat_map.py,tests/test_saveload_warm_cache.py,tests/test_vk_braces.py, andclang++ -fsyntax-onlyongpu/vk/vk_memory.cpppassed.RX_VK_MEMSYNC_FAST=1, 15 s):1,183frames,0cold frames,RUN_ERROR=None.RX_VK_MEMSYNC_FAST=check, 25 s):654,794syncs (4,000,014dirty pages checked),0mismatches,RUN_ERROR=None.HOS_AB(HOS_AB=RX_VK_MEMSYNC_FAST=0,3,0, 5×90 s,145paired periods in Market):5/5runs won, zero crashes/errors.main@0aeb6858(2026-12-03), with the three checks this change broke updated:tests/run_all.py --exactoftest_vk_memsync_fast,test_msync_pass,test_mem_check,test_capture_copy_runs,test_hos_abandtest_switch_tablepassed (Windows 11, llvm-mingw clang++), andclang++ -fsyntax-onlyofgpu/vk/vk_memory.cpp. No game run on the rebased head.f747daf: passed onwindows+amd,linux+radvandintel; failed onwindows+nvidia(a GTX 980 whose Field frame times flip between two levels on main too: main p99 47.19 / 27.68 / 26.90 ms, PR 46.92 / 30.82 / 43.77 ms) andsteamdeck(screenshot.max_diff0.78 with the PR's picture taken on a loading screen; Market 1% low 61.19 -> 78.84 ms on one Deck, the other passing).RX_VK_MEMSYNC_FAST=checklogged no mismatch.=0vs=1): +6.15% median FPS, p99 39.71 -> 27.38 ms. HumanBean, Linux RTX 3090 (2 pairs): -0.55%, inconclusive (one=1capture with 46 frames of 50 ms or more, the other none).Still to test:
mainagainst this head at player settings, in the Market and a heavy area, with RAM: the in-run A/B can't show the summary table's own cost, both sides pay it (by hand).RX_VK_MEMSYNC_FAST=check(by hand/@Beanstalk).Measurements
Verdict: faster: +0.85% fps, mean frame time -0.107 ms (95% interval +0.44% to +1.25% faster vs
RX_VK_MEMSYNC_FAST=0).Setup: Windows 11, NVIDIA GeForce RTX 4060 (driver 621.40, Vulkan 1.4); Market, child (crowded), 50% res (
768x432), output res1280x720, frame generation Off, vsync Off, uncapped (HOS_FPS_MAX=1000), queued in-runHOS_AB=RX_VK_MEMSYNC_FAST=0,3,0across 5×90 s runs (145paired periods;16,207ON frames vs16,062OFF frames).Baseline: both columns are one build,
056beb631onperf/vk-memsync-fast(main@495ed9fe2):RX_VK_MEMSYNC_FAST=0(Before) againstRX_VK_MEMSYNC_FASTunset (After).056beb63056beb63desc_msdraw_mswait_gpu_msRisks
Set
RX_VK_MEMSYNC_FAST=0to restore the full 2 MB page scan and per-callstd::mapcopy gathering inmirror_sync(), orRX_VK_MEMSYNC_FAST=checkto verify live parity (0mismatches across654k+syncs /4.0M+pages). Shader cache and pipeline cache are untouched.Assisted-by: Antigravity
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
gpu/vk/switches.def.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.Tested in game: Windows 11, NVIDIA GeForce RTX 4060 (Vulkan 1.4, driver 621.40), Market: RX_VK_MEMSYNC_FAST=1 (1183 frames, RUN_ERROR=None), =check (654794 syncs, 4.00M+ dirty pages, 0 mismatches), 5x90s HOS_AB (145 periods, +0.85% FPS, 95% CI +0.44%..+1.25%, 1% Low +1.29%, 0.1% Low +1.47%)
Possibly related, for context:
@review
Recommendation: Request changes. The commit omits the required AI-assistance trailer, and the test hardcodes its standalone compiler. The reported speedup also does not measure the full change against main.
The change skips clean sub-regions and reuses mirror-sync scratch storage. It also adds a 16 MiB generation table and maintains it even when the new switch is off; the net player benefit against main remains unproven.
Blocking (1): must change before merging.
056beb631c, has no Assisted-by or Co-Authored-By trailer, so the required attribution is absent from the commit. Do: Add the required assistance trailer to the commit message.Should fix (1): not blocking, but worth doing before merging.
tests/test_vk_memsync_fast.py:450: The standalone test ignores the configured C++ compiler and defaults to clang++. (more on the line) Do: Default to CXX when set, with the repository's usual compiler fallback, while retaining the explicit --cxx override.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:897: The A/B result excludes costs shared by both switch settings, so it cannot establish the change's net speedup against main. (more on the line) Do: Run interleaved base-versus-head measurements at player settings in Market and a heavy area, reporting FPS, frame-time tails and RAM. (@fixdoes its part first: Allocate and maintain summaries only where needed, if HOS_AB switching is redesigned to preserve correctness.)gpu/vk/memsync_fast.h:191: The new default traversal has only been exercised in game on Windows NVIDIA. (more on the line) Do: Run the default and check mode on the outstanding Tier 1 configurations, including a representative performance comparison against main.@fixcan do L1, L2 and L3.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven. The PR reports +0.85% FPS over five interleaved runs on an RTX 4060, but both sides use the PR build and therefore include its shared costs. No comparison against base
495ed9feis supplied.Other systems: The changed generation tracking also feeds texture upload and write detection, and the cached addresses and scratch storage affect mirror synchronization. Windows NVIDIA received a smoke and parity run; Linux, AMD and Steam Deck coverage is still outstanding.
Switches: RX_VK_MEMSYNC_FAST is added, default on; 0 selects the legacy scan and check compares scans. Its default is not yet supported by measurements against main or by the outstanding Tier 1 runs. The switch table has a row.
Reviewed:
056beb631cagainst495ed9fe2a: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the commit, the full diff, memsync_fast.h, the new test and the changed vk_memory.cpp paths and relevant callers. Skimmed the remainder of vk_memory.cpp and test_hos_ab.py. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run, as requested. CI was still running on this head.
Overlaps and merge order: Not checked; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -0,0 +188,4 @@/// Walks [start_page, end_page) invoking `on_dirty(page, pg)` for every page whose generation > `synced_gen`./// When `use_subregions` is true, checks 64-page sub-regions and hoists chunk/region_full pointers per 2 MB region./// `on_dirty` must return true to continue or false to stop early.template <class ChunkVecT, class Fn>L4 (should fix): The new default traversal has only been exercised in game on Windows NVIDIA.
When: Linux, AMD and Steam Deck players use the same changed synchronization and texture-write paths, but the PR has no game run on those Tier 1 configurations.
Do: Run the default and check mode on the outstanding Tier 1 configurations, including a representative performance comparison against main.
@ -892,1 +894,4 @@std::vector<uint64_t> region_full(kPages / kRegionPages);// (longshot, RX_VK_MEMSYNC_FAST) 64-page (256 KB) max-generation summary, 8 words per 2 MB region on one cache line.// Always maintained on every stamp so HOS_AB flips see an up-to-date summary without stale skips.memsync_fast::SubRegionTable subregion_gen(kPages / kRegionPages);L3 (should fix): The A/B result excludes costs shared by both switch settings, so it cannot establish the change's net speedup against main.
When: Both measured modes allocate the 16 MiB table and update its summaries on every stamp; main does neither. Those costs can offset the reported 0.85% mode-to-mode gain.
Do: Run interleaved base-versus-head measurements at player settings in Market and a heavy area, reporting FPS, frame-time tails and RAM.
@ -0,0 +447,4 @@def main():p = argparse.ArgumentParser(description=__doc__.split("\n")[0])p.add_argument("--cxx", default="clang++")L2 (should fix): The standalone test ignores the configured C++ compiler and defaults to clang++.
When: On a supported Linux development setup with CXX=g++ and no clang++, invoking this test directly fails before testing the change, even though the configured compiler is available.
Do: Default to CXX when set, with the repository's usual compiler fallback, while retaining the explicit --cxx override.
056beb631cf747daf2faUpdated in
f747daf2f:Assisted-by: Antigravity (Google DeepMind)to the commit message.tests/test_vk_memsync_fast.pycompiler selection): Replaced the hardcodedclang++default withtests/compiler_command.py(--cxxoverride, thenCXX, thenc++,g++,clang++fallback, plusLONGSHOT_MINGWon Windows when unset).gpu/vk/vk_memory.cpp,gpu/vk/memsync_fast.hmode-0 allocation & stamp cost):subregion_genis now lazily allocated (ensure_subregion_table()/SubRegionTable::ensure()) so staticRX_VK_MEMSYNC_FAST=0(whenHOS_ABdoes not targetRX_VK_MEMSYNC_FAST) allocates 0 bytes and performs zerosubregion_genoruntracked_genwrites onstamp_page()/memory_stamp().HOS_AB=RX_VK_MEMSYNC_FAST=...is active, mode-0 stamps skipsubregion_genupdates and raisesubregion_gen.untracked_gen;subregion_gen.usable(synced_gen)disables sub-region skipping untilsynced_gen >= untracked_gen, preventing stale skips across0 -> 1flips.test_static_mode_zero_no_alloc_or_writes,test_hos_ab_flip_parity) and a broken-variant trap (broken_usable_ignores_untracked_gen) intests/test_vk_memsync_fast.py.495ed9fe2vsf747daf2f) and Tier 1 hardware coverage beyond Windows NVIDIA remain to be run by the author/maintainers.Verified after the final edit:
clang++ -std=c++20 -Wall -Wextra -Werror -x c++-header -fsyntax-only gpu/vk/memsync_fast.h(PASS)python -I -B tests/test_vk_memsync_fast.py --cxx clang++, withCXX=clang++, and withCXXunset (all PASS, 6/6 broken variants caught)python -I -B tests/test_hos_ab.py --cc clang(PASS)python -I -B tests/test_tls_objects.py(PASS)python -I -B tests/test_vk_braces.py(PASS)@review
@beanstalk
Beanstalk test farm · an earlier run: commit
f747daf(the newer results are in a comment below)Commit
f747daf· approved by HumanBean (reviewed) · dashboard⚠️ Note: The reported 0.85% improvement is smaller than the regression thresholds and may not be distinguishable from run-to-run noise; the plan measures net performance against main rather than the author's in-run switch comparison.
⚠️ Note: Check mode reports mismatches if encountered, but the plan cannot guarantee that every synchronization branch or a parity summary is reached; check-mode timings are not used for performance judgments.
⚠️ Note: macOS and the in-run HOS_AB switching comparison are not covered by these farm steps.
Done (started 2026-12-02 15:44 UTC, last report 07:24 UTC). Comment
@Beanstalkto run it again.windows+nvidiawindows+amdlinux+radvintelsteamdeckWhy it failed
windows+nvidia:default-performancefield.frametime_p99_ms.max_delta_pct:27.7 → 43.8 (+58.2%); limit 15.0windows+nvidia:default-performancefield.frametime_1pct_low_ms.max_delta_pct:29.4 → 46.7 (+58.8%); limit 15.0steamdeck:default-performancemarket.frametime_1pct_low_ms.max_delta_pct:61.2 → 78.8 (+28.8%); limit 15.0steamdeck:default-performancescreenshot.max_diff:0.2 → 0.8; 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.
intel, report 1:Insufficient frame-time evidence for 6 required comparison(s). See rule results.What was tested
What will be tested · AI plan (
gpt-6.1-terra)The farm will compare main with the default fast synchronization path in Market and Hyrule Field, using three uncapped starts per side and 20-second measurements at each place. A separate check-mode run will exercise live mirror-sync parity in both places with one start per side. The plan measures frame-time tails, FPS and process memory, and compares stationary pictures; a crash, parity mismatch, excessive picture difference or frame-time regression fails the pull request. The run covers Windows NVIDIA, Windows AMD, Linux RADV, Intel and Steam Deck testers.
check(PR only).market-entrance(settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switchesHOS_OUTPUT_RES=1280x720,RX_VK_AUTO_TUNE=0), then teleport to Market, take the picture market to compare with main, measure market for 20 s (after 10 s warm-up), teleport to Hyrule Field, take the picture field to compare with main, measure field for 20 s (after 10 s warm-up); 3 runs on each side.market-entrance(settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0; switchesHOS_OUTPUT_RES=1280x720,RX_VK_AUTO_TUNE=0), then teleport to Market, teleport to Hyrule Field; 1 run on each side.Measurements on `windows+nvidia`, for the PR description
Verdict: fail on windows+nvidia (2 reports):
default-performance field.frametime_p99_ms.max_delta_pct (+58.2%);default-performance field.frametime_1pct_low_ms.max_delta_pct (+58.8%)failed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+window+xess
NVIDIA GeForce GTX 980, 582.78.0Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpu+windowNVIDIA GeForce RTX 4070 Ti SUPER, 621.14.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMScene: default-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); live-parity, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); 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); default-performance: 3 game starts a side, market 20 s after 10 s warm-up, field 20 s after 10 s warm-up; live-parity: 1 game start a side; 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)495ed9ff747dafRX_VK_MEMSYNC_FAST=check (PR only)· forbidden log linesFlags and settings
RX_VK_MEMSYNC_FASTcheckAs Markdown for the PR description:
Measurements on `windows+amd`, for the PR description
Verdict: pass on windows+amd (2 reports): no rule failed and no PR run crashed.
Hardware: 1: windows+amd+amd-proprietary+dgpu+window+fsr4
AMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 9 7950X 16-Core Processor, 128 GB RAM; 2: windows+amd+amd-proprietary+igpu+window+xessAMD Radeon(TM) Graphics, 2.0.279AMD Ryzen 5 5600G with Radeon Graphics, 28 GB RAMScene: default-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); live-parity, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); 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); default-performance: 3 game starts a side, market 20 s after 10 s warm-up, field 20 s after 10 s warm-up; live-parity: 1 game start a side; 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)495ed9ff747dafRX_VK_MEMSYNC_FAST=check (PR only)· forbidden log linesFlags and settings
RX_VK_MEMSYNC_FASTcheckAs Markdown for the PR description:
Measurements on `linux+radv`, for the PR description
Verdict: pass on linux+radv (2 reports): no rule failed and no PR run crashed.
Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 7900 XTX (RADV NAVI31), 26.3.1AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAMScene: default-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); live-parity, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); 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); default-performance: 3 game starts a side, market 20 s after 10 s warm-up, field 20 s after 10 s warm-up; live-parity: 1 game start a side; 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)495ed9ff747dafRX_VK_MEMSYNC_FAST=check (PR only)· forbidden log linesFlags and settings
RX_VK_MEMSYNC_FASTcheckAs Markdown for the PR description:
Measurements on `intel`, for the PR description
Verdict: pass on intel (2 reports): no rule failed and no PR run crashed.
Hardware: 1: windows+intel+intel-proprietary+igpu+window
Intel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAM; 2: linux+intel+anv+igpuIntel(R) Graphics (RKL GT1), 26.2.411th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 128 GB RAMScene: default-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); live-parity, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); 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); default-performance: 3 game starts a side, market 20 s after 10 s warm-up, field 20 s after 10 s warm-up; live-parity: 1 game start a side; 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)495ed9ff747dafRX_VK_MEMSYNC_FAST=check (PR only)· forbidden log linesFlags and settings
RX_VK_MEMSYNC_FASTcheckAs Markdown for the PR description:
Measurements on `steamdeck`, for the PR description
Verdict: fail on steamdeck (2 reports):
default-performance market.frametime_1pct_low_ms.max_delta_pct (+28.8%);default-performance screenshot.max_difffailed.Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAM; 2: linux+amd+radv+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMScene: default-performance, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); live-parity, from the repository's save market-entrance (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, frame_generation=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=0); 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); default-performance: 3 game starts a side, market 20 s after 10 s warm-up, field 20 s after 10 s warm-up; live-parity: 1 game start a side; 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)495ed9ff747dafRX_VK_MEMSYNC_FAST=check (PR only)· forbidden log linesFlags and settings
RX_VK_MEMSYNC_FASTcheckAs Markdown for the PR description:
The testers' hardware
windows+nvidiaNVIDIA GeForce GTX 980, 582.78.0Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz, 32 GB RAMwindows+nvidiaNVIDIA GeForce RTX 4070 Ti SUPER, 621.14.0AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMwindows+amdAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 9 7950X 16-Core Processor, 128 GB RAMwindows+amdAMD Radeon(TM) Graphics, 2.0.279AMD Ryzen 5 5600G with Radeon Graphics, 28 GB RAMlinux+radvAMD Radeon RX 7900 XTX (RADV NAVI31), 26.3.1AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMlinux+radvAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 7 5700X3D 8-Core Processor, 32 GB RAMintelIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMintelIntel(R) Graphics (RKL GT1), 26.2.411th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 128 GB RAMsteamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMsteamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMRecommendation: Approve. The code is ready: only testing is left. The net performance gain against main remains unmeasured, and the new traversal still needs in-game coverage beyond Windows NVIDIA. The reported in-run comparison shows a small improvement but excludes work shared by both switch settings. Recommend approval; not approved on the forge.
The change skips clean sub-regions and reuses scratch storage during Vulkan mirror synchronization. Lazy allocation removes the summary allocation and writes in static mode 0, at the cost of additional mode and generation tracking.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:897: The A/B result excludes costs shared by both switch settings, so it cannot establish the change's net speedup against main. When: Both measured modes allocate the 16 MiB table and update its summaries on every stamp; main does neither. Those costs can offset the reported 0.85% mode-to-mode gain. Do: Run interleaved base-versus-head measurements at player settings in Market and a heavy area, reporting FPS, frame-time tails and RAM. (@fixdoes its part first: Allocate and maintain summaries only where needed, if HOS_AB switching is redesigned to preserve correctness.)gpu/vk/memsync_fast.h:191: The new default traversal has only been exercised in game on Windows NVIDIA. When: Linux, AMD and Steam Deck players use the same changed synchronization and texture-write paths, but the PR has no game run on those Tier 1 configurations. Do: Run the default and check mode on the outstanding Tier 1 configurations, including a representative performance comparison against main.@fixcan do L3.Since the last review (on
056beb631c)Resolved: L1 (The commit has no AI-assistance trailer, although the PR records assistance and checks the…); L2 (The standalone test ignores the configured C++ compiler and defaults to clang++.)
Still open: L3 (The A/B result excludes costs shared by both switch settings, so it cannot establish the c…); L4 (The new default traversal has only been exercised in game on Windows NVIDIA.)
Checks: Still running: 10 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven against main. The author's Windows RTX 4060 in-run comparison reported +0.85% FPS and improved frame-time lows over five runs, but both sides used the PR build and shared some added costs.
Other systems: The traversal affects Vulkan memory synchronization and written-page queries across platforms and GPUs. The reported live parity run covered Windows NVIDIA; Linux, AMD and Intel coverage remains outstanding.
Switches: RX_VK_MEMSYNC_FAST is added, defaults to 1, and offers 0 and check modes. Its default's net gain against main and broader hardware behavior remain unverified.
Reviewed:
f747daf2faagainst495ed9fe2a: Read the commit message, repository rules, memsync_fast.h, compiler selection helper, and the changed portions of vk_memory.cpp and the tests; inspected the changes since the earlier head and the reported runs. The full vk_memory.cpp and the complete original PR diff were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports passing game-free checks and Windows NVIDIA live smoke and parity runs; CI is still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Independent Linux Market A/B on PR head
f747daf2fa04.RX_VK_MEMSYNC_FASTdefaults to on in this revision.Inconclusive in this short capture. Median average FPS changed by -0.55%.
0)1)Market (child), Linux 7.3.3-1-cachyos, RTX 3090, NVIDIA 620.70.06, 1280x720, 50% (640x360), uncapped with V-Sync and frame generation off. Two interleaved 30-second captures per side on the same PR binary, each after pipeline warm-up. Frame-time and 1% low rows report the median across the two captures.
The repeats on at least one side differ by more than 10%, so the average FPS delta is sensitive to the run chosen.
AMD Lab Market A/B on PR head
f747daf2fa04, usingRX_VK_MEMSYNC_FAST=0andRX_VK_MEMSYNC_FAST=1on the same build.Within the run-to-run spread. Median average FPS changed by +6.15%.
0)1)Market (child), headless Linux 7.3.3-1-cachyos, Core i7-9700K, Radeon RX 580 with Mesa RADV 3:26.2.6-1, 1280x720 output and 50% (640x360) render scale, uncapped with V-Sync and frame generation off. Three alternating pairs, 40 seconds per capture after warm-up.
After warm-up, the harness still flagged pipeline or shader activity in 33 / 13 / 47 frames on side A and 2 / 34 / 24 on side B across the three captures. The FPS and tail numbers include those frames.
f747daf2fa8eb6923443Beanstalk test farm
Commit
8eb6923· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Rebased onto
main@0aeb6858(head8eb69234). The default stays on. The description's Testing is updated.Rebase conflicts, resolved keeping both sides:
Pool:main's switch-gated mirror-address cache (cached_mirror_address/cached_mirror_buf, used byRX_VK_WB_CPU_WORDS_FAST) sits beside this PR'smirror_address.mirror_sync:main'sspan_memo_flushstays beside this PR's mode logic.Checks this PR broke, fixed in
00c4c5bc,aaa5ae16and8eb69234. On the rebased head,tests/run_all.py --changed origin/mainshowed three checks broken by this PR's own changes (test_mem_check,test_msync_pass,test_capture_copy_runs), plus three that ran out of time (below).tests/test_mem_check.py: the fast walk inmirror_synccalledmem_checker().live_read(…)behind a local copy ofmem_check_on(), which the check doesn't accept as the switch. It now asksmem_check_on()itself, as the walked path does (gpu/vk/vk_memory.cpp). There is no change whenRX_VK_MEM_CHECKis unset.tests/test_msync_pass.py:msync_pass_addgained a capture-address argument, and its copies are now counted bymsync_copies_nso their arrays are reused. The test now cuts the new signature and counts the copies in use, so an earlier sync's entry is taken again. It also checks that an address the caller passes is used (with the buffer's own lookup gone), and that the mirror's address is kept in the pool.tests/test_msync_pass.py's source checks: this PR movedmirror_sync's loop over the capture buffers intoemit_mirror_sync_copiesand itsemit_caplambda, so the checks now read it there (8eb69234). Before moving them I checked both rules against the new code. The runs the pass takes are still copied into the write-back shadow (shadow_sync_copyinemit_cap's taken branch).msync_pass_flush()still comes right after the loop over the capture buffers (both loops of theif constexpr), which calls onlyemit_capand has noreturn. The checks also require thatmirror_synchands the pass no run itself. Each check fails on a copy of the source with its rule broken (shadow copy removed, flush moved after the earlyreturn, areturnin the loop, an extraemit_capcall).tests/test_capture_copy_runs.py:append_capture_copynow callsmemsync_fast::append_copy, so the fixture includesmemsync_fast.h.Farm results (
f747daf):windows+nvidia(GTX 980), Field p99 27.68 → 43.77 ms: the Field frame times on that PC switch between two levels on both sides. Main's starts gave 47.19 / 27.68 / 26.90 ms and the PR's 46.92 / 30.82 / 43.77 ms, with mean FPS 24.7 / 43.0 / 45.0 against 24.6 / 38.1 / 27.2. With main itself hitting 47 ms, that +58% can't be put on the PR. The RTX 4070 Ti SUPER report on the same target passed, with the PR slightly faster.steamdeckscreenshot.max_diff0.78: the PR's Market picture is a loading screen, so the capture came too early. It doesn't show the scene.steamdeckMarket 1% low 61.19 → 78.84 ms: PR starts 78.84 / 92.61 / 76.17 ms against main's 60.84 / 61.19 / 86.31 ms. The other Deck passed, and there main's own starts went 74.35 / 48.51 / 326.75 ms. Weak evidence either way.RX_VK_MEMSYNC_FAST=checklogged no mismatch on any target.Measurements by people:
=1capture with 46 frames of 50 ms or more; the other=1capture had none, at 126 FPS.No system shows it slower, so the default stays on.
L3 (net gain against
main, including the summary table's cost): still open. With the switch on, both A/B sides pay for the 64-page summary (subregion_gen, allocated on first use,gpu/vk/vk_memory.cpp:895-898). So the in-run A/B can't show the net effect againstmain; that needs base-against-head runs at player settings, which I can't run here (one Windows RTX 4060 PC, a shared queue, no game runs). L4 (other Tier 1 systems): the farm ran default and check mode on all six targets (above), and the AMD Lab ran Linux RX 580. Still missing: a base-against-head comparison at player settings on AMD and Steam Deck.Tested on the rebased head (Windows 11, llvm-mingw clang++):
tests/run_all.py --exactoftest_msync_pass,test_mem_check,test_capture_copy_runs,test_vk_memsync_fast,test_hos_ab,test_switch_table: 6 passed, 0 failed.clang++ -fsyntax-onlyofgpu/vk/vk_memory.cpp, with the build plan's own compile command: no errors.test_direct_buffer_writes,test_invalidate_quick,test_wb_spans) did so only while 8 checks ran at once. Run one at a time, they passed on this PR and onmain(checked before the last rebase, onmain@1c91b18f).No game run on the rebased head.
Recommendation: Wait (on numbers against
mainand a Test Farm run of the rebased head). I found no bug in the fast walk. The code reads as equivalent to the old scan. But no measurement againstmainshows a gain: the farm'smain-against-PR runs onf747dafshow none on any target, and two targets failed. The head also conflicts withmain. A perf change with no measured gain doesn't merge yet.For a player: the same pictures, with a cheaper mirror sync each submission. Clean 256 KB pieces of a dirty 2 MB region are skipped, scratch arrays are reused, and device addresses are cached. The code gets a separate header with a standalone test and a live
=checkparity mode, which is good. It also adds a second mirror-sync path beside the old one while the switch exists.Does it help: Unproven.
mainare the farm's onf747daf: windows+amd p99 -1%, linux+radv -0%, intel +0%. windows+nvidia failed: GTX 980 Field p99 27.7 -> 43.8 ms (mainalso swings to 47 ms on that PC), while the 4070 Ti SUPER passed. steamdeck failed: one Deck's Market 1% low 61.2 -> 78.8 ms, and its picture was a loading screen.HOS_ABwithin the PR's build on one RTX 4060. Its=0side is notmain: the 16 MiB table is allocated, every stamp does a CAS onuntracked_gen, andregion_genis now a CAS max instead of a store.Other systems:
stamp_page, the whole-region path inmemory_stamp, andmemory_begin_submission's mode switch.mirror_sync,memory_written_since,memory_written_runsandcap_pages_overall take the new walk.=checkcompares onlymirror_sync's output (below).Switches:
RX_VK_MEMSYNC_FAST(kill; default on,0the old scan,checkboth with a parity log). The row is inswitches.def. Default on is not yet backed by measurements againstmainon any platform.Reviewed:
8eb692344against merge base0aeb68589.gpu/vk/memsync_fast.h, the wholegpu/vk/vk_memory.cppdiff, and the code it relies on:page_gen,stamp_page,memory_stamp, theregion_gen/region_fullwriters (only those two),kChunkPages/kCapChunkPages, every assignment toPool::mirror(mirror_make, the sparse mirror's creation,mirror_free), oldcap_pages_over,msync_copiesusers,prot_pageswriters, andhost/hos_ab.c's value format.tests/test_vk_memsync_fast.py,tests/test_msync_pass.py,tests/test_capture_copy_runs.py.Fixed in this review: nothing (no push).
Checked and fine:
stamp_pageandmemory_stamp's whole-region path, the only writers ofregion_genandregion_full.HOS_ABflips are covered: mode-0 stamps raiseuntracked_gen, the flip raises it togen_now, andusable()holds skips off until the pool has synced past it.HOS_ABnames one switch (host/hos_ab.c), so thestrncmpprefix test is right. Static=0never allocates or reads the table.walk_dirty_pages' chunk pointer andcap_pages_over's capture chunk once per region is sound: both chunk sizes are 65,536 pages, a multiple of the 512-page region, so a region never spans two chunks.region_genas a monotonic max can't hide a page that a later stamp with a lower generation would have hidden. That holds on the=0side too.SmallCapRunskeepsstd::map<VkBuffer,...>'s order (std::less), so the copies go out in the same order. Insertion keeps inner capacities and resetslast_idx.GenBufCachepointers intocap_bufsstay valid through a pass (nothing erases).msync_copies_nreplacesclear()at every user (msync_pass_add, both flush exits, the fallback loop).Pool::mirror_addressis set inmirror_make(dense and sparse) and cleared inmirror_free. There is no other place a mirror is replaced.CapBuf::addresslives and dies with itscap_bufsentry.prot_pages_anyis written underprot_muat the only writer ofprot_pages.mirror_sync, the fast path keeps the old per-page order: GPU-page diagnostic, write-back note, protected pages, capture, live. A=checkmismatch falls back to the reference copies.Suggestions
tests/test_hos_ab.pyconflicts withmainin theWIREDtable (both sides add rows: keep both). The other files merge cleanly.tests/test_hos_ab.py:364: theWIREDcomment is out of date sincef747daf2f. It says "subregion_gen is always maintained on every stamp" and "no cross-submission mode state". In fact, mode-0 stamps skip the table and raiseuntracked_gen, which carries across submissions. Fix it while resolving the conflict.gpu/vk/vk_memory.cpp:1104,:1125,:7228: with=check,memory_written_since,memory_written_runsandcap_pages_overstill take the new walk unchecked. So the "0 mismatches over 654k syncs" coversmirror_synconly. Comparing their results with the old loops in check mode would cost a few lines.gpu/vk/vk_memory.cpp:99-101:Poolnow caches the mirror's address twice:main'scached_mirror_address/cached_mirror_bufforRX_VK_WB_CPU_WORDS_FAST, and this PR'smirror_address. Sincemirror_addressis set atmirror_makeand cleared atmirror_free, the write-back path could read it and the other pair could go.gpu/vk/vk_memory.cpp:898: the 16 MiB table is zero-filled and committed at once. Allocating it per 256 MB chunk on first stamp (asgen_chunksis) would keep it to the address space the game touches. Either way, name the RAM in Risks.main" box is ticked. Say which it is, or add themain-against-head numbers.Testing:
=check(654,794 syncs, 0 mismatches), and the 5x90 s in-run A/B.f747daf: 3 targets pass, 2 fail (above).=checklogged no mismatch anywhere.8eb69234has had no game run and no farm run (the farm's sticky says no BigBean has approved one).mainagainst this head at player settings in the Market and a heavy area, with RAM. Also a farm run of the rebased head to settle or confirm the GTX 980 Field and Deck Market tails.Overlaps and merge order:
mirror_sync) and #2134 (assembly walk) optimise the same loop, so only one approach should land.mirror_syncscan, so their gains don't add.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.