GPU/HLE: pipelined startup reads and pooled small buffers, rebased onto main #2667

Open
github-bot wants to merge 4 commits from github-bot/gh-2667 into main AGit
Owner

@⁠kais7654 on GitHub · 2026-11-25 17:46 UTC · original
kais7654:perf/startup-load-upstream → main · +1367 −99 · 8 files · 4 commits · open

Rebases #2427 by @⁠imjustprism onto current main (67e8ae1), authorship preserved
commit by commit. This carries the measured startup numbers of the original PR
forward:

launch to first screen main this branch
cold, file cache purged 48.8, 49.5 s 21.0, 21.3, 21.3 s
launched again, files cached 37.0, 47.5 s 5.5, 5.5, 5.5 s

(same bytes read; RX 9070 XT, game folder on a 7200 rpm drive, per the
original report on top of 940d32f).

The rebase points:

  • placed.rs (pooled 16 MiB heaps for small shared buffers) coexists with
    main's placement.rs — main's is for textures, this one for CPU-mapped
    shared buffers; Host::shared_buffer keeps main's diagnostics GPU-upload
    heap preference where a pool slot does not apply.
  • main's held queue (#1663-fixup commit eddde73, "reads into physical pages
    wait for the title's Submit") is integrated into the overlap scheduler: an
    explicit Submit releases the held reads, a queue that submitted itself
    keeps its page reads held until then, and a moved read returns its count
    for a per-read wake (Scheduler::submit_and_wake).
  • the held-queue test adopts the overlapped finish's now must-use return.

The two narrow edges from the review's reading stand as written (the placed
resource's deferred teardown on a fast re-take; dropped_flags staying as
conservative as it is) — flagged for _

Local check: clippy --workspace --all-targets -D warnings with and without
--all-features; victory-hle 162/162 (28 dstorage tests including the held and
overlap suites), victory-gpu 207 passed (the two heap-cap failures that
#1943's fix owns), victory-shader 266 passed (the NVIDIA machine trio of
#2317).

**@⁠kais7654** on GitHub · 2026-11-25 17:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2667) `kais7654:perf/startup-load-upstream` → `main` · +1367 −99 · 8 files · 4 commits · open Rebases #2427 by @⁠imjustprism onto current main (67e8ae1), authorship preserved commit by commit. This carries the measured startup numbers of the original PR forward: | launch to first screen | main | this branch | |---|---|---| | cold, file cache purged | 48.8, 49.5 s | 21.0, 21.3, 21.3 s | | launched again, files cached | 37.0, 47.5 s | 5.5, 5.5, 5.5 s | (same bytes read; RX 9070 XT, game folder on a 7200 rpm drive, per the original report on top of 940d32f). The rebase points: - `placed.rs` (pooled 16 MiB heaps for small shared buffers) coexists with main's `placement.rs` — main's is for textures, this one for CPU-mapped shared buffers; `Host::shared_buffer` keeps main's diagnostics GPU-upload heap preference where a pool slot does not apply. - main's held queue (#1663-fixup commit eddde73, "reads into physical pages wait for the title's Submit") is integrated into the overlap scheduler: an explicit Submit releases the held reads, a queue that submitted itself keeps its page reads held until then, and a moved read returns its count for a per-read wake (`Scheduler::submit_and_wake`). - the held-queue test adopts the overlapped `finish`'s now must-use return. The two narrow edges from the review's reading stand as written (the placed resource's deferred teardown on a fast re-take; `dropped_flags` staying as conservative as it is) — flagged for _ Local check: clippy --workspace --all-targets -D warnings with and without --all-features; victory-hle 162/162 (28 dstorage tests including the held and overlap suites), victory-gpu 207 passed (the two heap-cap failures that #1943's fix owns), victory-shader 266 passed (the NVIDIA machine trio of #2317).
a shared buffer of up to 64 KiB takes a slot in a 16 MiB heap instead of
a committed allocation of its own. a slot is free again when the host
reports the buffer destroyed, and a heap no buffer is left in goes back
on the frame meter's tick.
a read no longer holds its file's position: requests of one file run at
once on overlapped handles. each submitted read wakes one worker, a
worker reuses its source and intermediate buffers up to 1 MiB, and a
queue made with no worker running fails instead of never completing.
The rebase of #2427 (imjustprism) onto main: main's held queue (eddde73)
and the overlap scheduler were reworked around one sizewap. The submit
path keeps both: an explicit Submit still releases the held reads, a
queue that submits itself leaves its reads into physical pages held
until it, and each moved read returns its count for a per-read wake. The
test of the held queue adopts the lift's must-use finish, and the file
object keeps the name a read logs.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:35 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:57 UTC · original

