run_game_wine.sh: keep the drivers' shader cache from run to run (WINE-RUN-SHADER-CACHE) #2436

Merged
kawaii-shakal merged 5 commits from upstream-pr/2436 into main 2026-12-01 11:30:41 +00:00
kawaii-shakal commented 2026-11-27 06:49:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-27T06:49:11Z.


Claimed in the coordination issue as: WINE-RUN-SHADER-CACHE (finding by z3r0rc in #1608, its shader-cache part)

What and why

scripts/run_game_wine.sh exported XDG_CACHE_HOME=$RUN/session/cache, a new folder in each run folder. NVIDIA's
GLCache and Mesa's shader cache live under XDG_CACHE_HOME, so every launch started with an empty driver cache and
compiled its pipelines again.

  • The caller's XDG_CACHE_HOME is used when it is set; --cache DIR names a folder instead. Both are kept from run
    to run.
  • --cache fresh, or neither of the two, gives the old behaviour: a new folder in the run folder, for a cold-cache
    measurement.
  • The first line of the printed summary says which (shader cache: kept in DIR or shader cache: fresh).
  • --help and docs/linux_proton.md describe it.

Not in this PR: the compile-gate defaults from the same finding (LEONIDA_COMPILE_HELPER, LEONIDA_ASYNC_PIPELINES),
which need a retail run to judge.

Tested

  • tests/test_run_game_wine.py, three new cases against the script's stubs: a fresh cache by default; the caller's
    cache kept across two runs (the stub wine appends to nvidia/GLCache, and the second run finds the first's
    line); --cache DIR and --cache fresh over a caller's XDG_CACHE_HOME.
  • Ubuntu 24.04 container, bash 5.2, Python 3.12. No Wine, GPU or game.

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption.
  • A new translator rule is in the contract table of docs/design.md. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5522496778 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2436). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-27T06:49:11Z. --- Claimed in the coordination issue as: WINE-RUN-SHADER-CACHE (finding by z3r0rc in #1608, its shader-cache part) ### What and why `scripts/run_game_wine.sh` exported `XDG_CACHE_HOME=$RUN/session/cache`, a new folder in each run folder. NVIDIA's `GLCache` and Mesa's shader cache live under `XDG_CACHE_HOME`, so every launch started with an empty driver cache and compiled its pipelines again. - The caller's `XDG_CACHE_HOME` is used when it is set; `--cache DIR` names a folder instead. Both are kept from run to run. - `--cache fresh`, or neither of the two, gives the old behaviour: a new folder in the run folder, for a cold-cache measurement. - The first line of the printed summary says which (`shader cache: kept in DIR` or `shader cache: fresh`). - `--help` and `docs/linux_proton.md` describe it. Not in this PR: the compile-gate defaults from the same finding (`LEONIDA_COMPILE_HELPER`, `LEONIDA_ASYNC_PIPELINES`), which need a retail run to judge. ### Tested - `tests/test_run_game_wine.py`, three new cases against the script's stubs: a fresh cache by default; the caller's cache kept across two runs (the stub `wine` appends to `nvidia/GLCache`, and the second run finds the first's line); `--cache DIR` and `--cache fresh` over a caller's `XDG_CACHE_HOME`. - Ubuntu 24.04 container, bash 5.2, Python 3.12. No Wine, GPU or game. AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption. - [ ] A new translator rule is in the contract table of `docs/design.md`. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kirigayakazima commented 2026-11-28 03:27:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-28T03:27:49Z.


#2436 | head 6fe01249f6 | python -I tests/test_run_game_wine.py | red: ModuleNotFoundError: No module named 'fcntl' (PR branch predates main's Windows skip guard) | green: OK (skipped=12 on Windows 11 after merging main's Linux-only guard) | full suite: same as main (514/521 standalone stdlib tests passed, 0 new failures vs main 02f71ccfe7; compileall=0; node viewer_streaming=0) | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini)

  • Clean merge onto main 02f71ccfe7; scripts/check_no_game_data.py passed (0).
  • Note: tests/test_run_game_wine.py is Linux-only (fcntl / bash / Wine stub), so all 12 tests skip on Windows once main is merged. A Linux runner still needs to verify the live Red -> Green XDG_CACHE_HOME assertions for VERIFY-2436.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7233091648 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7233091648). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-28T03:27:49Z. --- #2436 | head 6fe01249f668cbc5b5b659d5fc91e87c754f81f7 | python -I tests/test_run_game_wine.py | red: ModuleNotFoundError: No module named 'fcntl' (PR branch predates main's Windows skip guard) | green: OK (skipped=12 on Windows 11 after merging main's Linux-only guard) | full suite: same as main (514/521 standalone stdlib tests passed, 0 new failures vs main 02f71ccfe7; compileall=0; node viewer_streaming=0) | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini) - Clean merge onto `main` `02f71ccfe7`; `scripts/check_no_game_data.py` passed (`0`). - Note: `tests/test_run_game_wine.py` is Linux-only (`fcntl` / `bash` / Wine stub), so all 12 tests skip on Windows once `main` is merged. A Linux runner still needs to verify the live Red -> Green `XDG_CACHE_HOME` assertions for `VERIFY-2436`.
