fix(dev): the queue names no NVIDIA cache folder for a game the Windows sandbox confines #2751
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2751
Loading…
Reference in a new issue
No description provided.
Delete branch "ChloeNow/Longshot:fix/sandbox-nv-cache-dir"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
fix(dev): the queue names no NVIDIA cache folder for a game the Windows sandbox confines
Summary
On Windows every sandboxed game run through the development queue (
dev.py game-tests,dev.py queue run) compiledevery pipeline again at its start: 15 to 25 minutes of "preparing shaders" on an RTX 4060 after any change of the
translator, and the same again on the next run.
The queue names an NVIDIA shader cache folder for every job (
__GL_SHADER_DISK_CACHE_PATH, itsnvcache), andNVIDIA's Windows driver keeps its cache there. The sandboxed game's AppContainer cannot open that folder, and the driver
keeps no cache at all in a folder it cannot open. So a confined queue run kept nothing.
This changes the queue, not the sandbox: the game gets no new grant. On Windows a game run (a mode with a GPU share)
gets no queue folder unless
HOS_SANDBOXis0. The confined driver then keeps its cache in the container's ownfolder (
%LOCALAPPDATA%\Packages\longshot.game\AC\NVIDIA\GLCache), which it can always write. Builds, whose shaderpreparation runs unconfined, a folder the caller set, and Linux all keep the folder as before. Players were never
affected: a normal start sets no such folder.
scripts/devtools/jobqueue.pyjob_env: the rule above.docs/dev/developing.md: the queue's NVIDIA cache section says so.An earlier version of this pull request granted the queue's folder to the container instead. That widened the
sandbox, against the plan for longshot-builder to broker between the game and the system, so this version replaces it.
On mod-api, to see it: Windows, sandboxed (the default). Two
dev.py game-testsruns in a row both spend theirstart compiling ("noted pipelines: N of ~38000"), and nothing writes the container's NVIDIA cache.
Read first:
job_envinscripts/devtools/jobqueue.py.How it was found
All on one build, sandboxed, with the container's NVIDIA cache moved aside so the driver had to compile:
longshot_ctl.py launchmade the container's cache (6.5 MB in two minutes).nvcache(1.9 GB): the Windows driver does read the variable.Testing
Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24.
tests/test_job_queue.py,test_no_queue_nvidia_cache_for_a_game_the_windows_sandbox_confines(new):common.WINDOWSon, game modes get no folder, withHOS_SANDBOXunset orstrict.HOS_SANDBOX=0they get one, and a build and a folder of the caller's own keep theirs.with the rule undone it fails again.
test_no_lift_key_variableschecks Linux's rule, so its folder checks now run withcommon.WINDOWSoff.tests/test_job_queue.py: 47 tests, one failure.test_a_pid_used_again_or_another_namespace_is_not_itfails the same way on mod-api.
dev.py queue run), the container'sNVIDIA cache moved aside, quit after 150 s.
GLCache\...\b4217564bad97491.binmade in the container's folder, 42.9 MB written while it compiled(
noted pipelines: 346 of 37935 ... in 10 s).Still to test:
Measurements
The fix's effect is the driver's cache kept from one sandboxed queue run to the next: the "Before" and "After" above
(a cache made, against none). The time a run saves depends on how many of its pipelines are new; with none kept, every
start compiled all of them (about 38,000 here, 15 to 25 minutes).
Risks
builds' pipelines go into the cache the player's game reads. NVIDIA's shader cache size is the player's setting
(no limit on this PC); with a limit, dev runs could evict the played game's entries.
HOS_SANDBOX=0passed only to the game (not in the queue's environment) uses theplayer's own
%LOCALAPPDATA%\NVIDIA\GLCache, not the queue's.Not here
The renderer measures the driver's cache on Windows at
%LOCALAPPDATA%\NVIDIA\GLCachealone(
gpu/vk/pcache_load.hnvidia_cache_windows), and its note says the Windows driver reads no variable for its folder.For a confined run that is now the right folder. For an unconfined queue run with the variable set it is not: a renderer
change, for a pull request of its own.
Checklist
Ready for review
mod-api; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11, RTX 4060 Laptop, sandboxed starts through the dev queue's wrapper on this head (with #2726 and #2742 merged locally): the queue's nvcache folder is granted and the confined NVIDIA driver writes it; on mod-api the same start kept no driver cache at all.
Possibly related, for context:
@review
Recommendation: Request changes. The cache grant can make the game’s protected files writable by the confined process, and an unusable optional cache folder can prevent the game from starting. The reported run shows cache writes, but the claimed reduction in repeated startup time remains unmeasured.
The change grants the Windows AppContainer write access to the NVIDIA cache folder named by the environment, allowing development queue runs to retain driver cache data. It reuses the existing ACL planner, but expands its writable surface and makes an optional cache grant affect launch success.
Blocking (1): must change before merging.
host/sandbox_win_plan.h:321: The cache path can grant direct write access to files that the sandbox otherwise protects through the broker. (more on the line) Do: Reject cache grants that overlap protected game, profile, save, mod or other brokered roots, and test those overlaps.Should fix (1): not blocking, but worth doing before merging.
host/sandbox_win_plan.h:321: Failure to grant this optional cache folder can prevent a sandboxed game from starting. (more on the line) Do: Treat failure to grant the optional NVIDIA cache as nonfatal, log that caching is unavailable, and cover an existing but ungrantable cache folder.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1 and L2.More: does it help, other systems, switches, what was read
Does it help: Unproven: on Windows 11 with an RTX 4060 Laptop GPU, the author reports that two three-minute confined runs wrote a shared cache that grew to 1.889 GB, whereas the base wrote no queue cache. There are no comparable completed cold and warm startup timings for the base and this change.
Other systems: The new Windows grant is planned regardless of GPU vendor and can affect any sandboxed launch that inherits the variable. Linux is unchanged. The Windows renderer still measures the default NVIDIA cache instead of the named folder, as the description notes; no timing comparison establishes the effect of that policy on these queue runs.
Switches: __GL_SHADER_DISK_CACHE_PATH is an existing environment variable, unset by default for normal starts and set by the development queue when absent. The change makes Windows grant its named folder write access; the current unrestricted choice of folder is unsafe for protected game data.
Reviewed:
2fd3155d47against5c1cd9f5b1: Read the diff, both commit messages, repository rules, pull request template, Windows ACL planner and relevant Windows launch and grant paths, queue environment setup, changed tests, and renderer cache selection. Skimmed the sandbox reference and standards; docs/review-checklist.md and the adjacent Tooling checkout are absent. Large files were reviewed around the changed paths and their dependencies rather than in full.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run, as requested. The author reports Windows sandbox plan checks and two short in-game runs with sibling changes merged locally; complete startup measurements and Linux checks remain outstanding.
Overlaps and merge order: The description identifies adjacent changes in #2726 and a local test dependency on #2742; their current merge status was not available offline.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -316,1 +318,4 @@sbxw_add(p, in, in->shader_store, SBXW_WRITE, 1, "the renderer's shader store");/* (NVIDIA's Windows driver files its cache in the folder __GL_SHADER_DISK_CACHE_PATH names, and keeps none at all in one itcannot open: by ACL, as the drivers' own caches above, since the driver opens it itself) */sbxw_add(p, in, in->nv_cache_dir, SBXW_WRITE, 1, "NVIDIA's shader cache (__GL_SHADER_DISK_CACHE_PATH)");L1 (blocking): The cache path can grant direct write access to files that the sandbox otherwise protects through the broker.
When: If __GL_SHADER_DISK_CACHE_PATH names the game folder, or a folder containing a profile's mods or saves, and that path is below the protected top-level folders, sbxw_add accepts it as an inherited write ACL. The confined process can then modify those files directly, bypassing the broker's read-only and restricted-write roots.
Do: Reject cache grants that overlap protected game, profile, save, mod or other brokered roots, and test those overlaps.
L2 (should fix): Failure to grant this optional cache folder can prevent a sandboxed game from starting.
When: If the inherited variable names an existing directory the user can read but cannot change permissions on, grant fails and sbxw_grant_failed treats the existing writable-folder grant as fatal. This happens even on a non-NVIDIA GPU, although the game could run without this cache.
Do: Treat failure to grant the optional NVIDIA cache as nonfatal, log that caching is unavailable, and cover an existing but ungrantable cache folder.
WIP: fix(sandbox): Windows grants the folder __GL_SHADER_DISK_CACHE_PATH names, NVIDIA's shader cacheto WIP: fix(dev): the queue names no NVIDIA cache folder for a game the Windows sandbox confinesReworked: instead of granting the queue's NVIDIA cache folder to the sandboxed game (a wider sandbox, against the builder-as-broker plan), the queue now names no such folder for a game the Windows sandbox confines, so the confined driver keeps its cache in the container's own folder. Tested in game: a sandboxed start through the queue made and wrote the container's cache (42.9 MB in 150 s), where mod-api's queue made none.
2fd3155d472bfb7902cf@review
Recommendation: Approve. The code is ready: only testing is left. The change removes the proposed sandbox grant and a Windows run shows the container cache being written. The claimed reduction in repeated shader preparation still needs a comparison across repeated starts. Recommend approval; not approved on the forge.
Sandboxed Windows GPU jobs no longer receive the queue's NVIDIA cache path, allowing the driver to use the container cache without widening sandbox access. The tradeoff is that development runs share the player's sandboxed cache and may evict entries under a cache size limit.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
2fd3155d47)Resolved: L1 (The cache path can grant direct write access to files that the sandbox otherwise protects…); L2 (Failure to grant this optional cache folder can prevent a sandboxed game from starting.)
Still open: L3 (The claimed improvement to repeated shader preparation has not yet been measured.)
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven for repeated-start time: on Windows 11 with an RTX 4060 Laptop GPU, the reported run wrote 42.9 MB to the container cache in 150 seconds, versus no cache folder on the base. No repeated-start preparation times are reported.
Other systems: Linux and Windows build jobs retain the existing queue cache policy; caller-provided paths are preserved. The reported game run covers Windows NVIDIA; the Linux queue test and other hardware runs are not reported.
Switches: No switches added, changed or removed. Existing HOS_SANDBOX and NVIDIA cache variables determine the queue's behavior.
Reviewed:
2bfb7902cfagainst5c1cd9f5b1: Read the repository rules, pull request template, diff, commits and changed files; traced job_env, its caller, modes and the former sandbox grant. The combined output for the full changed files was truncated; the surrounding sandbox code and tests were skimmed. The Tooling repository and docs/review-checklist.md were absent.; nothing run (a code review).Checked and fine:
Testing: The author reports a Windows NVIDIA game run and a game-free regression test; repeated-start timing remains outstanding. No tests or project scripts were run during this review.
Overlaps and merge order: Not checked; network access is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
WIP: fix(dev): the queue names no NVIDIA cache folder for a game the Windows sandbox confinesto fix(dev): the queue names no NVIDIA cache folder for a game the Windows sandbox confines