Skip to content

GPU: a small allocation failure no longer ends the title - #1624

Open
mizzied wants to merge 1 commit into
trustno1-coder:mainfrom
mizzied:up/fetch-stepdown
Open

mizzied wants to merge 1 commit into
trustno1-coder:mainfrom
mizzied:up/fetch-stepdown

Conversation

@mizzied

@mizzied mizzied commented Nov 28, 2026

Copy link
Copy Markdown

What was wrong. A failed 16 MiB allocation for a fetch buffer ended the title, even when the PC was only briefly short of memory.

The fix.

  • The relay and card-back fetch buffers step down to a smaller size and retry once. If that fails too, the fetch is skipped and NO MEMORY TO FETCH is logged, and the title goes on.
  • A read-back buffer is retried once.
  • VICTORY_FETCH_STEPDOWN=0 restores the old behaviour.

Related open PRs #1472 (retry texture staging smaller) and #625 cover nearby allocations, but not the fetch buffers.

How it was tested. RTX 5070, Windows 11. There are five tests in fetchmem.rs covering the step-down sizes, the single retry, the skip and the switch. cargo test --workspace passes apart from repository_passes_policy, which already fails on main: lower.rs is over the 640 KiB file-size limit there (#1493 raises it). Clippy reports only the 16 findings already on main, none on lines this PR changes. The victory-gpu watch:: tests are flaky on this machine in files this PR does not touch, and pass on a rerun.

The relay's fetch buffer and the card-back fetch buffer were made 16 MiB at
a time, and where the system refused that the layer ended the run through
host::fail ("no memory to fetch what shaders wrote to the card's memory"),
though the PC had room for the few megabytes a fetch needs.

Both now step down (16 MiB rounded, 1 MiB, the least the bytes allow; not
the first while host memory pressure is on), try the least once more after a
moment, and if none can be made the fetch is skipped, counted and logged
loudly (NO MEMORY TO FETCH): the pieces stay as they were in title memory
until a later fetch of them. A read-back buffer is retried once the same
way. VICTORY_FETCH_STEPDOWN=0 restores the single 16 MiB try and the fatal
failure.

Tests (fetchmem.rs): the step-down sizes, the pressure case, the retry of
the least, and the count of skipped fetches.
@github-actions github-actions Bot added crash The game closes, freezes or stops with an error memory RAM or VRAM use, out of memory, leaks NVIDIA pr-fix Pull request: fixes a bug labels Nov 28, 2026
@github-actions github-actions Bot changed the title [pr-fix][memory][crash][NVIDIA] GPU: a small allocation failure no longer ends the title GPU: a small allocation failure no longer ends the title Nov 28, 2026
@babuakhil

Copy link
Copy Markdown

Second machine for this: Windows 11, RTX 3060, Ryzen 7 5700X, Rust 1.98.1 (pinned), applied on current main (d4b5d51); cherry-picks cleanly.

  • clippy on victory-gpu, with and without --all-features: the same 2 errors as main, none in fetchmem.rs or the changed parts of host.rs
  • the five fetchmem tests pass; cargo test -p victory-gpu --lib --locked: 555 passed in 2 of 3 runs, and the third had one failure in watch::tests::what_is_put_in_beside_the_guards_is_told_at_every_view, a watch test that fails now and then on main too; with --all-features, 609 passed

Reading the paths, since an allocation failure can't be forced on a real card from a test:

  • The step-down can work: shared_buffer returns None with a warning when creation fails rather than ending the run, so fetchmem::buffer gets each size in turn.
  • The relay skip ends the same way as the existing pieces.is_empty() path (relay_fetched(after), then return), and RELAY_FETCHED is only read by card_dirty to drop ordering notes, so the bookkeeping stays as it is when there is nothing to fetch.
  • What a skip costs is as the log line says: those pieces' card bytes are not merged, and title memory keeps its old bytes until a later flight flags the same pieces. If none does, they stay stale. That's a reasonable trade for not ending the run, and the counts (stale_bytes_so_far) make it visible; worth keeping in mind when a report shows NO MEMORY TO FETCH.

Not checked: a run that actually hits the failure (the unit tests drive fetchmem::buffer with a fake make), and the comment that the old buffer's last fetch has been waited for before it is let go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crash The game closes, freezes or stops with an error memory RAM or VRAM use, out of memory, leaks NVIDIA pr-fix Pull request: fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants