Pipelines: driver compiles are admitted by memory, and put off rather than refused #1625

Manually merged
github merged 1 commit from github-bot/gh-1625 into main 2026-11-29 08:21:58 +00:00 AGit
Owner

@⁠mizzied on GitHub · 2026-11-28 22:34 UTC · original
mizzied:up/compile-memory → main · +944 −19 · 7 files · 1 commits · merged 2026-11-29 08:16 UTC

What was wrong. A dozen driver pipeline compiles could run at once. Each can take hundreds of MB of commit, so on a PC with little commit left they exhausted memory and the process was killed. A compile the driver refused for memory was also recorded as refused for the whole run.

The fix.

  • A compile starts only while commit headroom allows it (VICTORY_COMMIT_FLOOR_MB).
  • Under low free physical memory (VICTORY_MEMORY_FLOOR_MB), compiles go one at a time.
  • A compile that would cross the floor is put off and retried a second later, not refused. Its draws are dropped until then.
  • This is merged with main's compute-pipeline wait: a dispatch doesn't wait on a put-off compile during the pause, so it's dropped like a draw until the retry.
  • VICTORY_COMPILE_MEMORY=0 turns it all off.

Overlap: open PR #1173 (throttle pipeline workers under commit pressure) aims at the same problem. This one admits each compile by measured memory and retries put-off compiles, rather than capping worker count. Happy to fold it into #1173 or close it, whichever you prefer.

How it was tested. RTX 5070, Windows 11. Tests cover admission at and around the floors, one-at-a-time under low memory, the put-off and retry, and recording a compile that panicked. 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.

**@⁠mizzied** on GitHub · 2026-11-28 22:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1625) `mizzied:up/compile-memory` → `main` · +944 −19 · 7 files · 1 commits · merged 2026-11-29 08:16 UTC **What was wrong.** A dozen driver pipeline compiles could run at once. Each can take hundreds of MB of commit, so on a PC with little commit left they exhausted memory and the process was killed. A compile the driver refused for memory was also recorded as refused for the whole run. **The fix.** - A compile starts only while commit headroom allows it (`VICTORY_COMMIT_FLOOR_MB`). - Under low free physical memory (`VICTORY_MEMORY_FLOOR_MB`), compiles go one at a time. - A compile that would cross the floor is put off and retried a second later, not refused. Its draws are dropped until then. - This is merged with `main`'s compute-pipeline wait: a dispatch doesn't wait on a put-off compile during the pause, so it's dropped like a draw until the retry. - `VICTORY_COMPILE_MEMORY=0` turns it all off. **Overlap:** open PR #1173 (throttle pipeline workers under commit pressure) aims at the same problem. This one admits each compile by measured memory and retries put-off compiles, rather than capping worker count. Happy to fold it into #1173 or close it, whichever you prefer. **How it was tested.** RTX 5070, Windows 11. Tests cover admission at and around the floors, one-at-a-time under low memory, the put-off and retry, and recording a compile that panicked. `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 driver's shader compiler runs inside our process and takes gigabytes
for a large program; with a dozen pipeline workers compiling together the
NVIDIA compiler once found no memory and ended the process (ptxas fatal:
Memory allocation failure). An allocation that fails in a driver library
cannot be caught, so a compile must not start unless the memory is there.

A compile now starts only while the commit the PC can still promise, less
the compiles running times a learned per-compile cost, stays over the commit
floor (VICTORY_COMMIT_FLOOR_MB, 4096, the hard limit). Under the soft floor
of free physical memory (VICTORY_MEMORY_FLOOR_MB, 1024) compiles go one at a
time, and so do they for half a second after an allocation failed
(residency::allocation_error). Pipeline workers wait for a running compile,
other threads about a second; then the compile is put off and the pipeline
made again a second later (Pending::defer, RETRY_AFTER_MS), never recorded
as refused. A dispatch whose compute pipeline was put off is not waited for
during the pause (it is dropped, like a draw). VICTORY_COMPILE_MEMORY=0 turns
the admission off.

Tests: the admission's verdicts for each floor, the learned cost, a compile
put off is not recorded as refused and is made again once the pause is over,
and a panicking build is recorded as a failure of its own.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 22:35:41 +00:00
github manually merged commit 35b0ff2c42 into main 2026-11-29 08:21:58 +00:00
Author
Owner

@⁠nick0451 on GitHub · 2026-11-29 10:05 UTC · original

Regression report: on a PC with little commit headroom at the moment, a fresh start of current main never reaches the world, and the admission added here is the cause.

