Skip to content

GPU tests: a world frame's preparing at the published volumes (benchmark) - #2134

Open
r4tedx wants to merge 1 commit into
Marvisak:mainfrom
r4tedx:gpu/prepare-bench
Open

r4tedx wants to merge 1 commit into
Marvisak:mainfrom
r4tedx:gpu/prepare-bench

Conversation

@r4tedx

@r4tedx r4tedx commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

The title run on 940d32f in #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_aliased as xmem reports them). Then it records and runs frames of 33 submissions of 12 lists through Host::execute itself, so the refresh batch, Shadow::update, the guards and their fault handler, arming, snapshots, the page table's prepare and 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 main, the right the title run:

per frame benchmark published
refreshes 22,494 21,974
asking for 21.0 GB 20.6 GB
change checks 274,094 254,139
checked 102.7 GB 92.8 GB
changed and copied 159 MB 240 MB
protect calls 7,813 7,147
snapshots 580 MB 563 MB
marked pages compared 942 1,996
title copies 75 75

It prints the frame's parts next to the published numbers (with the diagnostics feature, every counter of the copies per frame line), 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.rs names 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 shows on main (synthetic)

Ryzen 7 7800X3D, WARP, diag profile with diagnostics, median of 5 frames after 2 warm-up frames, three runs:

benchmark published
preparing 168–225 ms 1,198 ms
of it: refresh batches (checks and copies) 115–156 ms
of it: snapshots 29–37 ms 31.7 ms
of it: naming every copy for title memory 17–22 ms 109 ms
in the kernel's copies 22–27 ms
protecting 10–13 ms
copying back 115–135 ms 122 ms
page faults 962 698,986
  • Checking copies nothing wrote is the largest part. 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.
  • "GPU writes" is mostly the refresh batch it flushes. The step shows 147–197 ms here as it shows 563 ms in the title, and nearly all of it is the batch a root UAV's declaration flushes, plus the snapshots. Declaring a range through marked views costs 31–36 µs when it runs from the start of a 174 MB copy to its end (a set entry per page) and 0.1 µs for its last megabyte.
  • The guards cause no page faults. A guard's round costs 3.2–6.0 µs for the title's write and 4.0–6.6 µs for the refresh, on either kind of memory, with 0.0 page faults a page. The 700,000 page faults a frame of the title run are not the guards' and not the refresh of memory already copied once: the first frame here, which touches every copy for the first time, has 800,000.
  • Copies through the kernel run at 14–24 GB/s, in user mode at 37–53 GB/s (GPU: copy title memory into host memory without a system call #1010 makes them in user mode).
  • The same volumes cost a sixth of the title's time here. So either each operation costs several times more in the title (the published handler time is 74.8 ms; here 14–18 ms for 3,638 faults), or the time is in work these counters do not count. The parts of the copies per frame line 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 through update, writing and copy_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's prepare, and the submission path around them. It goes through Host::execute and reports the diagnostics counters, so its output lines up with a tester's log.

Changes outside the new file

  • host.rs: the mod line.
  • 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

$env:VICTORY_D3D12_WARP = 1
cargo test --profile diag -p victory-gpu --features diagnostics -- --ignored --nocapture --test-threads 1 world_frame_preparing

About 4 s after the build; it takes 1.6 GB of memory twice (title memory and host copies). Without diagnostics it runs on the default adapter and prints the times without the counters.

Tested

  • The benchmark itself, on WARP only (diagnostics build, VICTORY_D3D12_WARP=1): three runs on main as it is here.
  • 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); the rest of the test suite on this branch (outside the new file it adds two test-only functions and a mod line). The title was not used in these tests.

AI-assisted

🤖 Generated with Claude Code

…ark)

An ignored test that runs the submissions of a made-up world frame through
Host::execute on made-up title memory (write-watched pools, physical pages
shown through two views), at the per-frame volumes a title run published
on issue Marvisak#400, and prints the parts next to the published numbers and the
cost of each mechanism on its own. No title, no hardware GPU needed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 warnings
  • cargo 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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 25, 2026
…at the published volumes, head efb35b5)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 25, 2026
…sak#2115 in; Marvisak#2150 left out for now

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nathanbzrr

Copy link
Copy Markdown
Contributor

Confirmed working on Windows 11 x64 / AMD Radeon RX 7600 (driver 32.0.32029.2010, rustc 1.98.1), head efb35b560c51147c37ac30617b7928a56db40df1 merged onto main (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 (with VICTORY_D3D12_WARP unset -> runs on AMD Radeon RX 7600 hardware with full counters; 2 independent runs, median of 5 scored frames):
    • preparing, ms: 244.1 / 227.2
    • copying back, ms: 181.9 / 173.3
    • change 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.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate, but only if the maintainers want to carry it. This adds an ignored benchmark, host::frame_bench::world_frame_preparing. It runs Host::execute at the per-frame volumes published in #400 and needs no title and no hardware GPU. Outside the new file it adds only test-only helpers (copystat::take, Shadow::mark_written) and the mod line. Main already carries ignored benchmarks (host.rs, object.rs). It contains no title data. CI passes.

It is about 590 lines with many made-up constants, and it needs about 3.2 GB of memory when run. Whether to carry it, or keep it with #2136 as the measurement for that change, is a maintainer call.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants