GPU memory: rebasing the closed #916 onto current main, split into three commits (plan for discussion) #2463

Closed
opened 2026-11-29 13:22:50 +00:00 by github-bot · 2 comments
Owner

@⁠CwWwWwW on GitHub · 2026-11-29 13:17 UTC · original

Rebasing the closed #916, split into three commits

PR #916 was closed without merging; the maintainer's comment asked for a rebase on the current
main, ideally in smaller steps, and a new pull request. This issue is the plan and the record for
that rebase, so its shape can be discussed before the new PR.

Work branch on my fork:
https://github.com/CwWwWwW/VIctory-NVIDIA/tree/feat/gpu-memory-rebased
(compare: https://github.com/trustno1-coder/VIctory-NVIDIA/compare/main...CwWwWwW:VIctory-NVIDIA:feat/gpu-memory-rebased)

Approach: re-derive on main, not apply the old diff

main moved from 63b902f (the base of #916) to 829188e: 1,687 commits, +140k/-10k, and the
memory code changed a lot through merged forks: CardCpu, buffer_sides, card_late windows,
the ARENA_CARD_BYTES / VICTORY_MEMORY_CARD_MB by-address cap, window_card_percent /
window_line, card_copy_fits, the checked device-removal fence waits, and inplace/port's
native_stretch / beside / probe / census. A blind apply of the old 3,500-line diff to main
gives 49 conflicting hunks AND would re-introduce fixes main already has (the by-address cap, the
checked waits, the window/arena budget separation, the room-line logging). So the still-new work is
re-implemented on main's current code; the parts of the old audit that main already fixed from
other forks are recorded as such in the docs instead of being re-applied.

The commits (three, in order)

1. c9887c4b GPU memory: split the copy admission from its allocation and add the placement ledger

3 files, +526/-7

  • shadow::card_admission / window_admission: exactly the checks card_for /
    window_card_for make (switch, size limits, host ready, DXGI budget line, the path's cap)
    before any allocation, so the copy paths can ask "would this copy have a device-local side?"
    before a mirror is made. A refused copy is recorded with why.
  • residency: the placement ledger. HeapClass/class_of ask the API (GetHeapProperties)
    what heap class a host buffer has; Fallback names why a copy stayed in system memory;
    fallback_add/fallback_freed count live and total bytes by reason; placement_line prints
    them every 5 s while a fallback copy lives (or when VICTORY_MEMORY_REPORT is set). host.rs
    counts every buffer the copy and transfer machinery makes.
  • The windows' second side (VICTORY_WINDOWS_OWN) is system memory and is no longer charged to
    the window device-local budget; it is in the ledger instead.
  • host::say_separation_switches names the separation switches at startup and warns for the
    documented combinations; tests for the heap classes, the MB line and the counter balance.

2. 3adec350 GPU memory: use the title's own backing where it can be opened

6 files, +973/-83

  • inplace: openability (private committed memory, one contiguous run of one section through our
    own refcounted SectionView, or a refusal reason), one shared region per section run,
    place_view_part, and place_fallback: page-pool view memory first (VICTORY_INPLACE_VIEW=1
    windows, =2 title buffers), then private memory (VICTORY_INPLACE=3), only where admission
    already refused a device-local side. The mirror stays the fallback; every refusal is counted
    with its reason.
  • shadow: place_fallback at exactly those refused points (lookup, loose). A placed copy
    makes no staging/mirror, no card side, no hash twin, no send/fetch state, no refresh, snapshot,
    compare or copy-back. An exact placed-copy registry lets a mapping change let go of exactly the
    copies over the range instead of a bounded scan. gpu_writes declares a placed copy's shader
    writes to the copy machinery, so the late waits order a CPU reader behind the flight.
  • xmem: VirtualProtect is intercepted unconditionally and XMemFreeDefault's raw
    VirtualFree for 32-bit allocations lets placed copies go before the kernel call; watch
    already calls inplace::title_memory_freeing before the title's own free/decommit/release.
  • port: uses the shared SectionView (one owner, one lifetime); a section close forgets its
    regions.
  • residency: directly backed copies and refused direct asks are counted in the ledger.
  • WARP tests for the placement mechanics, the section lifetime, the shared region, the exact
    invalidation and the counters.

3. docs commit (pending)

The audit documents re-checked against 829188e: docs/memory-separation.md,
docs/memory-separation-window-budget.md, docs/copy-bridges.md — the copy inventory and
classification, what main already fixes via other forks, what the ledger now makes visible, the
remaining copies and why, what a real NVIDIA GPU run must establish before any switch becomes a
default, and the verification record (checks, CI runs).

What does not change

  • Every direct-access switch is off by default; with them unset the product path behaves as at
    829188e (no policy, threshold, budget, launcher default or rendering change).
  • Required copies stay: carded VRAM copies, by-address shader memory, layout/format-dependent
    textures/targets/depth, and the D3D12 infrastructure.
  • Placed copies declare their shader writes; the title's own kernel calls are not blocked because
    placed copies are let go before them.

Validation so far

  • cargo check --workspace --all-targets --locked: PASS after each commit, no new warnings in the
    changed files.
  • Full cargo test --workspace --locked and the all-features build check are running on GitHub
    Actions (Windows, WARP) from a temporary ci/memory-rebase branch (test workflow only, not part
    of the PR): https://github.com/CwWwWwW/VIctory-NVIDIA/actions/runs/46266652500 — results will be
    added here when done.
  • Local cargo test cannot link on this machine (GNU raw-dylib/dlltool), so the test evidence is
    the Windows CI run.
  • No NVIDIA hardware here: nothing is claimed about driver acceptance, pinning, coherency, PCIe
    cost or physical residency.

For discussion

  1. Is three commits a good split, or would you prefer another grouping (e.g. admission split and
    ledger separate, or the docs first)?
  2. Is the placement ledger's 5-second line, and VICTORY_MEMORY_REPORT, acceptable in the product
    log, or would you rather it be diagnostics-build only?
  3. The view-byte copies (exact()) would need deeper changes in the new exact pool, so they stay
    on the copy path for now; is that acceptable for a first PR?
  4. Anything from the old #916 you explicitly do not want back (for example the legacy
    VICTORY_INPLACE 1/2 behaviour)?

The new PR will be opened from the branch above once the docs commit and the CI results are in, so
it can be reviewed commit by commit.

**@⁠CwWwWwW** on GitHub · 2026-11-29 13:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2463) # Rebasing the closed #916, split into three commits PR #916 was closed without merging; the maintainer's comment asked for a rebase on the current main, ideally in smaller steps, and a new pull request. This issue is the plan and the record for that rebase, so its shape can be discussed before the new PR. Work branch on my fork: https://github.com/CwWwWwW/VIctory-NVIDIA/tree/feat/gpu-memory-rebased (compare: https://github.com/trustno1-coder/VIctory-NVIDIA/compare/main...CwWwWwW:VIctory-NVIDIA:feat/gpu-memory-rebased) ## Approach: re-derive on main, not apply the old diff `main` moved from `63b902f` (the base of #916) to `829188e`: 1,687 commits, +140k/-10k, and the memory code changed a lot through merged forks: `CardCpu`, `buffer_sides`, `card_late` windows, the `ARENA_CARD_BYTES` / `VICTORY_MEMORY_CARD_MB` by-address cap, `window_card_percent` / `window_line`, `card_copy_fits`, the checked device-removal fence waits, and inplace/port's `native_stretch` / `beside` / probe / census. A blind apply of the old 3,500-line diff to main gives 49 conflicting hunks AND would re-introduce fixes main already has (the by-address cap, the checked waits, the window/arena budget separation, the room-line logging). So the still-new work is re-implemented on main's current code; the parts of the old audit that main already fixed from other forks are recorded as such in the docs instead of being re-applied. ## The commits (three, in order) ### 1. `c9887c4b` GPU memory: split the copy admission from its allocation and add the placement ledger 3 files, +526/-7 - `shadow::card_admission` / `window_admission`: exactly the checks `card_for` / `window_card_for` make (switch, size limits, host ready, DXGI budget line, the path's cap) before any allocation, so the copy paths can ask "would this copy have a device-local side?" before a mirror is made. A refused copy is recorded with why. - `residency`: the placement ledger. `HeapClass`/`class_of` ask the API (`GetHeapProperties`) what heap class a host buffer has; `Fallback` names why a copy stayed in system memory; `fallback_add`/`fallback_freed` count live and total bytes by reason; `placement_line` prints them every 5 s while a fallback copy lives (or when `VICTORY_MEMORY_REPORT` is set). host.rs counts every buffer the copy and transfer machinery makes. - The windows' second side (`VICTORY_WINDOWS_OWN`) is system memory and is no longer charged to the window device-local budget; it is in the ledger instead. - `host::say_separation_switches` names the separation switches at startup and warns for the documented combinations; tests for the heap classes, the MB line and the counter balance. ### 2. `3adec350` GPU memory: use the title's own backing where it can be opened 6 files, +973/-83 - `inplace`: openability (private committed memory, one contiguous run of one section through our own refcounted `SectionView`, or a refusal reason), one shared region per section run, `place_view_part`, and `place_fallback`: page-pool view memory first (`VICTORY_INPLACE_VIEW=1` windows, `=2` title buffers), then private memory (`VICTORY_INPLACE=3`), only where admission already refused a device-local side. The mirror stays the fallback; every refusal is counted with its reason. - `shadow`: `place_fallback` at exactly those refused points (`lookup`, `loose`). A placed copy makes no staging/mirror, no card side, no hash twin, no send/fetch state, no refresh, snapshot, compare or copy-back. An exact placed-copy registry lets a mapping change let go of exactly the copies over the range instead of a bounded scan. `gpu_writes` declares a placed copy's shader writes to the copy machinery, so the late waits order a CPU reader behind the flight. - `xmem`: `VirtualProtect` is intercepted unconditionally and `XMemFreeDefault`'s raw `VirtualFree` for 32-bit allocations lets placed copies go before the kernel call; `watch` already calls `inplace::title_memory_freeing` before the title's own free/decommit/release. - `port`: uses the shared `SectionView` (one owner, one lifetime); a section close forgets its regions. - `residency`: directly backed copies and refused direct asks are counted in the ledger. - WARP tests for the placement mechanics, the section lifetime, the shared region, the exact invalidation and the counters. ### 3. docs commit (pending) The audit documents re-checked against `829188e`: `docs/memory-separation.md`, `docs/memory-separation-window-budget.md`, `docs/copy-bridges.md` — the copy inventory and classification, what main already fixes via other forks, what the ledger now makes visible, the remaining copies and why, what a real NVIDIA GPU run must establish before any switch becomes a default, and the verification record (checks, CI runs). ## What does not change - Every direct-access switch is off by default; with them unset the product path behaves as at `829188e` (no policy, threshold, budget, launcher default or rendering change). - Required copies stay: carded VRAM copies, by-address shader memory, layout/format-dependent textures/targets/depth, and the D3D12 infrastructure. - Placed copies declare their shader writes; the title's own kernel calls are not blocked because placed copies are let go before them. ## Validation so far - `cargo check --workspace --all-targets --locked`: PASS after each commit, no new warnings in the changed files. - Full `cargo test --workspace --locked` and the all-features build check are running on GitHub Actions (Windows, WARP) from a temporary `ci/memory-rebase` branch (test workflow only, not part of the PR): https://github.com/CwWwWwW/VIctory-NVIDIA/actions/runs/46266652500 — results will be added here when done. - Local `cargo test` cannot link on this machine (GNU raw-dylib/dlltool), so the test evidence is the Windows CI run. - No NVIDIA hardware here: nothing is claimed about driver acceptance, pinning, coherency, PCIe cost or physical residency. ## For discussion 1. Is three commits a good split, or would you prefer another grouping (e.g. admission split and ledger separate, or the docs first)? 2. Is the placement ledger's 5-second line, and `VICTORY_MEMORY_REPORT`, acceptable in the product log, or would you rather it be diagnostics-build only? 3. The view-byte copies (`exact()`) would need deeper changes in the new exact pool, so they stay on the copy path for now; is that acceptable for a first PR? 4. Anything from the old #916 you explicitly do not want back (for example the legacy `VICTORY_INPLACE` 1/2 behaviour)? The new PR will be opened from the branch above once the docs commit and the CI results are in, so it can be reviewed commit by commit.
github-bot 2026-11-29 13:22:50 +00:00
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 13:22:50 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-29 13:18 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-29 13:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2463#issuecomment-7256436790) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Author
Owner

@⁠CwWwWwW on GitHub · 2026-11-29 13:22 UTC · original

Closing this: it was opened before the work was finished, and it is about the rebase rather than about the problems the commits solve. A proper write-up of the problems the commits address will follow once the work is complete.

**@⁠CwWwWwW** on GitHub · 2026-11-29 13:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2463#issuecomment-7256486742) Closing this: it was opened before the work was finished, and it is about the rebase rather than about the problems the commits solve. A proper write-up of the problems the commits address will follow once the work is complete.
This discussion has been locked. Commenting is limited to contributors.
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/trustno1-coder--VIctory-NVIDIA#2463
No description provided.