d3d12: adapt large shader compile concurrency to available memory #236

Merged
Valdi320 merged 5 commits from upstream-pr/236 into main 2026-11-29 15:13:36 +00:00
Valdi320 commented 2026-11-26 14:52:57 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Valdi320 on 2026-11-26T14:52:57Z.


Review goal: Bound simultaneous large pipeline compilation under host memory pressure while preserving progress.

Scope: Existing adaptive gate plus the wake-all fix when capacity grows; fixed-budget behavior remains notify-one. Existing environment override remains available.

Evidence: Current head e5f8b58 on main 6ce0aac: Windows provider typecheck, Python suite 404 collected / 27 skipped, 10/10 native gate tests. Earlier negative control: old wake-one admitted 1/3 eligible workers; corrected gate admits 3/3. Previous six no-GPU groups and selected integrated GPU tests are historical; no new full GPU run or actual title RAM/time saving measured.

Review order: fifth, after diagnostics. Independent of other pending PRs. Treat as a candidate until real memory-pressure measurements and full GPU validation are available.

<!-- greyfinch-sync:brcly/TuxBox:issue:5512236491 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/236). Originally posted by [Valdi320](https://github.com/Valdi320) on 2026-11-26T14:52:57Z. --- **Review goal:** Bound simultaneous large pipeline compilation under host memory pressure while preserving progress. **Scope:** Existing adaptive gate plus the wake-all fix when capacity grows; fixed-budget behavior remains notify-one. Existing environment override remains available. **Evidence:** Current head e5f8b58 on main 6ce0aac: Windows provider typecheck, Python suite 404 collected / 27 skipped, 10/10 native gate tests. Earlier negative control: old wake-one admitted 1/3 eligible workers; corrected gate admits 3/3. Previous six no-GPU groups and selected integrated GPU tests are historical; no new full GPU run or actual title RAM/time saving measured. **Review order:** fifth, after diagnostics. Independent of other pending PRs. Treat as a candidate until real memory-pressure measurements and full GPU validation are available.
Valdi320 commented 2026-11-26 22:09:08 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Valdi320 on 2026-11-26T22:09:08Z.


Refresh #236 to 88aea59 on main e76ff6a. Fixed adaptive wakeup under expanding budget: a single released slot can admit several waiters, so the adaptive path now notifies all; fixed-capacity behavior stays notify-one. Regression red/green on the exact compile-gate module: previous code admitted 1/3 and failed, new code admitted 3/3, all 10 native tests pass. Six no-GPU groups (including Windows typecheck) pass. Integrated validation branch github.com/Valdi320/TuxBox@d3276e9c69 includes #236, #249, #257, #261, #272, #273 and #275. Rebuilt provider and Lanes fixture, 19/19 isolated D3D12 and 7/7 selected Lanes gates pass on RTX 4080/GE-Proton11-14; actual long-driver-compile memory savings not measured. The integration does not include DrArroway's #258, and does not establish AMD host-memory behavior. Initial isolated runner attempt with an uninitialized Wine prefix hid the NVIDIA adapter; initialized test prefix with NVAPI restored real PCI ID and all cases passed.

<!-- greyfinch-sync:brcly/TuxBox:comment:7204410795 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/236#issuecomment-7204410795). Originally posted by [Valdi320](https://github.com/Valdi320) on 2026-11-26T22:09:08Z. --- Refresh #236 to 88aea59 on main e76ff6a. Fixed adaptive wakeup under expanding budget: a single released slot can admit several waiters, so the adaptive path now notifies all; fixed-capacity behavior stays notify-one. Regression red/green on the exact compile-gate module: previous code admitted 1/3 and failed, new code admitted 3/3, all 10 native tests pass. Six no-GPU groups (including Windows typecheck) pass. Integrated validation branch https://github.com/Valdi320/TuxBox/tree/d3276e9c692ecafb46de53edb864c6e55cc0d3e3 includes #236, #249, #257, #261, #272, #273 and #275. Rebuilt provider and Lanes fixture, 19/19 isolated D3D12 and 7/7 selected Lanes gates pass on RTX 4080/GE-Proton11-14; actual long-driver-compile memory savings not measured. The integration does not include DrArroway's #258, and does not establish AMD host-memory behavior. Initial isolated runner attempt with an uninitialized Wine prefix hid the NVIDIA adapter; initialized test prefix with NVAPI restored real PCI ID and all cases passed.
NathansDomainSolutions commented 2026-11-28 09:51:02 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NathansDomainSolutions on 2026-11-28T09:51:02Z.


A real memory-pressure measurement for this, as the description asks: ProjectScarlett 1.0.2.1 to the title screen ("ACCOUNT PICKER / TUXBOX"), on a machine where it nearly runs out of memory.

Host: RTX 4070 12 GB, driver 620.73.04, Ryzen 7800X3D, 30 GB RAM, 4 GB zram, no disk swap, GE-Proton11-14. The desktop holds about 11 GB before launch, which leaves the title about 19 GB. A run on main was killed by the kernel OOM killer earlier tonight.

Runs: both launched with the shader preparation cache warm, and both with #378 staged (a texture-memory change unrelated to compiles). Memory was sampled every 15 s from /proc/<pid>/smaps. "Unix" is anonymous memory above 0x7f00… (driver, vkd3d-proton, winevulkan). "Win" is the title's own memory below that.

large-compile gate peak system used peak unix-side anon peak win-side anon mean system used
A: main + #378 + #380 fixed 4 30.8 GB 14.1 GB 6.6 GB 23.9 GB
B: main + #378 + this PR (88aea59) adaptive 30.1 GB 13.5 GB 7.6 GB 24.1 GB

The gate did adapt. B's "waits for one of N large compile slots" lines: N=4 71 times, N=3 16, N=2 90, N=1 20. A always had 4 (729 lines).

But the peak barely moved: 0.7 GB lower in total, and the unix side swung between about 4 and 13.5 GB either way. I read this as most of the transient driver memory not coming from the gated compiles:

  • At B's peak, at most 1–3 large compiles held a slot. The 59 large requests logged "still running" in that window were mostly queued for the gate, since the slot is held on the detached thread for the whole driver compile.
  • Translated programs under 512 KiB compile synchronously on the title's threads, one per thread and ungated. Several hundred KiB of DXIL each, several at a time.
  • Either the ungated compiles are what's large on NVIDIA, or a single large compile costs much more than the 2 GiB the policy budgets. These two runs can't tell the two apart.

Caveats: A's translator differed: it included #380, so its runtime HLSL cache was cold, while B's was mostly cold. The NVIDIA cache was warmer for B. Both runs end at the same screen. This is one run per arm.

Next I can measure a pinned TUXBOX_LARGE_COMPILES=1 run (the floor of what gating large compiles alone can do) and the per-compile peak of a single 750 KB translated compute pipeline on this driver, if that helps calibrate BYTES_PER_COMPILE.

(Measured with Claude Code assisting.)

<!-- greyfinch-sync:brcly/TuxBox:comment:7237507396 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/236#issuecomment-7237507396). Originally posted by [NathansDomainSolutions](https://github.com/NathansDomainSolutions) on 2026-11-28T09:51:02Z. --- A real memory-pressure measurement for this, as the description asks: ProjectScarlett 1.0.2.1 to the title screen ("ACCOUNT PICKER / TUXBOX"), on a machine where it nearly runs out of memory. **Host:** RTX 4070 12 GB, driver 620.73.04, Ryzen 7800X3D, **30 GB RAM, 4 GB zram, no disk swap**, GE-Proton11-14. The desktop holds about 11 GB before launch, which leaves the title about 19 GB. A run on `main` was killed by the kernel OOM killer earlier tonight. **Runs:** both launched with the shader preparation cache warm, and both with #378 staged (a texture-memory change unrelated to compiles). Memory was sampled every 15 s from `/proc/<pid>/smaps`. "Unix" is anonymous memory above `0x7f00…` (driver, vkd3d-proton, winevulkan). "Win" is the title's own memory below that. | | large-compile gate | peak system used | peak unix-side anon | peak win-side anon | mean system used | |---|---|---|---|---|---| | A: `main` + #378 + #380 | fixed 4 | 30.8 GB | 14.1 GB | 6.6 GB | 23.9 GB | | B: `main` + #378 + this PR (88aea59) | adaptive | 30.1 GB | 13.5 GB | 7.6 GB | 24.1 GB | **The gate did adapt.** B's "waits for one of N large compile slots" lines: N=4 71 times, N=3 16, N=2 90, N=1 20. A always had 4 (729 lines). **But the peak barely moved:** 0.7 GB lower in total, and the unix side swung between about 4 and 13.5 GB either way. I read this as most of the transient driver memory **not** coming from the gated compiles: - At B's peak, at most 1–3 large compiles held a slot. The 59 large requests logged "still running" in that window were mostly queued for the gate, since the slot is held on the detached thread for the whole driver compile. - Translated programs under 512 KiB compile synchronously on the title's threads, one per thread and ungated. Several hundred KiB of DXIL each, several at a time. - Either the ungated compiles are what's large on NVIDIA, or a single large compile costs much more than the 2 GiB the policy budgets. These two runs can't tell the two apart. **Caveats:** A's translator differed: it included #380, so its runtime HLSL cache was cold, while B's was mostly cold. The NVIDIA cache was warmer for B. Both runs end at the same screen. This is one run per arm. **Next I can measure** a pinned `TUXBOX_LARGE_COMPILES=1` run (the floor of what gating large compiles alone can do) and the per-compile peak of a single 750 KB translated compute pipeline on this driver, if that helps calibrate `BYTES_PER_COMPILE`. (Measured with Claude Code assisting.)
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
brcly/TuxBox!236
No description provided.