Setup: RTX 3090 24 GB, i9-14900K, 32 GB RAM, Windows 11, a system-managed pagefile. Other programs left open held most of the commit: about 15 GB of a 73 GB commit limit free with the game not running. Series S, the same frozen save for every start, a new executable name and hash each time.

build fresh starts reach the world hr=0x8007000e host pipeline failures
main 568c5e5 yes (54 s) 0
main 829188e9 (default) no: stuck at the title for 5 min 3,070
main 829188e9, VICTORY_COMPILE_MEMORY=0 2 of 2 (76-78 s) 0
main 829188e9 + the change below 2 of 2 (58-64 s) 25-32 (early, then recovers)

Bisect: 4e109ff5 good, cb696070 bad. The waves in between don't build separately, so I confirmed it with the switch above.

What happens: about 3 s in, memory guard: a compile is put off … free_commit_mb=3991 reason="the commit l…. From then on every driver compile is put off and made again a second later, for good. The layer's private memory climbs from 4 to 18.6 GB while it stays at the title (compile memory: / process memory: lines).

Why: memguard::figures_now() takes free_commit from ullAvailPageFile, the limit of the moment. Everything else in the layer counts what is left to commit with residency::available_commit(), which adds what a system-managed pagefile can still grow by (VICTORY_COMMIT_GROWTH; its comment describes the same false pressure seen earlier on a 5070 Ti). The commit floor of 4096 MB is reached at once when other programs hold the commit, though Windows would grow the pagefile.

Change (2 lines, tested here, not opened as a PR yet; I can open it if wanted):

// memguard.rs, figures_now()
free_commit: crate::residency::available_commit(&m),   // was m.ullAvailPageFile
// residency.rs: `fn available_commit` → `pub(crate) fn available_commit`

With it, the admission stays on and still puts off a few compiles early (6-7 per start here), but the start goes through. The 23 memguard/compilemem/residency tests pass.

Until a fix is in: VICTORY_COMPILE_MEMORY=0 gets such a PC into the game.

🤖 Generated with Claude Code

**@⁠nick0451** on GitHub · 2026-11-29 10:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1625#issuecomment-7254204353) **Regression report:** on a PC with little commit headroom at the moment, a fresh start of current main never reaches the world, and the admission added here is the cause. **Setup:** RTX 3090 24 GB, i9-14900K, 32 GB RAM, Windows 11, a system-managed pagefile. Other programs left open held most of the commit: about **15 GB of a 73 GB commit limit free with the game not running**. Series S, the same frozen save for every start, a new executable name and hash each time. | build | fresh starts reach the world | `hr=0x8007000e` host pipeline failures | |---|---|---| | main `568c5e5` | yes (54 s) | 0 | | main `829188e9` (default) | **no**: stuck at the title for 5 min | **3,070** | | main `829188e9`, `VICTORY_COMPILE_MEMORY=0` | 2 of 2 (76-78 s) | 0 | | main `829188e9` + the change below | 2 of 2 (58-64 s) | 25-32 (early, then recovers) | Bisect: `4e109ff5` good, `cb696070` bad. The waves in between don't build separately, so I confirmed it with the switch above. **What happens:** about 3 s in, `memory guard: a compile is put off … free_commit_mb=3991 reason="the commit l…`. From then on every driver compile is put off and made again a second later, for good. The layer's private memory climbs from 4 to 18.6 GB while it stays at the title (`compile memory:` / `process memory:` lines). **Why:** `memguard::figures_now()` takes `free_commit` from `ullAvailPageFile`, the **limit of the moment**. Everything else in the layer counts what is left to commit with `residency::available_commit()`, which adds what a system-managed pagefile can still grow by (`VICTORY_COMMIT_GROWTH`; its comment describes the same false pressure seen earlier on a 5070 Ti). The commit floor of 4096 MB is reached at once when other programs hold the commit, though Windows would grow the pagefile. **Change** (2 lines, tested here, not opened as a PR yet; I can open it if wanted): ```rust // memguard.rs, figures_now() free_commit: crate::residency::available_commit(&m), // was m.ullAvailPageFile // residency.rs: `fn available_commit` → `pub(crate) fn available_commit` ``` With it, the admission stays on and still puts off a few compiles early (6-7 per start here), but the start goes through. The 23 memguard/compilemem/residency tests pass. Until a fix is in: `VICTORY_COMPILE_MEMORY=0` gets such a PC into the game. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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/trustno1-coder--VIctory-NVIDIA!1625
No description provided.