perf(vk): honor NVN2 CPU_NO_ACCESS pool flags and add AVX2 mirror_sync #2858
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2858
Loading…
Reference in a new issue
No description provided.
Delete branch "siantm/Longshot:perf/pc-discrete-memory-coherence"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On
main(1e782fa4b;HOS_COLLECT_AVX2dropped,mainhas it asHOS_COLLECT_VECTOR):is_gpu_only()treats onlyCPU_NO_ACCESS(0x1) pools as GPU-only, soPHYSICALpools (0x104 = CPU_CACHED | PHYSICAL) stay CPU-mappable and tracked; GPU-only pools skip routine write-watch scans, eager captures and GPU-to-CPU write-backs (HOS_POOL_FLAGS,RX_VK_POOL_FLAGS;nvn_gpu_write's host writes are forwarded);range_all_gpu_only()accounts for overlapping pools through a running end (set_reach), so a long CPU-accessible pool that starts before shorter GPU-only ones is not missed; andmirror_sync()gets an AVX2 page-generation scan, reusable staging and a cachedcap_bufslookup (RX_VK_MIRROR_SYNC_FAST; the SIEVE/S3-FIFO eviction experiment is dropped). The host hands the pools' flags to the renderer asMkwVkHost.gpu_pools_flags(API version 90). OnKokiriForest_Child(1280x720)memsync_csv_meandrops-9.2%(0.630 -> 0.572 ms); frame rate and lows are within run-to-run spread (Measurements). Read first:gpu/vk/pool_flags_policy.h,hos_gpu_track_flags()/hos_gpu_pools_with_flags()inhost/nvdrv.c, andpool_flags_skip_writeback()/mirror_sync()ingpu/vk/vk_memory.cpp.Testing
Tested: Windows 11, Intel Core i7-9700 (8C/8T), NVIDIA GeForce RTX 4060 (driver
621.40), built withdev.py pack+dev.py rt. Ran per-switch bisect + 4 interleaved 35 s runs (BASE_1,WIN_1,WIN_2,BASE_2,3,587–3,784frames/run,1280x720,RX_VK_IMMEDIATE=1,RX_VK_FRAME_TRACE=1) with0warnings andCPU reads or writes of one left out: 0. Targetedtests/run_all.pychecks:14 passed(test_pool_flags,test_mirror_gpu_only,test_mirror_budget,test_mirror_bookkeeping,test_mirror_trim,test_mirror_inherit,test_sparse_mirror,test_wb_learn,test_capture_pool_refresh,test_msync_pass,test_mem_check,test_direct_buffer_writes,test_bind_memo,test_wb_diff_cpu_writes),1 failedpre-existing onorigin/main @ 28cb22b9e(test_switch_table.py: upstreamLONGSHOT_LAUNCHER_STARTUPinhost/launcher_startup.h:9; all 3 new switches ingpu/vk/switches.defpassed).Rebased on
main1e782fa4b(3 Dec): game-free checks on the head, Windows / llvm-mingw, through the PC's queue: 25 targetedtests/run_all.py --exactchecks passed on33f926954(pool flags, capture refresh, API-member, write-back and mirror checks; list in the 3 Dec comment). Syntax-only compiles ofgpu/vk/vk_memory.cpp(with and without-march=x86-64-v3, so the AVX2 and scalarmirror_syncpaths both compile) and ofhost/nvdrv.c,host/nvn_native.c,host/rx_backend.c(Windows target): clean. Not run in game after the rebase (no runtime build on this PC).Still to test:
@Beanstalk linux: build on Linux/AMD RADV and runpython -I -B tests/run_all.pyplus a multi-area playthrough, expectingtest_pool_flags,test_capture_pool_refresh, andtest_direct_buffer_writesto pass with clean mirror coherence (@Beanstalk linux).@Beanstalk windows: run full CI check suite and multi-area memory pressure route, expecting0left-out write-back faults across all areas (@Beanstalk windows).@Beanstalk windows+nvidia: a 4–6 GB card (the farm's GTX 980 / RTX 3050 class) inpool-mirror-multi-areawithvram_budget, whereRX_VK_POOL_FLAGSandRX_VK_MIRROR_SYNC_FASTcould matter, base against head.Measurements
Verdict: within spread on frame rate, measured on two PCs; a real
-9.2%inmemsync_csv_meanon one. On my i7-9700 / RTX 4060 the memory sync's mean drops0.630 -> 0.572 ms(non-overlapping0.572, 0.572vs0.608, 0.652), but Avg FPS is+0.35%and the 1% / 0.1% lows' per-run ranges overlap (60.65, 42.54vs54.81, 56.44), so the+7.8%1% Low is not established. HumanBean's port ontomainon an RTX 3090 / Linux PC, each part alone against all off, 2 interleaved pairs (#2886): pool flags-0.9%(157.1 / 159.1 -> 156.1 / 157.1fps),mirror_syncscan+1.4%(157.0 / 157.2 -> 158.2 / 160.3), both inside the155.9–160.3fps spread of those runs. The Beanstalk run on the old72a3074(base544229a) could not judge frame times on any target:nvidiaandlinux+radvlacked thevram_budgetsetting on that base, and onwindows+nvidia(GTX 980, 4 GB) main hung in 2 of its 3 starts and the PR in 1 of 3 (one usable main start, p9941.0 ms; PR starts37.9 msand1021 ms).Setup: Windows 11, i7-9700, RTX 4060 (
621.40);KokiriForest_Child(kokiri-start),1280x720(resolution=0,HOS_RES_SCALE=1.0,quality_preset=6),RX_VK_IMMEDIATE=1,frame_generation=0,HOS_FPS_MAX=1000,HOS_AUDIO=0,RX_VK_FRAME_TRACE=1(frames.csv), 4 interleaved 35 s runs after 8 s settle comparingRX_VK_POOL_FLAGS=0 HOS_POOL_FLAGS=0 RX_VK_MIRROR_SYNC_FAST=0vs1.Baseline:
origin/main @ 28cb22b9e(perf/pc-discrete-memory-coherencewith the 3 runtime switches set=0vs=1).0/0/0) @f595bb3c01/1/1) @f595bb3c0BASE102.48, 97.52 vsWIN99.85, 100.84)BASE104.82, 101.63 vsWIN102.67, 103.52)BASE60.65, 42.54 vsWIN54.81, 56.44)BASE33.46, 27.03 vsWIN26.55, 36.72)memsync_csv_mean(ms)Risks
If the game ever reads back on CPU from a pool flagged
CPU_NO_ACCESS(0x1) without usingnvn_gpu_write, excluding it fromhos_gpu_guest_rangesorwritebackswould leave host data stale;PHYSICAL(0x104) pools remain included.RX_VK_MIRROR_SYNC_FASTassumeskChunkPages(65536) is a multiple ofkRegionPages(512). Each optimization has a runtime=0kill switch (HOS_POOL_FLAGS=0,RX_VK_POOL_FLAGS=0,RX_VK_MIRROR_SYNC_FAST=0). BumpsMKWVK_API_VERSION(89 -> 90), solongshot.exeandlongshot_vk.dllmust be deployed together.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.MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendererchanged ingpu/vk/vk_api.h).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 (driver 621.40), KokiriForest_Child (kokiri-start) at 2560x1440 and 1280x720: 21.7% lower replay memory sync (0.645 -> 0.505 ms), 45-46 GPU-only write-backs skipped per 600 submits, 28 MB shadow VRAM saved at 1440p, 61.65 vs 58.69 mean wall FPS at 720p, zero sync errors.
@Beanstalk
Beanstalk test farm · an earlier run: commit
72a3074(the newer results are in a comment below)Commit
72a3074· approved by HumanBean (reviewed) · dashboard⚠️ Note: The plan cannot run the requested repository test suite or a multi-hour pressure playthrough; the tight budget encourages eviction but does not guarantee it occurs.
⚠️ Note: Replay memory-sync logs and VRAM are collected when available, but the plan does not isolate the five switches or directly measure scan ranges, write-back bytes, or shadow memory.
Started at 03:21 UTC.
windows+nvidianvidialinux+radvwindows+amdinteligpuWhy it failed
windows+nvidia:pool-mirror-multi-areacrash:1 PR run crashedCouldn'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, report 2:Insufficient frame-time evidence for 6 required comparison(s). See rule results. a step ran out of time: timeout: the save did not load into play within 900 s (the state boot, boot_save none: A pressed) (then the game was in boot, on no knonvidia, report 1:Insufficient frame-time evidence for 6 required comparison(s). See rule results. the game refused a step: not_found: no setting vram_budgetnvidia, report 2:Insufficient frame-time evidence for 6 required comparison(s). See rule results. a step ran out of time: timeout: the save did not load into play within 900 s (the state boot, boot_save none: A pressed) (then the game was in boot, on no knolinux+radv, report 1:Insufficient frame-time evidence for 6 required comparison(s). See rule results. the game refused a step: not_found: no setting vram_budgetlinux+radv, report 2:Insufficient frame-time evidence for 6 required comparison(s). See rule results. the game refused a step: not_found: no setting vram_budgetwindows+amd, report 1:Insufficient frame-time evidence for 7 required comparison(s). See rule results.windows+amd, report 2:Insufficient frame-time evidence for 7 required comparison(s). See rule results.intel, report 1:Insufficient frame-time evidence for 7 required comparison(s). See rule results.What was tested
What will be tested · AI plan (
gpt-6.1-terra)Compare the PR with main on Windows NVIDIA, Linux RADV, Windows AMD, Intel, NVIDIA, and integrated-GPU testers. Each side runs three starts, measuring uncapped frame times for 25 seconds each in Kokiri Forest, Hyrule Field, and the Forest Temple; the latter two use a tight VRAM budget to exercise mirror pressure. Stationary pictures, memory use, and replay memory-sync logs are also collected. A crash, a picture difference beyond the noise allowance, or a frame-time regression over 15% fails the PR.
kokiri-start(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 Kokiri Forest, take the picture forest to compare with main, measure forest for 25 s (after 10 s warm-up), set vram_budget to 1, teleport to Hyrule Field, take the picture field to compare with main, measure field for 25 s (after 10 s warm-up), teleport to Forest Temple, take the picture temple to compare with main, measure temple for 25 s (after 10 s warm-up); 3 runs on each side.Measurements on `windows+nvidia`, for the PR description
Verdict: fail on windows+nvidia (2 reports):
pool-mirror-multi-area crashfailed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu+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+dlss+xessNVIDIA GeForce RTX 5050 Laptop GPU, 621.40.0AMD Ryzen 5 220 w/ Radeon 740M Graphics, 16 GB RAMScene: pool-mirror-multi-area, from the repository's save kokiri-start (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); pool-mirror-multi-area: 3 game starts a side, forest 25 s after 10 s warm-up, field 25 s after 10 s warm-up, temple 25 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)544229a72a3074Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `nvidia`, for the PR description
Verdict: could not be judged on nvidia (2 reports): required frame-time comparison inconclusive (fewer than two usable starts per side).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.1.0AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAMScene: pool-mirror-multi-area, from the repository's save kokiri-start (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); pool-mirror-multi-area: 3 game starts a side, forest 25 s after 10 s warm-up, field 25 s after 10 s warm-up, temple 25 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)544229a72a3074Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `linux+radv`, for the PR description
Verdict: could not be judged on linux+radv (2 reports): required frame-time comparison inconclusive (fewer than two usable starts per side).
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: pool-mirror-multi-area, from the repository's save kokiri-start (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); pool-mirror-multi-area: 3 game starts a side, forest 25 s after 10 s warm-up, field 25 s after 10 s warm-up, temple 25 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)544229a72a3074Flags 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): required frame-time comparison inconclusive (fewer than two usable starts per side).
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: pool-mirror-multi-area, from the repository's save kokiri-start (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); pool-mirror-multi-area: 3 game starts a side, forest 25 s after 10 s warm-up, field 25 s after 10 s warm-up, temple 25 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:
Measurements on `intel`, for the PR description
Verdict: queued on intel (1 report).
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 RAMScene: pool-mirror-multi-area, from the repository's save kokiri-start (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); pool-mirror-multi-area: 3 game starts a side, forest 25 s after 10 s warm-up, field 25 s after 10 s warm-up, temple 25 s after 10 s warm-up; 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)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:
Measurements on `igpu`, for the PR description
Verdict: could not be judged on igpu (2 reports): required frame-time comparison inconclusive (fewer than two usable starts per side).
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+igpu+handheldAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMScene: pool-mirror-multi-area, from the repository's save kokiri-start (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); pool-mirror-multi-area: 3 game starts a side, forest 25 s after 10 s warm-up, field 25 s after 10 s warm-up, temple 25 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)544229a72a3074Flags and settings
None: the plan varied no setting, switch or build option.
As 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 5050 Laptop GPU, 621.40.0AMD Ryzen 5 220 w/ Radeon 740M Graphics, 16 GB RAMnvidiaNVIDIA GeForce RTX 4070, 621.24.0AMD Ryzen 9 7900X 12-Core Processor, 64 GB RAMnvidiaNVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.1.0AMD Ryzen 7 5800H with Radeon Graphics, 16 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 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 RAMintelIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMigpuAMD Radeon 8060S Graphics (RADV STRIX_HALO), 26.99.99AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, 64 GB RAMigpuAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 12 GB RAMsiantm referenced this pull request2026-11-30 05:40:08 +00:00
Thanks for running
@Beanstalk! Two clear issues surfaced here:not_found: no setting vram_budgetonlinux+radv/nvidia: #2858 is still based on544229a26(548 commits behindmain).pool-mirror-multi-areacrash onwindows+nvidia: Matches BeanBot's review findings on the stacked branch — specifically:gpu/vk/pool_flags_policy.h:PHYSICAL(0x100) alone was treated as GPU-only even whenCPU_CACHED(0x104) is also set, and the backward scan could stop early on nested overlapping pools.host/nvdrv.c: host-write queue length was inspected outside the lock.gpu/vk/vk_memory.cpp:sieve_visitedmixed atomic and plainboolaccesses.We are rebasing #2858 cleanly onto current
main, fixing all four issues (plus adding missingswitches.defrows forRX_VK_MIRROR_SYNC_FASTandRX_VK_MIRROR_SIEVE, and droppingHOS_COLLECT_AVX2sincemainalready includesHOS_COLLECT_VECTOR), and will re-test locally before requesting a fresh@Beanstalkrun.@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 for72a3074, and the PR has changed since (f595bb3), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.WIP: perf(vk): honor NVN2 GPU-only pool flags, AVX2 dirty/mirror scans, and SIEVE mirror evictionto WIP: perf(vk): honor NVN2 CPU_NO_ACCESS pool flags and add AVX2 mirror_sync72a3074df3f595bb3c0aWIP: perf(vk): honor NVN2 CPU_NO_ACCESS pool flags and add AVX2 mirror_syncto perf(vk): honor NVN2 CPU_NO_ACCESS pool flags and add AVX2 mirror_syncBeanstalk test farm
Commit
33f9269· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.f595bb3c0a33f9269541Rebased onto
main1e782fa4band pushed as33f926954, with BeanBot's last open blocking finding fixed. This covers the farm run, the review findings carried over from #2886, and HumanBean's measurements.What changed (
33f926954)mainhad moved 84 commits since28cb22b9e, andMkwVkHostgrew three members in that time.gpu_pools_flagsis now the member of API version 90, aftergame_settings_at_start.host/rx_backend.c'svk_hostsets it by name, and the renderer asks for it athost->version >= 90.HOS_POOL_FLAGSsits beside #2902'sHOS_POOL_FLAGS_SITESingpu/vk/switches.def. The renderer'sRX_VK_PLAY_SAVE_START_MB/RX_VK_POOL_IDLErows are settings onmainnow, so I didn't re-add them asSWrows.f595bb3. Its backward walk stopped at the first earlier pool ending at or beforelo, so BeanBot's exact case ([0,100)CPU-accessible, then[10,20)and[30,80)GPU-only, query[40,50)) still returned true, and the write-back would have been skipped.pool_flags_policy::set_reachnow stores each pool's running maximum end whenmemory_syncbuildsguest_pools.range_all_gpu_onlystarts at the first pool whose running end passeslo(a binary search), so every overlapping pool is seen.tests/test_pool_flags.pyhas that case plus the all-GPU-only control.tests/test_vk_desc_span_fast.pygets thepool_flags_skip_writebackstub.tests/test_program_hooks.pynamesgpu_pools_flagsafter version 89's members. Thegpu_pools_flagsparameter is unnamed, sohost_membersdoesn't read(*out)as a member.BeanBot's findings from #2886, as they stand on this head:
PHYSICAL | CPU_CACHED): fixed inf595bb3. OnlyCPU_NO_ACCESScounts (gpu/vk/pool_flags_policy.h,host/nvdrv.cHOS_NVN_POOL_GPU_ONLY).nhost_writesunder the lock with a release store, and the early-out reads it with an acquire load. The ranges themselves are copied under the lock. A write noted after the check is taken at the next collection.sieve_visited): SIEVE is gone from this PR.HOS_COLLECT_AVX2and its test): gone, sincemainhasHOS_COLLECT_VECTOR.Farm (
72a3074, the old base544229a): it couldn't judge the PR on any target, and my 30 Nov reading of it was wrong.windows+nvidia❌ is the crash rule. On the GTX 980 / 4 GB tester (report), main hung in 2 of its 3 starts and the PR in 1 of 3. That PC's hang doesn't single out the PR, and I was wrong to tie it to BeanBot's findings.windows+nvidiatester the save never loaded.nvidiaandlinux+radvfailed onno setting vram_budget, which the old base didn't have andmaindoes now.igpuwas −1 % p99 (couldn't be judged). AMD and Intel returned no metrics.So the low-VRAM case this PR is meant for still has no usable measurement. I'm asking for a fresh
@Beanstalkon this head from aBigBeansmember, ideally with the samepool-mirror-multi-areaplan including a 4–6 GB card.HumanBean's measurements (#2886, RTX 3090 / Linux, each part alone):
mirror_syncscan: +1.4 %.My own Windows numbers agree once read honestly:
memsync_csv_mean−9.2 % with no overlap, but Avg FPS +0.35 % and overlapping lows. I've rewritten the description's Verdict to say so. Neither is a demonstrated frame-rate win on a big card. If the low-VRAM farm run also shows nothing for the pool flags, I'll take them out of this PR and keep only themirror_syncscan, or close it if that shows nothing either. The shipped defaults stay as they are until then. Nothing has measured either switch slower.Testing (this push): Windows / llvm-mingw, through the PC's job queue:
python -I -B tests/run_all.py --exactwith 25 checks that read the changed code (test_pool_flags,test_capture_pool_refresh,test_program_hooks,test_vk_desc_span_fast,test_ui_renderer,test_hos_ab_table,test_bug_report,test_turf_budget,test_mem_check,test_msync_pass,test_wb_learn,test_capture_copy_runs,test_mirror_gpu_only,test_sparse_mirror,test_page_table_census,test_switch_table,test_import_span/_reach/_windows/_log,test_wb_diff_cpu_writes,test_inline_write_order,test_replay_write_order,test_ub_update_batch,test_vk_ubo_ssbo_fast): 25 passed, 0 failed on33f926954.--changed origin/mainon the first rebase (b4d56f526): 203 passed. The 6 failures were 4 since fixed above (test_program_hooks,test_vk_desc_span_fast) or timed out (test_direct_buffer_writes,test_invalidate_vcore: 60 s compile limit on the loaded PC), plus 2 for shader headers missing on this PC (test_gfx_effects,test_gfx_world: no cargo forgen-shadershere).gpu/vk/vk_memory.cppwith-march=x86-64-v3andx86-64(AVX2 and scalarmirror_sync), and ofhost/nvdrv.c,host/nvn_native.c,host/rx_backend.c(llvm-mingw, Windows target): clean.test_direct_buffer_writes/test_invalidate_vcoreon this head without the compile limit: still queued when I posted this. CI runs both.Not done: no runtime build or game run on this PC after the rebase, and no Linux compile here. CI builds both.
@siantm only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.Recommendation: Request changes. It conflicts with main, and its API version 90 is now taken there. Skipping write-backs for CPU_NO_ACCESS ranges looks likely to leave GPU-signalled event values stale in guest memory, because main now flags the event pool CPU_NO_ACCESS (#2902). The skipped write-backs also pin those pools' VRAM mirrors on the low-VRAM cards this PR is meant for, and that cost hasn't been measured. On top of that, no measurement shows a frame-rate gain.
For a player: nothing that shows yet. It cuts the renderer's memory sync by about 9% on one PC, and it could ease memory pressure on small cards, but that is unmeasured. The code is mostly careful: the overlap walk is fixed, the scalar fallback stays and each part has a kill switch. Some of the AVX2 scan is duplicated, though.
Does it help: Unproven.
memsync_csv_meandropped from 0.630 to 0.572 ms (-9.2%, spreads don't overlap) on an i7-9700 with an RTX 4060 at 720p. On the same runs, average fps was +0.35% and the 1%/0.1% lows overlap. HumanBean's RTX 3090 / Linux runs (#2886) were -0.9% (pool flags) and +1.4% (scan), both inside the run spread. All of those numbers are from before the rebase. The farm run was on the old base and could not judge any target. The low-VRAM case the PR is aimed at has no usable number.Other systems: guest CPU readers of CPU_NO_ACCESS pools:
nvnEventGetValueis one (blocking 2). VRAM budget and mirror release: blocking 3. Builds withoutA64_WRITE_TRACK: suggestion 3. AMD, Intel and the Deck: no run at all on this head.Switches:
HOS_POOL_FLAGS,RX_VK_POOL_FLAGSandRX_VK_MIRROR_SYNC_FASTare kill switches, all on by default. The rows are present, but no measurement chose "on" for any platform. Having two switches for one decision (the host's and the renderer's) lets them disagree.Reviewed:
33f926954against its base1e782fa4b. I read every changed hunk ingpu/vk/pool_flags_policy.h,vk_memory.cpp,vk_api.h,switches.def,host/nvdrv.c,nvn_native.c,rx_backend.candhos.h. I also read the code they rely on: the users ofPool::gpu_only,page_gen/load_gen,gpu_write→gpu_piece_bind→gpu_buffer_bind,nvnEventGetValue/nvnEventSignal, and main'sHOS_POOL_FLAGS_SITES. I skimmed the test changes. Nothing was run.Fixed in this review: nothing (no push).
Checked and fine:
range_all_gpu_onlywithset_reachhandles the nested case. Thepartition_pointholds because reach is monotonic.q + 4k + lane, and dirty lanes are re-read withload_gen.page_gen = max(chunk, region_full). A region can't straddle a chunk while 65536 % 512 == 0.collect_in.nhost_writesis changed under the lock, and the early-out reads it with an acquire load.map_add/hos_gpu_trackkeep their old behaviour through flags 0.Blocking
gpu/vk/vk_api.h:28and:470: main is atMKWVK_API_VERSION 98, and version 90 there is the ReShade presets member.gpu_pools_flagshas to become version 99, last onMkwVkHost. Thehost->version >= 90checks need the same number (gpu/vk/vk_memory.cpp:875and:1697), and so doestests/test_pool_flags.py'sver >= 90. As it stands, a version-98 host would pass>= 90with no such member. After the rebase, the description's baseline commits and the in-game run need refreshing.gpu/vk/vk_memory.cpp:186(pool_flags_skip_writeback), with main's #2902:HOS_POOL_FLAGS_SITES, on by default, flags the game's event pool CPU_NO_ACCESS (game/crates/game-core/src/engine.rs:366).NOP_SIGNAL_EVENT(gpu/vk/vk_replay.cpp:1925) writes the value withgpu_write→gpu_piece_bind→gpu_buffer_bind(gpu, n, true), and this PR skips that write-back.nvnEventGetValue(host/nvn_native.c:1252) reads guest memory throughnvn_gpu_read. That covers every caller but the present poll. With the pool mirrored, it reads the old value: a wait that never ends, or a sync that runs early.nvn_gpu_write". An event read through the driver is legal in such a pool on the console.gpu_writefromNOP_SIGNAL_EVENTcould alsoguest_cpu_writethe 4 bytes, or the write-back could be kept for any range an event lives in. Add a game-free test for it.gpu/vk/vk_memory.cpp:187:p.gpu_only = truemeans the pool's mirror is kept for good. Idle release (:6413) and the cold-mirror pass (:6740) both skipgpu_onlypools. That's needed for correctness once write-backs are skipped. But every pool that once had a write-back skipped can no longer give its VRAM back, and that lands on the 4–6 GB cards this PR is meant for. The only low-VRAM data is the GTX 980 farm run on the old base: VRAM peak +5%, one PR start at 1021 ms p99, couldn't be judged. Measure it withvram_budgeton a small card, or name the cost in Risks with a number.pool-mirror-multi-areaplan withvram_budget), plus a heavy area on your PC. If the pool flags show nothing there, drop them and keep themirror_syncscan, as you offered on 3 Dec.Suggestions
gpu/vk/vk_memory.cpp:5213:env_on("RX_VK_LOG_LIVE")is now agetenvon everymirror_synccall. Main read it once (static const). On Windows agetenvtakes the CRT environment lock and scans the environment. Keep it static:gpu/vk/vk_memory.cpp:5233:const bool dirty = true; if (dirty && note_writes)is left over from the old loop. Dropdirty.host/nvdrv.c:201:hos_gpu_note_host_writequeues everynvn_gpu_write, including CPU event signals and writes to CPU-accessible pools. Onlyhost_collectdrains the queue, and that exists only underA64_WRITE_TRACK && !__EMSCRIPTEN__. Where it isn't built, or before the renderer collects, the queue grows for the whole session. Note only writes that land in GPU-only pools, or cap the queue.memory_sync(:875) andrefresh_pool_ranges_locked(:1697) now hold two copies of the same loop. Fill a 3-wide list from either host call (flags 0 fromgpu_pools) and keep one loop.load_gen4uses inline-asmvmovdquwhere_mm256_loadu_si256would do. If it's there to stop the compiler from merging or caching the racy loads, say so in a comment.Testing: Before the rebase, the author ran it in the game on Windows 11 with an RTX 4060 (
f595bb3c0, 4 interleaved runs, 0 warnings). After the rebase there are only game-free checks: 25run_allchecks and syntax-only compiles. That head was never run in the game. Every item under Still to test is open (Linux/RADV, Windows full suite, a 4–6 GB NVIDIA card). There is no AMD, Intel or Deck run. A fresh@Beanstalkshould wait until the rebase onto main (blocking 1) is pushed. Missing testing holds the merge.Overlaps and merge order: #2886 is HumanBean's port of this onto main (its numbers are quoted above), and #2902 (merged) is what makes blocking 2 reachable. The open PRs touching the same files (#3080, #3116, #1334, #2816, #2542, #2515) were not read in this review. Whichever lands first on
MkwVkHosttakes the next API version, and the other renumbers.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.