GPU: small first scratch chunk per list; log host memory against budget #1666

Open
github-bot wants to merge 2 commits from github-bot/gh-1666 into main AGit
Owner

@⁠cyudev on GitHub · 2026-11-24 20:35 UTC · original
cyudev:gpu/scratch-first-chunk → main · +150 −13 · 1 files · 2 commits · open

GPU: small first scratch chunk per list; log host memory against budget

HostList::scratch hands out upload memory in 4 MiB chunks, and a list keeps every chunk across resets. In the world the title records with hundreds of host lists, most of which need a few KiB per recording. So each list that ever touched scratch pinned a full 4 MiB upload buffer.

On an RTX 3060 Ti (8 GB) with 16 GB RAM, running r4tedx's integration/testers update 10, this went as follows:

  1. Upload buffers failed with E_OUTOFMEMORY (no upload buffer … size=4194304, confirmed with the debug layer).
  2. Either the device was removed (DXGI_ERROR_DEVICE_REMOVED), or the title's own crash handler fired with memory.load_percent: 97.

This happened a few minutes into the world. Report on #71: #71

Change

  • A list's first chunk is now 256 KiB. A request that does not fit gets 4 MiB chunks after it, as before. Requests over 4 MiB still get their own buffer, freed at reset.

  • On reset, a list keeps only its first chunk.

  • Every 5 s, next to the frame-rate line:

    host memory: video <used>/<budget> MB, system <used>/<budget> MB; list scratch <n> MB in <lists> lists
    

    The figures come from IDXGIAdapter3::QueryVideoMemoryInfo, so testers can see memory pressure without the debug layer.

Measured

Same machine and tree, VICTORY_SHADER_LOOP_LIMIT=32, one run each:

before after
list scratch held, a minute into the world 1,476-1,588 MB (369 lists × 4 MiB; the most chunks in any one list was 1) 130-170 MB
time in the world before the end ~2.5-3.5 min (two runs) ~6 min

A first attempt that only trimmed chunks past the first on reset changed nothing. No list ever held more than one chunk; the cost was the size of that one chunk.

Not fixed here

The run after the change still ended with a device removal. System memory the GPU uses kept climbing to ~5.6 GB of a 7.4 GB budget from other sources. Video memory sat above budget (~9.2 GB of 7.2 GB) from world entry on. Those are separate problems.

Testing

  • cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings: clean.
  • cargo test -p victory-gpu: 52 passed on the RTX 3060 Ti, 55 with --features diagnostics on WARP. Two new tests cover the scratch scheme: a small first chunk; requests packed and 256-byte aligned; growth by 4 MiB chunks without overlap; a request over the small chunk taking a big first chunk; a request over 4 MiB getting its own buffer; a reset keeping and reusing only the first chunk.
  • In the title on the RTX 3060 Ti as above. The in-game runs were on integration/testers with this change applied; this PR is the same change on main.

🤖 Generated with Claude Code

**@⁠cyudev** on GitHub · 2026-11-24 20:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1666) `cyudev:gpu/scratch-first-chunk` → `main` · +150 −13 · 1 files · 2 commits · open ## GPU: small first scratch chunk per list; log host memory against budget `HostList::scratch` hands out upload memory in 4 MiB chunks, and a list keeps every chunk across resets. In the world the title records with hundreds of host lists, most of which need a few KiB per recording. So each list that ever touched scratch pinned a full 4 MiB upload buffer. On an RTX 3060 Ti (8 GB) with 16 GB RAM, running r4tedx's `integration/testers` update 10, this went as follows: 1. Upload buffers failed with `E_OUTOFMEMORY` (`no upload buffer … size=4194304`, confirmed with the debug layer). 2. Either the device was removed (`DXGI_ERROR_DEVICE_REMOVED`), or the title's own crash handler fired with `memory.load_percent: 97`. This happened a few minutes into the world. Report on #71: https://git.gtahub.st/github/Marvisak--VIctory/issues/71 ### Change - A list's first chunk is now 256 KiB. A request that does not fit gets 4 MiB chunks after it, as before. Requests over 4 MiB still get their own buffer, freed at reset. - On reset, a list keeps only its first chunk. - Every 5 s, next to the frame-rate line: ``` host memory: video <used>/<budget> MB, system <used>/<budget> MB; list scratch <n> MB in <lists> lists ``` The figures come from `IDXGIAdapter3::QueryVideoMemoryInfo`, so testers can see memory pressure without the debug layer. ### Measured Same machine and tree, `VICTORY_SHADER_LOOP_LIMIT=32`, one run each: | | before | after | |---|---|---| | list scratch held, a minute into the world | 1,476-1,588 MB (369 lists × 4 MiB; the most chunks in any one list was **1**) | 130-170 MB | | time in the world before the end | ~2.5-3.5 min (two runs) | ~6 min | A first attempt that only trimmed chunks past the first on reset changed nothing. No list ever held more than one chunk; the cost was the size of that one chunk. ### Not fixed here The run after the change still ended with a device removal. System memory the GPU uses kept climbing to ~5.6 GB of a 7.4 GB budget from other sources. Video memory sat above budget (~9.2 GB of 7.2 GB) from world entry on. Those are separate problems. ### Testing - `cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings`: clean. - `cargo test -p victory-gpu`: 52 passed on the RTX 3060 Ti, 55 with `--features diagnostics` on WARP. Two new tests cover the scratch scheme: a small first chunk; requests packed and 256-byte aligned; growth by 4 MiB chunks without overlap; a request over the small chunk taking a big first chunk; a request over 4 MiB getting its own buffer; a reset keeping and reusing only the first chunk. - In the title on the RTX 3060 Ti as above. The in-game runs were on `integration/testers` with this change applied; this PR is the same change on `main`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Every host list keeps its first upload chunk across resets, and that chunk
was 4 MiB. The title records with hundreds of lists that mostly need a few
KiB, so in the world 369 lists held 1.5 GB of upload memory, nearly all of
it unused. On an RTX 3060 Ti (8 GB, 16 GB RAM) upload buffers then failed
with E_OUTOFMEMORY and the device was removed a few minutes in.

A list's first chunk is now 256 KiB; requests that do not fit get 4 MiB
chunks after it, and a reset keeps only the first. Every 5 s the log also
reports video and system memory in use against Windows' budget and the
scratch bytes held by lists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:40:49 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:34 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/host.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1666#issuecomment-7149695199) <!-- victory-triage v1 head=a67255631622f04eed3d9a7d65b9422ceda66815 verdict=needs-rebase at=2026-11-25T01:34:01Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-gpu/src/host.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1666'
git switch 'github-bot/gh-1666'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1666'
git switch 'github-bot/gh-1666'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1666'
git switch 'main'
git merge --squash 'github-bot/gh-1666'
git switch 'main'
git merge --ff-only 'github-bot/gh-1666'
git switch 'main'
git merge 'github-bot/gh-1666'
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!1666
No description provided.