Scripts: stop shader precompile at a private commit budget #1746

Open
NemesisDawn wants to merge 1 commit from upstream-pr/1756 into main
NemesisDawn commented 2026-11-24 20:17:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by NemesisDawn on 2026-11-24T20:17:10Z.


Add an opt-in Windows wrapper for offline shader precompilation. It samples the XCL process’s private commit every 100 ms and stops it at a user-set threshold. Completed cache files stay available for the next run. Part of #1657.

What is in it

  • scripts/precompile-budget.ps1 launches and monitors XCL. The README shows how to use it, and scripts/precompile-budget.tests.ps1 exercises it with a native test process.

Tested

  • At f86b011, scripts/precompile-budget.tests.ps1 passed on Windows PowerShell 5.1 and PowerShell 7.6.9. A normal child preserved its arguments and exit code. A child allocating memory stopped with exit code 4 at a 74 MiB sample with a 48 MiB budget, leaving a completed fixture cache file intact.

Not tested

  • Retail shader pack, real XCL cache reuse, and the full Cargo workspace suite on a GPU.

AI use

  • OpenAI Codex (GPT-6, exact variant unavailable) wrote the patch and regression tests, ran the focused checks, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5479630415 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1756). Originally posted by [NemesisDawn](https://github.com/NemesisDawn) on 2026-11-24T20:17:10Z. --- Add an opt-in Windows wrapper for offline shader precompilation. It samples the XCL process’s private commit every 100 ms and stops it at a user-set threshold. Completed cache files stay available for the next run. Part of #1657. **What is in it** - `scripts/precompile-budget.ps1` launches and monitors XCL. The README shows how to use it, and `scripts/precompile-budget.tests.ps1` exercises it with a native test process. **Tested** - At `f86b011`, `scripts/precompile-budget.tests.ps1` passed on Windows PowerShell 5.1 and PowerShell 7.6.9. A normal child preserved its arguments and exit code. A child allocating memory stopped with exit code 4 at a 74 MiB sample with a 48 MiB budget, leaving a completed fixture cache file intact. **Not tested** - Retail shader pack, real XCL cache reuse, and the full Cargo workspace suite on a GPU. **AI use** - OpenAI Codex (GPT-6, exact variant unavailable) wrote the patch and regression tests, ran the focused checks, and drafted this description.
futurepro62 commented 2026-11-24 21:29:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T21:14:35Z.


Tested exact head f86b011, script tests only, since this PR has no test report yet.

Tested

  • Windows 11 Home 26300, Python 3.14.3 with pytest 9.0.3, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here).
  • powershell.exe -NoProfile -File scripts/precompile-budget.tests.ps1 at the head: exit 0, Both precompile budget checks passed. (it prints the stop message: XCL precompile stopped at 74 MiB private commit (limit 48 MiB)).
  • The PR's test file against current main's script (266b845): not applicable: precompile-budget.ps1 is new in this PR, so main has nothing for the test to run.

Not tested

  • PowerShell 7, the CI workflow itself, a game (no runtime code changed).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7144668741 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1756#issuecomment-7144668741). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T21:14:35Z. --- Tested exact head `f86b011`, script tests only, since this PR has no test report yet. **Tested** - Windows 11 Home 26300, Python 3.14.3 with pytest 9.0.3, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here). - `powershell.exe -NoProfile -File scripts/precompile-budget.tests.ps1` at the head: exit 0, `Both precompile budget checks passed.` (it prints the stop message: `XCL precompile stopped at 74 MiB private commit (limit 48 MiB)`). - The PR's test file against current main's script (`266b845`): not applicable: `precompile-budget.ps1` is new in this PR, so main has nothing for the test to run. **Not tested** - PowerShell 7, the CI workflow itself, a game (no runtime code changed). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
DavidM1911 commented 2026-11-24 23:08:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T23:04:41Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7146986264 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1756#issuecomment-7146986264). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T23:04:41Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
anes66 commented 2026-11-25 16:12:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by anes66 on 2026-11-25T15:18:00Z.


Independent Windows 10 CPU-only check of exact head f86b01177dee524b4382232efb3f220b6bbd2841: the checked-in synthetic wrapper tests passed in Windows PowerShell and PowerShell 7.

Tested

  • Windows 10 Pro 19045, Ryzen 7 9800X3D, Windows PowerShell 5.1.19041.7844 and PowerShell 7.6.9. The two scripts were extracted with git archive; both extracted file hashes match the Git blobs at this commit. The fixture was compiled with the installed .NET Framework C# compiler.
  • powershell.exe -NoProfile -ExecutionPolicy Bypass -File <scripts/precompile-budget.tests.ps1> and the equivalent pwsh.exe command: both exit 0 and print Both precompile budget checks passed.
  • Each shell checks the fast child's exact arguments (including quotes, a trailing backslash and an empty argument) and exit code 23, then a synthetic 64 MiB allocation with a 48 MiB sampling threshold. Both observed 74 MiB at termination, returned budget exit code 4, and preserved the completed fixture cache entry.
  • The initial Windows PowerShell attempt without the process-scoped execution-policy argument was blocked as an unsigned script; no test ran in that attempt. The passing commands above use a test-process-only exception. No persistent execution policy or other system setting changed.

Not tested
Real XCL, a shader pack, cache reuse by XCL, a title, GPU execution, Cargo suite, cancellation/error cleanup paths or a hard memory ceiling. The 74 MiB sample with a 48 MiB threshold confirms the documented sampling overshoot; it is not a hard commit cap.