Note: this is the rebase of #2427 which I reviewed in depth earlier (files.rs buffered opens, dstorage overlapped reads + per-worker events + reused staging buffers, placed.rs small-buffer pool) — that review's analysis stands; the measured 49→21 s cold-launch figure came with honest methodology. Re-checking the rebase-specific hunks would still be worth a maintainer look, but the underlying design was verified.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2667#issuecomment-7170232957) Note: this is the rebase of #2427 which I reviewed in depth earlier (files.rs buffered opens, dstorage overlapped reads + per-worker events + reused staging buffers, placed.rs small-buffer pool) — that review's analysis stands; the measured 49→21 s cold-launch figure came with honest methodology. Re-checking the rebase-specific hunks would still be worth a maintainer look, but the underlying design was verified.
Author
Owner

@⁠kais7654 on GitHub · 2026-11-25 18:26 UTC · original

Note: this is the rebase of #2427 which I reviewed in depth earlier (files.rs buffered opens, dstorage overlapped reads + per-worker events + reused staging buffers, placed.rs small-buffer pool) — that review's analysis stands; the measured 49→21 s cold-launch figure came with honest methodology. Re-checking the rebase-specific hunks would still be worth a maintainer look, but the underlying design was verified.

Thanks @⁠kotekompotek. For the maintainer's pass on the rebase-specific
hunks, these are the three places where the rebase touches more than
moving lines:

  1. crates/victory-gpu/src/lib.rs — mod placed; (this PR's small shared
    buffers) now sits next to main's mod placement; (wbkepler's texture
    pools). They do not share code; Host::shared_buffer resolves the two
    — pool slot first, then the committed fallback with main's
    diagnostics GPU-upload heap preference preserved (host.rs, the
    #[cfg(feature = "diagnostics")] let heap block inside the new
    &'static self signature).

  2. crates/victory-hle/src/modules/dstorage.rs — main's held queue
    (eddde73) is integrated into the overlapped scheduler: submit returns
    the read count for submit_and_wake's per-read wake, submit_as(id, explicit) keeps main's semantics (an explicit Submit releases the held
    reads, a self-submit leaves its page reads held, statuses behind a held
    read wait with it). The two pre-existing test suites (held queue +
    overlap) both pass on this merge, which was the intended proof.

  3. The held-queue test adopts the overlapped finish's now must-use
    return (let _ = l.finish(...)), nothing else changed in tests.

Everything else is a clean cherry-pick of d08323e^..d08323e with
imjustprism's authorship preserved per commit.

**@⁠kais7654** on GitHub · 2026-11-25 18:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2667#issuecomment-7170912007) > Note: this is the rebase of #2427 which I reviewed in depth earlier (files.rs buffered opens, dstorage overlapped reads + per-worker events + reused staging buffers, placed.rs small-buffer pool) — that review's analysis stands; the measured 49→21 s cold-launch figure came with honest methodology. Re-checking the rebase-specific hunks would still be worth a maintainer look, but the underlying design was verified. Thanks @⁠kotekompotek. For the maintainer's pass on the rebase-specific hunks, these are the three places where the rebase touches more than moving lines: 1. `crates/victory-gpu/src/lib.rs` — `mod placed;` (this PR's small shared buffers) now sits next to main's `mod placement;` (wbkepler's texture pools). They do not share code; `Host::shared_buffer` resolves the two — pool slot first, then the committed fallback with main's diagnostics GPU-upload heap preference preserved (host.rs, the `#[cfg(feature = "diagnostics")] let heap` block inside the new `&'static self` signature). 2. `crates/victory-hle/src/modules/dstorage.rs` — main's held queue (eddde73) is integrated into the overlapped scheduler: `submit` returns the read count for `submit_and_wake`'s per-read wake, `submit_as(id, explicit)` keeps main's semantics (an explicit Submit releases the held reads, a self-submit leaves its page reads held, statuses behind a held read wait with it). The two pre-existing test suites (held queue + overlap) both pass on this merge, which was the intended proof. 3. The held-queue test adopts the overlapped `finish`'s now must-use return (`let _ = l.finish(...)`), nothing else changed in tests. Everything else is a clean cherry-pick of d08323e^..d08323e with imjustprism's authorship preserved per commit.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 18:37 UTC · original

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of df7cb800 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 185 files ok.
  • cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warnings: 0 warnings.
  • cargo clippy --locked -p victory-gpu --all-targets --features diagnostics -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-hle --lib: 162 passed, 0 failed, 0 ignored.
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1 -> 212 passed, 0 failed, 1 ignored (all 14 new placed::tests pass).
  • NVIDIA GeForce RTX 5090:
    • cargo test --locked -p victory-gpu --features diagnostics --lib placed::tests -- --test-threads=1 -> 14 passed, 0 failed (0.36s).
    • Full victory-gpu --features diagnostics --lib -- --test-threads=1 -> 210 passed, 2 failed, 1 ignored (1.93s). The only 2 failures are the pre-existing RTX 5090 1M view-heap cap baseline failures (#1744: dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views).

Code Review Notes

  • Pipelined startup reads (dstorage.rs, files.rs): Overlapped ReadFile with per-worker manual-reset events, CancelIoEx + volatile Internal == STATUS_PENDING drain on error, staging starvation wakeup (starved -> notify_all), kernel_will_write guard lifetime, and dropped_flags scoping (CreateFileW, GENERIC_READ, non-overlapped only) all look sound.
  • Small buffer pool (placed.rs, host.rs, shadow.rs): Leaf-lock discipline (Pool::slots never held across D3D12 heap/resource creation or drop), 64 KiB alignment and write_bytes zeroing of [0..width_bytes.max(1)), and fence-deferred retirement via ID3DDestructionNotifier look solid.
  • Minor diagnostics-mode ordering nit (crates/victory-gpu/src/host.rs:3230-3240): Host::shared_buffer calls self.small_buffers.buffer(width_bytes) before checking #[cfg(feature = "diagnostics")] self.copies_in_video_memory(), so VICTORY_COPIES_IN_VIDEO_MEMORY=1 still places <= 64 KiB buffers in the system-memory WRITE_BACK pool instead of GPU_UPLOAD. Checking copies_in_video_memory() first would keep that diagnostic switch consistent across all buffer sizes.
  • Note on dstorage.rs merge ordering: touches Lanes::submit_as / Lane alongside #2617 (plain reads held behind a held Status fence).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 18:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2667#issuecomment-7171161135) Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and code review of `df7cb800` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **185 files ok**. - `cargo clippy --locked -p victory-gpu -p victory-hle --all-targets -- -D warnings`: **0 warnings**. - `cargo clippy --locked -p victory-gpu --all-targets --features diagnostics -- -D warnings`: **0 warnings**. - `cargo test --locked -p victory-hle --lib`: **162 passed, 0 failed, 0 ignored**. - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1` -> **212 passed, 0 failed, 1 ignored** (all 14 new `placed::tests` pass). - **NVIDIA GeForce RTX 5090:** - `cargo test --locked -p victory-gpu --features diagnostics --lib placed::tests -- --test-threads=1` -> **14 passed, 0 failed** (0.36s). - Full `victory-gpu --features diagnostics --lib -- --test-threads=1` -> **210 passed, 2 failed, 1 ignored** (1.93s). The only 2 failures are the pre-existing RTX 5090 1M view-heap cap baseline failures (#1744: `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`). ### Code Review Notes - **Pipelined startup reads (`dstorage.rs`, `files.rs`):** Overlapped `ReadFile` with per-worker manual-reset events, `CancelIoEx` + volatile `Internal == STATUS_PENDING` drain on error, `staging` starvation wakeup (`starved` -> `notify_all`), `kernel_will_write` guard lifetime, and `dropped_flags` scoping (`CreateFileW`, `GENERIC_READ`, non-overlapped only) all look sound. - **Small buffer pool (`placed.rs`, `host.rs`, `shadow.rs`):** Leaf-lock discipline (`Pool::slots` never held across D3D12 heap/resource creation or drop), 64 KiB alignment and `write_bytes` zeroing of `[0..width_bytes.max(1))`, and fence-deferred retirement via `ID3DDestructionNotifier` look solid. - **Minor diagnostics-mode ordering nit (`crates/victory-gpu/src/host.rs:3230-3240`):** `Host::shared_buffer` calls `self.small_buffers.buffer(width_bytes)` *before* checking `#[cfg(feature = "diagnostics")] self.copies_in_video_memory()`, so `VICTORY_COPIES_IN_VIDEO_MEMORY=1` still places `<= 64 KiB` buffers in the system-memory `WRITE_BACK` pool instead of `GPU_UPLOAD`. Checking `copies_in_video_memory()` first would keep that diagnostic switch consistent across all buffer sizes. - **Note on `dstorage.rs` merge ordering:** touches `Lanes::submit_as` / `Lane` alongside #2617 (plain reads held behind a held `Status` fence).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:23 UTC · original

Automated triage for the maintainers.

Proposed close. This branch repackages #2427 (imjustprism's small-buffer pool, buffered pack opens in files.rs, and the DirectStorage scheduling and overlapped reads in dstorage.rs) as a new PR. #2427 is still open, merged cleanly into main when it was last triaged, and its author is answering that triage. The triage on #2427 asked for the four changes to be split into separate PRs and for their relation to #1457 and #234 to be explained. This branch keeps them bundled, about 1,400 lines in one PR, so it does not address that and only adds a second copy to track. The rebase work around main's held queue (submit_as / submit_and_wake) is better offered to imjustprism on #2427 or on the split PRs.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2667#issuecomment-7176298606) <!-- victory-triage v1 head=df7cb800ff5e9b4aa7b5f79029196e4498f4937e verdict=proposed-close at=2026-11-25T22:28:30Z --> Automated triage for the maintainers. **Proposed close.** This branch repackages #2427 (imjustprism's small-buffer pool, buffered pack opens in `files.rs`, and the DirectStorage scheduling and overlapped reads in `dstorage.rs`) as a new PR. #2427 is still open, merged cleanly into `main` when it was last triaged, and its author is answering that triage. The triage on #2427 asked for the four changes to be split into separate PRs and for their relation to #1457 and #234 to be explained. This branch keeps them bundled, about 1,400 lines in one PR, so it does not address that and only adds a second copy to track. The rebase work around `main`'s held queue (`submit_as` / `submit_and_wake`) is better offered to imjustprism on #2427 or on the split PRs. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2667/head:github-bot/gh-2667'
git switch 'github-bot/gh-2667'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2667'
git switch 'github-bot/gh-2667'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2667'
git switch 'github-bot/gh-2667'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2667'
git switch 'main'
git merge --squash 'github-bot/gh-2667'
git switch 'main'
git merge --ff-only 'github-bot/gh-2667'
git switch 'main'
git merge 'github-bot/gh-2667'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2667
No description provided.