merzleckeier commented 2026-11-28 20:46:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-28T20:46:29Z.


Linux verification for VERIFY-2436 on CachyOS (kernel 7.3.6-3, Bash 5.3.20, Python 3.14.10). Head e73386f5 merged cleanly into main at 1bc055e6.

I ran the same current python -I tests/test_run_game_wine.py -v fixture before and after, changing only which runner it called. On bare main with the PR fixture, 9 passed and the 3 new cases failed as expected. The old runner ignores the caller's cache, rejects --cache and uses the expected fresh directory without the new status line. With the PR, 12/12 passed with no skips. That covers the default fresh cache, the caller's cache surviving two stub launches, and both forms of the explicit override (directory or fresh).

The cases ran offline with Wine stubs. No game files or GPU work were needed. AI-assisted with Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7245529539 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7245529539). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-11-28T20:46:29Z. --- Linux verification for `VERIFY-2436` on CachyOS (kernel 7.3.6-3, Bash 5.3.20, Python 3.14.10). Head `e73386f5` merged cleanly into `main` at `1bc055e6`. I ran the same current `python -I tests/test_run_game_wine.py -v` fixture before and after, changing only which runner it called. On bare `main` with the PR fixture, 9 passed and the 3 new cases failed as expected. The old runner ignores the caller's cache, rejects `--cache` and uses the expected fresh directory without the new status line. With the PR, 12/12 passed with no skips. That covers the default fresh cache, the caller's cache surviving two stub launches, and both forms of the explicit override (directory or `fresh`). The cases ran offline with Wine stubs. No game files or GPU work were needed. AI-assisted with Codex.
TheGeogeo commented 2026-11-28 23:38:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T23:38:01Z.


Tested e73386f5b merged (no commit) with main aa918e5d9: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Not testable here: tests/test_run_game_wine.py skips all of its 12 tests on Windows (it needs bash and Wine). Green and red can't be observed on this machine, so this is diff reading only.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247560787 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7247560787). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T23:38:01Z. --- Tested `e73386f5b` merged (no commit) with `main` `aa918e5d9`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Not testable here: `tests/test_run_game_wine.py` skips all of its 12 tests on Windows (it needs `bash` and Wine). Green and red can't be observed on this machine, so this is diff reading only. AI-assisted (Claude Code).
zmasi commented 2026-11-29 01:40:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:40:20Z.


