Skip to content

perf: lazy GPU readback on guarded title pages (VICTORY_LAZY_BACK, off) - #574

Merged
LooperSalty merged 5 commits into
mainfrom
perf/lazy-back
Nov 28, 2026
Merged

LooperSalty merged 5 commits into
mainfrom
perf/lazy-back

Conversation

@LooperSalty

Copy link
Copy Markdown
Owner

Summary

Port of the lazy copy-back of JMAN730/victory PR #802 (fever308, GPL-3.0) onto our Vice-Tay base. In game the submit thread spends 10-17 ms a frame copying back what the card wrote (21-47 MB, RTX 4070 SUPER, 1080p): with VICTORY_LAZY_BACK=1 (off by default) a page is copied back only when the title's CPU touches it (guarded pages), and unread page versions stay on the device.

  • b10d4b31 enumerate all aliases for deferred readback (uncapped section-view lookup)
  • 06744005 defer GPU readback to guarded title pages
  • 7c925c18 retain unread GPU-mapped page versions on the device

Source: JMAN730/victory PR #802, credited per commit (Co-authored-by: fever308).

Test plan

  • cargo test --release -p victory-gpu and -p victory-hle, with the switch off and on
  • cargo xtask policy
  • CI
  • In game A/B: copying back ms per frame and fps, switch off then on

🤖 Generated with Claude Code

t and others added 5 commits November 28, 2026 00:37
Add an uncapped section-view lookup for lazy readback, including pages with more than the existing watch limit. Keep the existing capped lookup unchanged and test both paths with 65 aliases. The deferred readback itself is not implemented yet.

Validation: CARGO_BUILD_JOBS=6 cargo test --release -p victory-gpu -p victory-hle; cargo xtask policy. One earlier full test run failed in watch::tests::a_raw_copy_in_watched_memory_keeps_the_other_asked_ranges; the complete rerun passed.

Source: JMAN730/victory PR #802
Co-authored-by: fever308 <89748148+fever308@users.noreply.github.com>

Files:
- THIRD_PARTY.md
- third_party/victory/crates/victory-gpu/src/inplace.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port the demand-readback core to Vice-Tay's mapped and device-local
buffers. Opt in with VICTORY_LAZY_BACK=1. Admit full, singly mapped
pages with a matching CPU baseline after a completed synchronous submit
or at the completed tail of the relay. Keep concurrent landings eager.
Use an independent allocator and fence on the direct queue for faults.
Keep sources alive and save unread versions before the next submission
reuses their storage. Leave title pages inaccessible until materialization.

Materialize for native CPU faults, file and physical storage I/O and mapping
changes. Reject conflicting owners, partial declarations, kernel-pinned
pages and unguarded aliases. Preserve the completed-plan watermark when
deferred pages leave a batch without a fetch. Propagate materialization
failure to ReadFile and DirectStorage and preserve guards on failed fetch.

Validation: offline release suites for victory-gpu and victory-hle and
cargo xtask policy passed with CARGO_BUILD_JOBS=4. The isolated regression
also exercised real D3D12 DMA. Its eager control failed on 196608 bytes
copied at landing versus zero with the pager. No game run or benchmark.

Source: JMAN730/victory PR #802
Co-authored-by: fever308 <89748148+fever308@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use a private COPY queue to capture completed GPU-mapped pages before
their source is reused. Replace superseded versions under continuous
protection and fetch the latest immutable bytes on a CPU fault. Exclude
eligible relay ranges before scanning their mappings. Bound retained
GPU snapshots to 64 MiB and capture separate card-side CPU references
in batches of up to 64 pages before the next submit reuses them.

Drain pending physical versions before publishing a new view. Retry
sparse reads of pages the pager may have just reopened. Keep overlapped
ReadFile control fields safe and propagate failed CRT destination
preparation through errno and ferror. Register the extra CRT hooks only
with lazy readback enabled.

Validate two successive GPU versions and a real fault-time COPY, a new
alias, ReadFile output pointers, stream errors, and eager mode. The
isolated eager control copied 196608 bytes at landing versus zero with
the switch enabled.

Validation: offline CARGO_BUILD_JOBS=4 cargo test --release -p victory-gpu
-p victory-hle passed with VICTORY_LAZY_BACK unset and set to 1. GPU
unit tests: 620 passed, 51 ignored. HLE: 259 passed, 3 ignored. The
integration and doc tests also passed. cargo xtask policy: 375 files OK.
An earlier off-mode run failed watch::tests::a_write_opens_the_view_it_goes_through;
the isolated test and the complete rerun passed. No game benchmark.

The two patches apply in order to e9814cf and reproduce the final files.
Multi-view pages and landings concurrent with a newer submit remain eager.
The upstream hot-page promotion and reprobe heuristics are omitted.

Source: JMAN730/victory PR #802
Co-authored-by: fever308 <89748148+fever308@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-28T01:16:06.283314Z
We couldn’t complete this review. Comment @codex review to try again.
3fa09cd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copy link
Copy Markdown
Contributor

I compared the observable-read contract with KLBF #59 and the Vulkan image case in shadPS4 #5434. Fourteen local CPU model sequences agreed with eager readback at each CPU observation, including replacing an unobserved GPU write and preserving a neighboring page through a partial CPU write. The model bypasses D3D12 and does not establish hardware behavior. A portable extension of your opt-in tests is to leave one page unread, observe its neighbor twice, then overwrite part of the first page. Require correct bytes and report each page transfer count separately from frame gains.

@LooperSalty
LooperSalty merged commit 66b92fb into main Nov 28, 2026
4 checks passed
@LooperSalty
LooperSalty deleted the perf/lazy-back branch November 28, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants