GPU: report retained snapshot, texture scratch and upload memory #602
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!602
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-602"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lucaseddd on GitHub · 2026-11-24 05:21 UTC · original
lucaseddd:gpu/retained-copy-memory-471→main· +55 −3 · 3 files · 1 commits · openWhen world loading approaches the system commit limit (#471), the process-wide number cannot show which retained GPU bridge allocations are growing. This adds a diagnostic line with three byte counters: idle shadow snapshots, live texture upload staging allocations, and retained CPU texture-read capacity.
The counters are independent of GPU vendor and VRAM size. Upload allocations are tracked once by allocation lifetime through weak references, so a diagnostic reference cannot keep an allocation alive. The sampler skips a busy sample and runs only with diagnostics enabled. The counters distinguish these components from overall private or system commit and do not change allocation policy.
Validated against main at
940d32f6on Windows 10 x64:cargo check --locked -p victory-gpu --features diagnosticscargo check --locked -p victory-gpucargo xtask policy(182 files)An earlier offline diagnostics run on an RTX 3060 Laptop collected 59 samples during loading. The last sample reported 53.5 MiB in texture uploads, 8 KiB of CPU read capacity, zero idle snapshots and about 11.9 GiB of process private memory. That run ended before a world frame, so it does not establish the cause of #471.
@geiyiliyabumo on GitHub · 2026-11-24 10:56 UTC · original
Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver
32.0.32029.2010, Rust1.98.1), cleanly merged ontomain(ffe310e):cargo xtask policy: PASS (154 files ok)cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: PASScargo clippy -p victory-gpu --all-targets --features diagnostics --locked -- -D warnings: PASScargo test -p victory-gpu --locked: 50 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --features diagnostics --locked: 53 passed, 0 failed, 1 ignoredDiff review (
copystat.rs,shadow.rs,texture.rs): clean, minimal, and properly gated behind#[cfg(feature = diagnostics)]. Usingtry_lock()onPOOL,STAGING, and eachstaging.lastavoids blocking render/upload work and eliminates any lock-order deadlock risk when sampling retained memory.AI-assisted; synthetic tests only, no game files.
@lucaseddd on GitHub · 2026-11-24 11:15 UTC · original
Thanks both for verifying this on NVIDIA and AMD. The #472 interaction is useful to have recorded. #472 is still open, so the diagnostics remain based on the current layout. If #472 lands first, the texture-read sample will need to read the single SCRATCH capacity while retaining the non-blocking sample behavior.
@lucaseddd on GitHub · 2026-11-24 12:33 UTC · original
Could a maintainer merge this into main if the diagnostics meet the request in #471? The counters are ready on current main. If #472 is scheduled to land first, please let me know here so I can adapt the texture-read counter to the shared scratch buffer.
@lucaseddd on GitHub · 2026-11-24 20:32 UTC · original
Thanks @DenRakEiw for testing the diagnostics configuration and running Clippy and the policy check. The #471 follow-up also confirms the counters can be sampled alongside #484.
@Capi360 on GitHub · 2026-11-24 21:29 UTC · original
Additional Windows startup measurement with the retained-copy counters.
This corroborates the earlier loading-screen result on a 3060: the measured retained copy buffers explain only a small portion of the startup memory use. These samples do not cover the world or resources outside the counters. The diagnostics build, three watch tests, and asset policy check passed. AI-assisted.
@lucaseddd on GitHub · 2026-11-24 21:52 UTC · original
Updated the branch to main at
70564ae(head380dab26). Texture uploads now belong to individual host textures, so the sampler tracks each staging allocation once through a weak reference. It counts allocations that remain live through an in-flight owner and skips busy samples without waiting. The upstream watch-lock and snapshot-rate lines remain present. Windows checks with and without diagnostics passed, and cargo xtask policy passed for 174 files.@aycow on GitHub · 2026-11-24 22:40 UTC · original · edited 2026-11-24 22:52 UTC
@Capi360 I reviewed your shared-read scratch measurement at
8d67d8eand the original implementation in39eba9d. An isolated current-main version on70564aepassed the tracked refresh and live alias shader controls on AMD and WARP. Across six generated 512² and two 1024² textures, the retained CPU input capacity was 14 MiB with per-texture storage and 4 MiB with a shared buffer. The GPU-visible uploads retained their independent contents. I’m keeping the branch local while we choose the contribution route. Would you prefer to carry the current-main scratch port separately from your retained-copy counters, or have me send the isolated patch for your review?For the GPU-HOST-MEMORY and FIND-2 claims, a matched current-main loading and world capture would help identify what still consumes memory and whether fallback hashing is material. If your authorized setup can collect it, please share aggregate process private bytes, system commit/headroom, adapter budget/usage, snapshot and texture capacity, and the existing texture refresh totals for watched, hashed and changed bytes by the same frame window. Aggregate measurements are sufficient. The old startup measurement is useful provenance.
AI-assisted using Codex.
The attribution composition also exposed an exact-view accounting error. A 456-byte view backed by a native buffer of width 512 was charged as 65,536 bytes. The current diagnostics package charges 512 and includes live exact-view overlap until its owner releases it. AMD and WARP reproduced the expected capacity and lifetime after correction. The package preserves #602's allocation-lifetime counters and #484's process counters. Resource width remains a separate quantity from driver allocation and residency.
@aycow on GitHub · 2026-11-24 23:11 UTC · original
@Capi360 The validated patch is available as shared texture read scratch on your #602 head. This combines exact
380dab2with the isolated scratch change and retains your nonblocking upload attribution. It credits your earlier implementation and the #1076 scratch work. AMD and WARP passed tracked refresh, decommit zero-fill, and the placed-alias shader test. Six 512² and two 1024² inputs required 4 MiB of shared CPU scratch instead of 14 MiB of per-texture capacity. The GPU uploads remained independent.@Calvix2k If you can collect a matched run on the same authorized Windows 10 Series X and Agility/#1798 setup as your #175 report, the two revisions are attribution-only
1eab79cand attribution with shared scratchdac1953. Use the same cache, title profile, and recorded system commit headroom. WithVICTORY_MEMORY_STATS=1, please share aggregate process private bytes, system commit and limit, DXGI budget and use, and shadow, snapshot, staging and scratch capacity over the same pre-failure window around frame 128. We can compare a world window if both runs reach it. No files or dumps are needed. Prior reportAI-assisted using Codex.
@Calvix2k on GitHub · 2026-11-24 23:56 UTC · original
@aycow Matched run, revision A = 1eab79c + Agility #175 + #1798 (diag build, VICTORY_MEMORY_STATS=1). Same authorized setup as the #175 report: Windows 10 22H2 19045, Ryzen 7 5800X, RX 7800 XT (driver 32.0.32029.2010), 32 GB, D3D12Core 1.620.2, same cache/data dirs, title 99f876b…. Bytes are decimal.
Series X (--console series-x), pre-failure window — the run ends with Windows commit limit reached while committing 65536 bytes at frame ~130, title breakpoint +0x2474680:
Snapshot, list scratch and list upload were 0 in every sample; idle_snapshot_bytes 0. At the failure the system had ~1.8 GB of commit left, and Victory's own retained pools (shadow 0.63 GB, native textures 1.52 GB capacity / 0.14 GB used, staging ~4 KB) are small next to the process's 10.35 GB private. So the Series X failure here is the OS commit limit (C: pagefile cannot grow: 5.4 GB free), not one of the tracked pools.
Series S, same revision, 20 samples over 57 s (last sample, frame 1655):
private 10,385,784,832; working set 5,490,969,664; commit 43,484,344,320 / 46,939,488,256; GPU local 3,272,552,448 / 16,156,999,680; GPU non-local 2,663,211,008; shadow 1,266,756,864 peak; cached shadows 4,102 (1,064,812,494 guest / 913,442,886 unique); native textures 1,522,597,888 capacity (last line not sampled, texture count moves); texture upload 43,628,192; texture read 43,421,696; snapshots/scratch/upload 0.
Revision B = dac1953 is building now; I will post the same two windows for it next. No files or dumps.
@Calvix2k on GitHub · 2026-11-24 23:59 UTC · original
@aycow Matched run, revision B = dac1953 (attribution + shared scratch) + Agility #175 + #1798. Same machine, cache, data dirs, title and diagnostic profile as the revision A table above. Bytes are decimal.
Series X (--console series-x) — same end: XMem … mapping physical pages failed … os error 1455 at frame ~142, then the title breakpoint +0x2474680:
*frame-0 line is the same startup sample in both revisions; I marked it with the A values because the run prints identical numbers there.
Snapshot, list scratch and list upload were 0 in every sample. As with A, the tracked pools are small at the failure (shadow 0.72 GB, native 1.52 GB capacity / 0.14 GB used) and the last 64 KiB fails against the OS commit limit.
Series S, revision B, 20 samples over 57 s (last sample, frame 1660):
private 10,194,096,128; working set 4,983,078,912; commit 42,840,850,432 / 46,809,739,264; GPU local 3,221,667,840 / 16,156,999,680; GPU non-local 2,593,333,248; shadow 1,240,577,280 peak; cached shadows 4,068 (1,039,297,790 guest / 896,878,266 unique); native textures 1,522,597,888 capacity / 144,637,952 used; texture upload 4; texture read 4,096; snapshots/scratch/upload 0.
The one visible A→B difference in this boot window is the texture read/upload attribution: revision A's Series S sample showed texture upload 43,628,192 and texture read 43,421,696, while B shows 4 and 4,096 with the same frame count and window length. If that matches your expectation for shared scratch, the matched pair is here; if not, I can repeat both with a fixed frame window (VICTORY_CAPTURE_FRAMES-style stop at frame 1600) to remove the timing difference.
@Marvisak on GitHub · 2026-11-25 01:23 UTC · original · edited 2026-11-25 16:49 UTC
Automated triage for the maintainers.
Merge candidate.
This adds a diagnostics-only
retained copy memoryline tocopystat::log. It reports three numbers: idle shadow snapshot capacity (shadow::idle_snapshot_bytes, fromPOOL), texture upload chunks plus large upload buffers (texture::cached_staging_bytes, fromCHUNKSandBUFFERS), and idle per-thread read scratch.copystatis already gated ondiagnostics, and so is every new counter. The sampler usestry_lockand skips a busy sample rather than blocking.RETAINED_SCRATCHstays balanced: it is added when a buffer is put back inScratch::drop, and subtracted ontake, on replacement and on thread exit (Drop for ScratchCache). Allocation behaviour does not change.One note: the PR description still mentions tracking uploads through weak references. This head no longer does that, so please update the description.
CI (
check) passes on this head.Generated by Claude Code
@aycow on GitHub · 2026-11-25 01:29 UTC · original
@lucaseddd I updated the existing #602 scratch handoff to
ccfb029while retaining your changes. Both strict GPU Clippy configurations, policy and 144 active diagnostics tests passed. The separate attribution build passed the focused synthetic checks on AMD, NVIDIA and WARP with full GPU-based validation. The 8-texture fixture retained 4 MiB of CPU detile scratch versus 14 MiB before sharing and kept its GPU uploads independent. Could you use this scratch change in #602, or would #472 be the better place for it?@Calvix2k Thanks for the previous matched title runs. The Series S GPU upload gauge moved along with CPU scratch, so that sample cannot isolate the private-commit effect. If you have an authorized test slot, could you compare the current-main counter baseline and shared-scratch build? Use a diagnostics build with
VICTORY_MEMORY_STATS=1, the same adapter, title mode and cache state, and matching elapsed-time windows or frame tokens. Aggregate process private commit, system commit and limit, CPU texture-read capacity, GPU texture-upload capacity, and any failure time/code are sufficient. Measurement steps@lucaseddd on GitHub · 2026-11-25 01:35 UTC · original
I'd keep shared detile scratch in #472. #602 can stay focused on counting what the bridge retains, including live GPU uploads. Keeping the allocation change separate also lets us compare private and system commit at matched frame tokens without treating a change in GPU upload retention as a CPU scratch savings. The synthetic result gives #472 a concrete regression target: shared CPU scratch with independent GPU uploads.
@Calvix2k on GitHub · 2026-11-25 01:49 UTC · original
@aycow Matched A/B on current main
4118f33(plus only the Agility opt-in so Windows 10 draws), diagnostics build, VICTORY_MEMORY_STATS=1, --console series-s, same cache/data, title 99f876b…, adapter RX 7800 XT. Both runs: 20 samples, 0–57 s, 1644 / 1645 frames — the windows match. Bytes are decimal.Shadow, snapshots, scratch and the texture gauges are identical at every matched sample: shadow 1,238,711,808 peak, snapshot 0, list scratch/upload 0, texture upload 4 B, texture read 4,096 B, cached shadows 4,329 (1,037,401,102 guest / 893,261,254 unique).
So in this window shared scratch shows no private-commit benefit (B is ~0.2–0.3 GB higher late, within run-to-run noise). The caveat is the window itself: on main with --console series-s this machine never submits world draws (the black-UI issue #1854), so texture reads never start and the scratch pool is not exercised; the gauges stay at their boot values. A window with active texture reads — or your synthetic fixture — is the fair place to see the 14 MiB → 4 MiB capacity change. If you want, I can rerun the pair with --console series-x and stop both at the same frame, but that profile dies at the commit limit around frame 130 here, before the world either.
@lucaseddd on GitHub · 2026-11-25 16:17 UTC · original
Rebased onto
67e8ae1and pushed663dc83. GitHub now reports the PR as mergeable.The rebase accounts for the current ownership of texture memory: upload chunks are counted once, the separate pool includes its free and in-use buffers, and idle per-thread read capacity is removed when the buffer is taken or its thread exits. The upstream ordering of host writes is preserved.
Both strict workspace Clippy configurations and the repository policy check passed. On this Windows host, the three reproducible GPU test failures and the shader test failures were also present on the unmodified base. The two additional timing-sensitive tests seen in the parallel workspace run passed when rerun individually on both the base and this PR. The hosted Windows CI is running on the new head.
@fuzeofficlal on GitHub · 2026-11-26 01:27 UTC · original
Code review and RTX 5090 + WARP verification at head
663dc8371f15merged cleanly ontomain(63bcca43c6a0):shadow.rs:899-903,texture.rs:725-733, 917-924):idle_snapshot_bytes,cached_staging_bytes,RETAINED_SCRATCH, andDrop for ScratchCachestay strictly under#[cfg(feature = "diagnostics")](default builds retain only zero-overheadScratchCache(Cell<Vec<u8>>)).Scratch::take(fetch_sub),Scratch::drop(fetch_add->replace->fetch_sub), and thread-exitScratchCache::drop(fetch_sub) balances exactly without underflow, andtry_lock().ok()?ensures diagnostic logging never blocks active uploads/copy-backs.VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy -p victory-gpu --all-targets -- -D warnings(default +--features diagnostics): 0 warningscopystat:: shadow:: texture::: 12/12 passed on both RTX 5090 and WARP (--features diagnostics).LGTM.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.