Independent verification on Windows 11 (10.0.26200, x64, Git Bash + Python 3.12.10 & Python 3.14.5) with e73386f5bc merged onto origin/main (0efc2bd43d, 0 merge conflicts):

  • Git Bash CLI Red -> Green (scripts/run_game_wine.sh):
    • Red (origin/main): bash scripts/run_game_wine.sh --cache fresh exits 2 (run_game_wine.sh: unknown argument: --cache (see --help)).
    • Green (e73386f5bc merged onto origin/main): bash -n scripts/run_game_wine.sh exits 0, bash scripts/run_game_wine.sh --help exits 0 and documents --cache DIR|fresh, and bash scripts/run_game_wine.sh --cache "" exits 2 (run_game_wine.sh: --cache needs a value (see --help)).
  • Python & documentation gates:
    • python -I -B tests/test_run_game_wine.py: Ran 12 tests, OK (skipped=12) on Windows under both Python 3.12.10 and Python 3.14.5 (matching the Linux-only guard).
    • python -I tests/test_docs_table_rows.py (2/2), python -I tests/test_docs_repeated_lines.py (3/3), python -I tests/test_ci_registration.py (18/18), and python -I tests/test_text_write_line_endings.py (3/3) all exited 0; test_docs_cli_flags.py and test_docs_links.py add 0 issues on docs/linux_proton.md or scripts/run_game_wine.sh.
  • Hygiene: git diff --check and python -I scripts/check_no_game_data.py across all 3 touched files exited 0.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248938209 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7248938209). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T01:40:20Z. --- Independent verification on Windows 11 (`10.0.26200`, x64, Git Bash + `Python 3.12.10` & `Python 3.14.5`) with `e73386f5bc` merged onto `origin/main` (`0efc2bd43d`, `0` merge conflicts): - **Git Bash CLI Red -> Green (`scripts/run_game_wine.sh`)**: - Red (`origin/main`): `bash scripts/run_game_wine.sh --cache fresh` exits `2` (`run_game_wine.sh: unknown argument: --cache (see --help)`). - Green (`e73386f5bc` merged onto `origin/main`): `bash -n scripts/run_game_wine.sh` exits `0`, `bash scripts/run_game_wine.sh --help` exits `0` and documents `--cache DIR|fresh`, and `bash scripts/run_game_wine.sh --cache ""` exits `2` (`run_game_wine.sh: --cache needs a value (see --help)`). - **Python & documentation gates**: - `python -I -B tests/test_run_game_wine.py`: `Ran 12 tests`, `OK (skipped=12)` on Windows under both `Python 3.12.10` and `Python 3.14.5` (matching the Linux-only guard). - `python -I tests/test_docs_table_rows.py` (`2/2`), `python -I tests/test_docs_repeated_lines.py` (`3/3`), `python -I tests/test_ci_registration.py` (`18/18`), and `python -I tests/test_text_write_line_endings.py` (`3/3`) all exited `0`; `test_docs_cli_flags.py` and `test_docs_links.py` add `0` issues on `docs/linux_proton.md` or `scripts/run_game_wine.sh`. - **Hygiene**: `git diff --check` and `python -I scripts/check_no_game_data.py` across all 3 touched files exited `0`. AI-assisted.
timbot103 commented 2026-11-29 04:27:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:27:45Z.

Review: COMMENTED


Reviewed head e73386f5b against the base by static inspection only. No builds, tests, or GPU runs.

  • Major · docs/linux_proton.md:104 and scripts/run_game_wine.sh:217. A warm MESA_SHADER_CACHE_DIR or __GL_SHADER_DISK_CACHE_PATH still reaches Wine under --cache fresh. The launcher prints “fresh” even though the driver can reuse that explicit cache during a cold-cache comparison. Please document that the flag selects the XDG cache root, name the driver overrides callers should unset for cold measurements, and add a stub assertion for their precedence.
  • Minor · scripts/run_game_wine.sh:217 and scripts/run_game_wine.sh:221. Fresh mode can reuse cache entries already present in an accepted output directory. Retrying a failed display startup with a different cache choice also appends a second, potentially contradictory status. Please reserve an unused directory for fresh mode or reject a pre-existing one, and write the session header anew on each launch.
  • Minor · tests/test_run_game_wine_safety.py:194. This fixture inherits XDG_CACHE_HOME. If it names a regular file, the new directory creation aborts the launcher before the fixture can verify summary exit propagation. Please add --cache fresh to the shared fixture arguments.

The new cache parsing guards unset values under set -u, and the directory operations quote paths with spaces. The shared base already uses Bash 4 case conversion for device selection. --cache takes precedence over the caller's XDG setting. The launcher passes through separate Mesa, NVIDIA, AMD, DXVK, and VKD3D cache environment variables, and the new Wine stub exercises the XDG selection.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6101397674 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2436#pullrequestreview-6101397674). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-29T04:27:45Z. **Review:** COMMENTED --- Reviewed head `e73386f5b` against the base by static inspection only. No builds, tests, or GPU runs. - **Major** · `docs/linux_proton.md:104` and `scripts/run_game_wine.sh:217`. A warm `MESA_SHADER_CACHE_DIR` or `__GL_SHADER_DISK_CACHE_PATH` still reaches Wine under `--cache fresh`. The launcher prints “fresh” even though the driver can reuse that explicit cache during a cold-cache comparison. Please document that the flag selects the XDG cache root, name the driver overrides callers should unset for cold measurements, and add a stub assertion for their precedence. - **Minor** · `scripts/run_game_wine.sh:217` and `scripts/run_game_wine.sh:221`. Fresh mode can reuse cache entries already present in an accepted output directory. Retrying a failed display startup with a different cache choice also appends a second, potentially contradictory status. Please reserve an unused directory for fresh mode or reject a pre-existing one, and write the session header anew on each launch. - **Minor** · `tests/test_run_game_wine_safety.py:194`. This fixture inherits `XDG_CACHE_HOME`. If it names a regular file, the new directory creation aborts the launcher before the fixture can verify summary exit propagation. Please add `--cache fresh` to the shared fixture arguments. The new cache parsing guards unset values under `set -u`, and the directory operations quote paths with spaces. The shared base already uses Bash 4 case conversion for device selection. `--cache` takes precedence over the caller's XDG setting. The launcher passes through separate Mesa, NVIDIA, AMD, DXVK, and VKD3D cache environment variables, and the new Wine stub exercises the XDG selection. AI-assisted.
kawaii-shakal commented 2026-11-30 08:16:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-30T08:16:13Z.


