GPU tests: a world frame's preparing at the published volumes (benchmark) #2134
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2134
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2134"
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?
@r4tedx on GitHub · 2026-11-25 05:48 UTC · original
r4tedx:gpu/prepare-bench→main· +772 −0 · 4 files · 5 commits · openThe title run on
940d32fin #400 (comment, RX 6700 XT) put 774–1,198 ms of a 1.2–2.0 s world frame into preparing submissions on the CPU, and published the volumes behind it: 21,974 refreshes asking for 20.6 GB, 254,139 change checks over 92.8 GB of which 99.7 % was unchanged, 7,147 protect calls, 698,986 page faults. Nothing in the tree replays those volumes, so a change to the refresh, guard or arming code can only be measured in the title.This adds an ignored benchmark,
host::frame_bench::world_frame_preparing, that does. It needs no title and no hardware GPU: it runs on the software adapter.What it does
It makes 4,100 host copies of 1.6 GB of made-up title memory of the two kinds the runtime gives a title: write-watched pools, and physical pages shown through two views (one view per run, and again page by page through placeholders, reported with
title_memory_aliasedasxmemreports them). Then it records and runs frames of 33 submissions of 12 lists throughHost::executeitself, so the refresh batch,Shadow::update, the guards and their fault handler, arming, snapshots, the page table'sprepareand both copy-backs are the real ones. The lists record no GPU commands.Per frame it asks for what the published line asks for. The left column is this benchmark on
main63bcca4(WARP,diagprofile, median of 5 frames), the right the title run on940d32f:It prints the frame's parts next to the published numbers (with the
diagnosticsfeature, every counter of thecopies per frameline), and then what each mechanism costs on its own: a check of a copy nothing wrote, a check of the heap under declared ranges, declaring a range as written, a guard's round (the title's write, the fault, the next refresh) on each kind of memory with the page faults it causes, and a copy through the kernel against one in user mode.What the published line does not say is made up, and the file says so at each constant: how many copies there are and how large (4,100 of 365 KB on average follows from the checks;
memory.rsnames the count), which lists use title memory, how many ranges shaders declare, and whether the title writes the same pages every submission. Not modelled: title threads writing while a submission is prepared (the title's writes come between submissions, on the same thread), heap-indexed views (Step::Heap), textures.What it showed on
940d32f(synthetic)Ryzen 7 7800X3D, WARP,
diagprofile withdiagnostics, median of 5 frames after 2 warm-up frames, three runs:940d32f. A check costs 138–146 ns on its own and 332–354 ns through a refresh batch, 274,094 times a frame: about 90 ms, half of preparing here. A separate PR removes it.mainthe refresh batch no longer checks copies that nothing wrote: a frame makes 1,325 change checks, not the 274,094 this benchmark made on940d32fand not the title's published 254,139. JoeY54 and xndbogdan got the same counters on four hardware adapters.distant_refreshes_preparingadds one batch with ranges a page apart and 8 MiB apart in one copy, and prints how many bytes it checks and copies. That tells apart a batch that keeps one span, one that joins ranges a page apart, and one that keeps exactly what was asked.copies per frameline the comment did not quote would tell: guard faults, pages opened, pages written, page faults while preparing, protecting, moves.These are wall times of a made-up pattern on an idle process. They say which change moves which part, not what frame rate the title gets.
Next to the other benchmarks
#1743 (
world_frame_copies) and #2051 (world_frame_refreshes) replay one 174 MB heap throughupdate,writingandcopy_back, to compare copy and snapshot changes. This one is about what those leave out: thousands of copies asked for many times over, the guards, the page table'sprepare, and the submission path around them. It goes throughHost::executeand reports the diagnostics counters, so its output lines up with a tester's log.Changes outside the new file
host.rs: themodline.shadow.rs:Shadow::mark_written(tests only), which sets a page's bit in the views' written-pages bitmap as a shader does.copystat.rs:take()(tests only), the counters since they were last read.Running it
About 4 s after the build; it takes 1.6 GB of memory twice (title memory and host copies). Without
diagnosticsit runs on the default adapter and prints the times without the counters.Tested
diagnosticsbuild,VICTORY_D3D12_WARP=1): three runs on940d32f, and once more at35eac210(merged withmain63bcca4) together withdistant_refreshes_preparing.cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1at35eac210on WARP: 246 passed, 0 failed, 3 ignored.cargo clippy -p victory-gpu --all-targets --locked -- -D warnings, with and without--features diagnostics: clean.Not run: the title; any hardware GPU (everything above is the software adapter);
distant_refreshes_preparingon #2428, #1555 or #1818. The title was not used in these tests.AI-assisted
🤖 Generated with Claude Code
@nathanbzrr on GitHub · 2026-11-25 08:40 UTC · original
Confirmed working on Windows 11 x64 / AMD Radeon RX 7600 (driver
32.0.32029.2010,rustc 1.98.1), headefb35b560c51147c37ac30617b7928a56db40df1merged ontomain(940d32f69b):cargo test -p victory-gpu --lib -- --test-threads=1: 143 passed, 0 failed.cargo test --profile diag -p victory-gpu --features diagnostics --locked --lib -- --ignored --nocapture --test-threads=1 world_frame_preparing(withVICTORY_D3D12_WARPunset -> runs on AMD Radeon RX 7600 hardware with full counters; 2 independent runs, median of 5 scored frames):preparing, ms: 244.1 / 227.2copying back, ms: 181.9 / 173.3change checks: 274,094.0 (checked, MB: 102,722.0,changed (copied), MB: 159.1)unit_costs—declaring the heap from its start to its end as written (marked): 73.0 us (ending it 9.1 us); unchanged copy through refresh batch: 437 ns.Clean, deterministic synthetic baseline for hardware comparisons.
AI-assisted; synthetic tests only, no game files, dumps, or captures used.
@Marvisak on GitHub · 2026-11-25 10:49 UTC · original · edited 2026-11-26 07:21 UTC
Automated triage for the maintainers.
Merge candidate (with the earlier size caveat). The new head
35eac21addresses the last review.Shadow::mark_written(test-only,crates/victory-gpu/src/shadow.rs) now callsbitmap(false), which matchesmain'sfn bitmap(memory: bool). The figures in the description are refreshed for currentmain. The newdistant_refreshes_preparingcase inhost/frame_bench.rsasks one batch for ranges far apart and a page apart in one copy, so it can tellmain, #2428/#1555 and #1818 apart. Everything outsideframe_bench.rsis#[cfg(test)](copystat::take,mark_written), and both benches are#[ignore].On your reply: the three points are done as agreed. The table for the three refresh PRs is expected, not measured, so someone should run the case on them before it is used to choose between them.
The earlier caveat still stands. It is about 750 lines of synthetic benchmark that needs about 3 GB when run, so whether to carry it in the tree is the maintainer's decision.
CI:
checkpassing on this head.Generated by Claude Code
@shortselow-byte on GitHub · 2026-11-25 14:11 UTC · original
Two limits I ran into while using
world_frame_preparingto compare the copy-back PRs, at headefb35b5onmain940d32f(Windows 11, Rust 1.98.1 MSVC, Ryzen 5 5600X,diagprofile withdiagnostics, WARP):1. The frame never reaches the byte-merge loop of the copy-back. With temporary counters in
Shadow::copy_back_or_not, the per-piece part fromhost != oldon (theread_into, the merge loop,write_mapped) ran for 0 pieces over the whole benchmark, and with #2054 merged itsmerge_writebackwas called 0 times. So PRs that change that loop (#2054, #1867 and others) cannot show a difference here either way. A case that makes the GPU change a few bytes of an unmarked declared range would cover it.2.
copying backmoves by about half with code layout alone. Five builds of the same tree, each in its own target directory, three runs each, interleaved, nothing else running (median of 5 frames, ms):The function is reached only behind an
AtomicBoolthat is never set, at the top ofcopy_back_or_not, so the code that runs is the same in all five. Identical sources give the same time, but adding dead code movescopying backfrom ~122 to ~180 ms. That is how this first showed up: #2054 looked ~45 % slower here although none of its code runs.So a single build per side can show a ±50 % difference that has nothing to do with the change. Comparing PRs with this benchmark needs either a check that the changed code runs at all, or several builds per side (e.g. with a trivial unrelated change) before reading a difference.
@r4tedx on GitHub · 2026-11-25 14:42 UTC · original
@shortselow-byte thank you. Both points held up when I read the code, and the head is now
934da01b, one commit onefb35b5(onlyhost/frame_bench.rs).1. The merge loop. You're right that nothing reached it, and it happens even before the
host != oldtest. Every declared range was either marked or kept out of title memory:Shadow::writingarms the pages and returns first (shadow.rs:288-291).defer_missed(|| true), sogoes_backis false (host.rs:967-975). They go throughkeep_writes, which never copies back.The fix: once per submission, list 7 refreshes one 128 KiB copy declared unmarked, and the shaders' part of list 11 changes 8 bytes of one of its pieces without a mark. That's 33 pieces a frame through
read_into, the merge andwrite_mapped. The list makes one refresh fewer in its place, so the refresh count is unchanged. The output now prints the pieces changed and merged, the bytes written back, the bytes compared, and the unit cost of one such copy-back.efb35b5.2. Layout noise. A note at the top of the file and a line in the output say what your table shows. On your setup (
diagprofile, WARP), adding never-called functions movedcopying backfrom ~122 to ~180 ms, though not every such change does. So a comparison should first check with the counters that the changed code runs, then use several builds per side.What ran here, WARP only: clippy clean, the victory-gpu lib tests 146 passed, and the benchmark passed with 33 pieces merged and 2.2 MB written back a frame. That benchmark run used the unoptimized test profile, so its times aren't comparable with your
diagfigures. I haven't made adiagrun of the new head yet; I'll add it here when it's done. Synthetic only; no title data used.AI-assisted
@xndbogdan on GitHub · 2026-11-25 23:33 UTC · original
I ran this on two machines to compare open copy PRs, and found three things.
1. It doesn't build on current
main(842b0cb).Shadow::mark_writtencallsbitmap(), which now takesmemory: bool(one bitmap for shaders that use title memory, one for the others). I usedbitmap(false), since the benchmark imitates writes through views. That was the only change needed; everything else built and every run passed its checks.2.
mainhas moved a lot since your description. Same benchmark,diagwithdiagnostics, hardware adapter, median of 5 frames, three runs each:That's 1,325 change checks against the 274,094 in the description.
3. It can't compare the refresh-range PRs. #2428, #1555 and #1818 each stop a batch from refreshing one
[min, max]span over distant ranges of a copy (main'sBatch::addstill does that). In this benchmark, all three check and copy exactly whatmaindoes: 6,657.8 MB checked and 243.7 MB copied, on both machines, in all runs. Their preparing times sit 0–6 ms frommain's on the Ryzen and withinmain's range on the Xeon, which is layout noise as your note describes. So the frame never asks for two distant ranges of the same copy within one batch. A list that refreshes, say, two small ranges at opposite ends of one large copy would let these three be told apart.In the same rounds, #2051 (copies on several threads) took preparing to 33.9–37.6 ms and 131.4–134.0 ms with identical counters. Details on #2051.
AI-assisted (Claude Code). Synthetic benchmark only, no game data.
@r4tedx on GitHub · 2026-11-25 23:35 UTC · original
@xndbogdan thank you. All three hold, and the third is the most useful: the benchmark's frame never asks one batch for two distant ranges of the same copy, so it can't tell the refresh-range PRs apart.
mainnow hasfn bitmap(memory: bool)inshadow.rs, while this branch still callsbitmap(). Since the benchmark imitates writes through views,bitmap(false)is the right choice, as you did.940d32f, before the tracking changes main has had since. I'll mark them as such and put current-main numbers next to them.I'll post the head here when it's updated: main merged in, the build fixed, the new case added, and the WARP run results. Checked here by reading the code at
main63bcca4; no title data used.AI-assisted
@JoeY54 on GitHub · 2026-11-26 06:11 UTC · original
Hardware verification of
world_frame_preparingon RTX 5090 and the Ryzen 9 9950X3D iGPU, as claimed on #1633. This complements my earlier WARP run.Setup.
934da01merged ontomain63bcca4(no conflicts). One build fix, as xndbogdan describes:bitmap(false)inShadow::mark_written. Windows 11 build 26300, Rust 1.98.1, Ryzen 9 9950X3D.To put the host device on a chosen adapter I used a local test-only patch:
VICTORY_ADAPTERmatches the adapter description.Correctness. Every run passes its checks. The counters are identical on both adapters, in every run, and match xndbogdan's RTX 5080 / RX 9070 XT numbers:
Timings (median of 5 frames per run):
GPU time is about 1 ms a frame on both adapters, so the frame is almost entirely CPU work. That's why the two adapters overlap. The run-to-run spread (68–96 ms on the same build) is larger than the adapter difference, so these runs can't rank the GPUs. Possible causes: the 9950X3D's two CCDs and where the scheduler puts the thread, and the layout effect the bench's notes describe.
Compared with xndbogdan's Ryzen 7 9800X3D + RTX 5080 (48.1–50.2 / 39.0–42.0 ms on
842b0cb), this host is slower. The differences are a newermainand a different CPU. Since the GPU barely enters, the gap says more about the CPU andmainthan about the GPU.Synthetic benchmark only, no game data. The merge and test patch are local, not pushed. AI-assisted (Claude Code).
@r4tedx on GitHub · 2026-11-26 06:33 UTC · original
Updated the head to
35eac210, as the triage asked:Builds on current
main.bd2ddfdemergesmain63bcca4(no conflicts; nothing outside the branch's four files changes), and the test-onlyShadow::mark_writtennow callsbitmap(false), since the bench imitates writes through views that do not use title memory.New case
distant_refreshes_preparing(07f6fd60, extended in35eac210). One list refreshes three 64 KiB ranges of one 8 MiB write-watched copy in one batch: pages 0 and 2 (one page apart), and page 127 (8 MiB away). The title also wrote page 1, which nobody asks for. The list then declares the three ranges as written and changes one dword in each. The case asserts that the refreshes reached the copy and that the GPU's dwords reached title memory, and prints the counters.On
main(WARP,diagprofile):The batch keeps one span from page 0 to page 127, so it checks the whole 8 MiB copy and copies every written page in it, page 1 included.
What the three PRs should print, going by their merge rules (expected, not measured: I did not run the case on any of them):
main(measured)a <= to + COALESCE)COALESCE_GAP= one page:from <= cur_to + gap)So the case separates
main, the two PRs that join ranges a page apart, and #1818. It does not separate #2428 from #1555: at this gap they follow the same rule. None of the three changes the copy-back, so its line should read the same on all of them.The frame on current
main.world_frame_preparingat35eac210on WARP prints 22,499 refreshes asking for 21.0 GB, 1,325 change checks (not the 274,094 measured on940d32f) over 6,657.8 MB, of which 243.7 MB changed and was copied, and 33 declared pieces merged (2.2 MB). The description is refreshed below.Thanks @JoeY54 for the hardware run (comment). They ran
world_frame_preparingat934da01merged onto63bcca4withbitmap(false), on an RTX 5090 and on the Ryzen 9 9950X3D's iGPU. Their counters were identical on both adapters and matched xndbogdan's: 1,325 checks, 6,657.8 MB checked / 243.7 MB copied, 22,499 refreshes, 33 merged pieces of 2.2 MB. Preparing took 68–96 ms on the 5090 and 80–114 ms on the iGPU. The run-to-run spread was larger than the gap between the adapters. My WARP run at35eac210gives the same counters.The earlier caveat still stands. This is about 680 lines of synthetic constants and needs about 3 GB to run, so whether to carry it in the tree is your call.
Tested at
35eac210, all on the software adapter (VICTORY_D3D12_WARP=1):cargo clippy --locked -p victory-gpu --all-targets -- -D warnings, with and without--features diagnostics: clean.cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 246 passed, 0 failed, 3 ignored (the two benches and an existing release benchmark).diagprofile: both pass. Counters as above.Not run: any hardware GPU, the title, and the new case on #2428, #1555 or #1818. Only synthetic data was used. No title data was used.
AI-assisted
@DenRakEiw on GitHub · 2026-11-25 06:02 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-gpu --lib frame_bench— compiles cleanly and respects#[ignore]cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (184 files ok)Clean opt-in world-frame preparation benchmark harness in
host/frame_bench.rs. Looks good.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 06:33 UTC · original · reviewed
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
GPU tests: world frame preparing at published volume — test-only PR for GPU paths; can't run on macOS, relies on Windows CI.
@fuzeofficlal on GitHub · 2026-11-26 13:51 UTC · original · approved these changes
Reviewed and verified head
35eac210649e528dddc03530f86e3e0e7184df5b(clean merge withorigin/main63bcca43) on Windows 11 x64 (Ryzen 9 9950X, NVIDIA GeForce RTX 5090 + D3D12 WARP, Rust 1.98.1).Code review
copystat::take(crates/victory-gpu/src/copystat.rs:117),mod frame_bench(crates/victory-gpu/src/host.rs:4136), andShadow::mark_written(crates/victory-gpu/src/shadow.rs:174, callingbitmap(false)) are strictly#[cfg(test)], and bothworld_frame_preparing(frame_bench.rs:401) anddistant_refreshes_preparing(frame_bench.rs:521) are#[ignore = "benchmark"]so default test runs incur no runtime or memory overhead.diagnosticscounter hooks incrates/victory-gpu/src/host/frame_bench.rsare cleanly feature-gated, so both--profile diag --features diagnosticsand plain--releasebuild and run cleanly.host.rs) without merge conflicts.Verification & Ryzen 9 9950X + RTX 5090 / WARP measurements
cargo xtask policy:192 files ok;cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default &--all-features): 0 warningscargo test --locked -p victory-gpu --lib -- frame_bench(default &--features diagnostics):0 passed, 0 failed, 2 ignoreddistant_refreshes_preparing(--test-threads=1, passed on RTX 5090diag, RTX 5090--release, and WARPdiag):3 refreshes, 196608 bytes requested; 1 change checks, 8388608 bytes checked, 262144 bytes copied; 196608 bytes snapshotted, 196608 bytes compared for copy-back; 196608 bytes mergedworld_frame_preparing(--test-threads=1, median of 5 frames, 4,100 copies / 1.62 GB synthetic memory, no 1M view-heap issue on RTX 5090):--profile diag --features diagnostics):preparing62.8 ms (GPU 0.6 ms),copying back46.9 ms (33.0 merged pieces / 2.2 MB),title's writes21.3 ms;22,499refreshes (21,038.6 MB),1,325change checks (6,657.8 MB checked, 243.7 MB copied),7,900protect calls,577.2 MBsnapshots (22.6 ms),983marked pages (48.4 MB, 18.2 ms),75title copies; 8 MiB copy unit cost24,655 MB/skernel vs81,045 MB/suser mode.--release, withoutdiagnostics):preparing59.1 ms (GPU 0.5–0.6 ms),copying back46.2 ms (33.0 merged / 2.2 MB),title's writes19.6 ms.VICTORY_D3D12_WARP=1,--profile diag --features diagnostics):preparing60.6 ms (GPU 7.2 ms),copying back47.0 ms; all counters identical to the RTX 5090 run.Well-scoped synthetic benchmark harness; approving.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.