<!-- greyfinch-sync:ivall/xcl:comment:7166622259 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1756#issuecomment-7166622259). Originally posted by [anes66](https://github.com/anes66) on 2026-11-25T15:18:00Z. --- Independent Windows 10 CPU-only check of exact head `f86b01177dee524b4382232efb3f220b6bbd2841`: the checked-in synthetic wrapper tests passed in Windows PowerShell and PowerShell 7. **Tested** - Windows 10 Pro 19045, Ryzen 7 9800X3D, Windows PowerShell 5.1.19041.7844 and PowerShell 7.6.9. The two scripts were extracted with `git archive`; both extracted file hashes match the Git blobs at this commit. The fixture was compiled with the installed .NET Framework C# compiler. - `powershell.exe -NoProfile -ExecutionPolicy Bypass -File <scripts/precompile-budget.tests.ps1>` and the equivalent `pwsh.exe` command: both exit 0 and print `Both precompile budget checks passed`. - Each shell checks the fast child's exact arguments (including quotes, a trailing backslash and an empty argument) and exit code 23, then a synthetic 64 MiB allocation with a 48 MiB sampling threshold. Both observed **74 MiB** at termination, returned budget exit code **4**, and preserved the completed fixture cache entry. - The initial Windows PowerShell attempt without the process-scoped execution-policy argument was blocked as an unsigned script; no test ran in that attempt. The passing commands above use a test-process-only exception. No persistent execution policy or other system setting changed. **Not tested** Real XCL, a shader pack, cache reuse by XCL, a title, GPU execution, Cargo suite, cancellation/error cleanup paths or a hard memory ceiling. The 74 MiB sample with a 48 MiB threshold confirms the documented sampling overshoot; it is not a hard commit cap.
RavenCurseBurg commented 2026-11-25 19:08:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T18:06:39Z.


Tested cancellation at f86b01177dee524b4382232efb3f220b6bbd2841 on Windows 11 (26100.9711), using the unmodified wrapper and a small synthetic .NET child. The child wrote a completed cache sentinel and its PID, then slept for up to 15 seconds. I verified the live process's executable path before stopping the calling PowerShell pipeline.

Shell Pipeline stop and observed child exit Completed sentinel
Windows PowerShell 5.1.26100.9711 58 ms Original contents
PowerShell 7.6.9 28 ms Original contents

Both runspaces reported Stopped. In both shells the normal short-lived fixture returned its exit code 23, and the missing-input and missing-executable cases returned path errors before launching the child. This checked ordinary pipeline cancellation below a 256 MiB threshold. No live XCL process, shader pack, GPU, retail game, forced host termination or memory-pressure run. OpenAI Codex (GPT-6) ran these checks and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7170452621 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1756#issuecomment-7170452621). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T18:06:39Z. --- Tested cancellation at `f86b01177dee524b4382232efb3f220b6bbd2841` on Windows 11 (26100.9711), using the unmodified wrapper and a small synthetic .NET child. The child wrote a completed cache sentinel and its PID, then slept for up to 15 seconds. I verified the live process's executable path before stopping the calling PowerShell pipeline. | Shell | Pipeline stop and observed child exit | Completed sentinel | | --- | --- | --- | | Windows PowerShell 5.1.26100.9711 | 58 ms | Original contents | | PowerShell 7.6.9 | 28 ms | Original contents | Both runspaces reported `Stopped`. In both shells the normal short-lived fixture returned its exit code 23, and the missing-input and missing-executable cases returned path errors before launching the child. This checked ordinary pipeline cancellation below a 256 MiB threshold. No live XCL process, shader pack, GPU, retail game, forced host termination or memory-pressure run. OpenAI Codex (GPT-6) ran these checks and wrote this report.
Foniass commented 2026-12-01 06:40:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:40:20Z.


Triage (#1607) – head f86b011

#1804 ("Part of #1657" too) works on the same memory problem inside shaders.rs (skips reloading cached PSO blobs); this PR wraps the precompile in an external watchdog instead. Different approaches, not a duplicate.
#1657 was closed on 2026-11-24 after the growth was traced to #1307 and fixed on main (#1321, #1748), so the README's motivation for this wrapper may no longer hold; worth confirming with a run on current main.
precompile-budget.tests.ps1 assigns to $input, which is a PowerShell automatic variable; a different name avoids surprises. The PR conflicts with main's README.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7303138944 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1756#issuecomment-7303138944). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:40:20Z. --- **Triage (#1607)** – head f86b011 #1804 ("Part of #1657" too) works on the same memory problem inside `shaders.rs` (skips reloading cached PSO blobs); this PR wraps the precompile in an external watchdog instead. Different approaches, not a duplicate. #1657 was closed on 2026-11-24 after the growth was traced to #1307 and fixed on main (#1321, #1748), so the README's motivation for this wrapper may no longer hold; worth confirming with a run on current main. `precompile-budget.tests.ps1` assigns to `$input`, which is a PowerShell automatic variable; a different name avoids surprises. The PR conflicts with main's README. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1756:upstream-pr/1756'
git switch 'upstream-pr/1756'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1756'
git switch 'upstream-pr/1756'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1756'
git switch 'upstream-pr/1756'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1756'
git switch 'main'
git merge --squash 'upstream-pr/1756'
git switch 'main'
git merge --ff-only 'upstream-pr/1756'
git switch 'main'
git merge 'upstream-pr/1756'
git push origin 'main'
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
xcl-dev/xcl!1746
No description provided.