Thanks, all three addressed in 206bb4b6:

  • Major: --cache fresh now unsets MESA_SHADER_CACHE_DIR, MESA_GLSL_CACHE_DIR and __GL_SHADER_DISK_CACHE_PATH, so a fresh run is cold whatever the caller had set; with a kept cache the caller's variables stay and win over the XDG root. --help and docs/linux_proton.md say both. test_a_fresh_cache_drops_the_drivers_own_cache_variables checks the stub sees none of them under fresh and the caller's values under a kept cache.
  • Minor: a fresh run empties session/cache in a run folder that is accepted again, and session.txt is written anew on each launch (>), so there is one shader cache: line; test_a_fresh_cache_is_empty_in_an_accepted_run_folder.
  • Minor: the safety fixture passes --cache fresh.

Linux, Python 3.13: tests/test_run_game_wine.py 14/14 (the two new tests fail with the old script), tests/test_run_game_wine_safety.py 3/3, also with XDG_CACHE_HOME naming a regular file. Merges cleanly into main d762b139.

AI-assisted (Claude Code); I ran the tests and checked the results.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7272693868 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2436#issuecomment-7272693868). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-30T08:16:13Z. --- Thanks, all three addressed in 206bb4b6: - Major: `--cache fresh` now unsets `MESA_SHADER_CACHE_DIR`, `MESA_GLSL_CACHE_DIR` and `__GL_SHADER_DISK_CACHE_PATH`, so a fresh run is cold whatever the caller had set; with a kept cache the caller's variables stay and win over the XDG root. `--help` and `docs/linux_proton.md` say both. `test_a_fresh_cache_drops_the_drivers_own_cache_variables` checks the stub sees none of them under fresh and the caller's values under a kept cache. - Minor: a fresh run empties `session/cache` in a run folder that is accepted again, and `session.txt` is written anew on each launch (`>`), so there is one `shader cache:` line; `test_a_fresh_cache_is_empty_in_an_accepted_run_folder`. - Minor: the safety fixture passes `--cache fresh`. Linux, Python 3.13: `tests/test_run_game_wine.py` 14/14 (the two new tests fail with the old script), `tests/test_run_game_wine_safety.py` 3/3, also with `XDG_CACHE_HOME` naming a regular file. Merges cleanly into main d762b139. AI-assisted (Claude Code); I ran the tests and checked the results. --- _Generated by [Claude Code](https://claude.ai/code)_
aslan2142 commented 2026-12-01 11:30:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:30:38Z.

Review: APPROVED


Reviewed head diff against main: scripts/run_game_wine.sh cleanly adds --cache DIR|fresh (defaulting to caller XDG_CACHE_HOME or fresh), unsets driver-specific cache overrides and clears session/cache on fresh runs, records the active cache mode in session.txt, updates docs/linux_proton.md, and adds unit test coverage in tests/test_run_game_wine.py and tests/test_run_game_wine_safety.py. Clean-room verified and all CI checks green.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130340661 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2436#pullrequestreview-6130340661). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:30:38Z. **Review:** APPROVED --- Reviewed head diff against `main`: `scripts/run_game_wine.sh` cleanly adds `--cache DIR|fresh` (defaulting to caller `XDG_CACHE_HOME` or `fresh`), unsets driver-specific cache overrides and clears `session/cache` on `fresh` runs, records the active cache mode in `session.txt`, updates `docs/linux_proton.md`, and adds unit test coverage in `tests/test_run_game_wine.py` and `tests/test_run_game_wine_safety.py`. Clean-room verified and all CI checks green. *(AI-assisted review.)*
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
ProjectLeonida/mandy!2436
No description provided.