pipelines: keep the graphics pipelines earlier runs drew with (LARP_KEEP_USED) #435
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/gamingwithhomie--larp!435
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-435"
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?
@nikitronick-crypto on GitHub · 2026-12-06 00:50 UTC · original
nikitronick-crypto:keep-used-pipelines→main· +254 −5 · 5 files · 5 commits · openRefs #390. Related: #424 (its
LARP_OPT_ASYNC_WORLD_PSOSlets a new pipeline compile without blocking; this one makes the wait not happen for pipelines an earlier run already drew with, and drops no draws. They can coexist).Problem. At a start after the first, a graphics pipeline with a blob on disk is passed over at the menu and made at its first draw, on the thread that asks. A place seen for the first time in a run draws with many at once, so every run stalls again where the previous one already had.
Change (as of the fourth commit). Opt-in:
LARP_KEEP_USED=1. While it is on, the key of each graphics pipeline a draw asks for is written toused-pipelines.txt, again at its first draw of each run, so the file's order is that of last use. At the next start theLARP_KEEP_USED_MAXmost recently used (4096 unless set) are made at the menu with the listed ones and kept, and the file is rewritten without the others. The file lies in the scoped blob folder of #376 (blobs::scoped()), one list for each adapter, driver and capture mode; without such a folder nothing is kept. 222 lines added in 5 files, no change tolarp-shaderorshader_cache.rs(no cache invalidation). The fourth commit is christopear's fix and test from the review: a key at the file's end with no newline behind it is no longer joined to the next one.Measured on the current code (Ryzen 5 7500F, RTX 3080 Ti 12 GB, 32 GB, Series X, 4K output with DLSS, hardware RT on; same save, route walked by hand, so not a controlled A/B). Full table and method: #435
Checked, on the fourth commit.
cargo build --release --locked -p larpandcargo test --release --locked -p larp-gpu --lib usedon Windows (three unit tests: the limit, the order of last use, the rewrite, and the key with no newline). Run in the game on this revision with the option off and on. Not run: clippy, the rest of the workspace tests, an 8 GB card, AMD, Linux/Proton.Conclusion. Opt-in and experimental is what the evidence supports; not proposed as a default.
Made with the assistance of AI (Claude).
@vanya890 on GitHub · 2026-12-06 01:01 UTC · original · edited 2026-12-06 01:08 UTC
The hitch reduction is promising, but I think the default needs more evidence before this is enabled for everyone.
Two additional concerns after checking the implementation against the merged cache-scoping change in #376:
used-pipelines.txtonly ever receives new keys; there is no pruning or rotation. The set therefore grows monotonically across sessions. A user who visits more of the world over time can eventually accumulate most of the available graphics PSOs, approaching the 95,000-pipeline / 11.7 GB retention problem this change is meant to avoid.used::note()/wanted()receiveblobs::dir()(the cache root), while #376 places native blobs under adapter/driver/PIX-specific child directories. The sameused-pipelines.txtis consequently shared across those identities, so changing GPU, driver, or capture mode can prewarm keys learned under a different cache identity.The reported menu count already rises from 2,685 to 4,683 pipelines (~74% more), and the PR says memory was not measured. These are retained
ID3D12PipelineStateobjects, so the important cost is additional live driver/host/GPU allocation, not just blob size or menu load time.Could you capture before/after peak process commit/RSS and
IDXGIAdapter3::QueryVideoMemoryInfousage/budget on the same route, ideally on an 8 GB card, and consider a bounded/rotated history stored beside the matching scoped blob directory? Until then, I would lean towardLARP_KEEP_USED=0by default rather than making thousands of additional PSOs resident by default. Users with memory pressure should not have to discover an opt-out after a regression.@vanya890 on GitHub · 2026-12-06 01:18 UTC · original
Thanks for making this opt-in by default; that addresses the main concern about imposing unmeasured PSO residency on every user.
I checked the updated head against #376. Two caveats still apply when the option is enabled:
blobs::dir()is the cache root. Native PSO blobs are stored under the adapter/driver/PIX-specific child path selected byStore::new, butused-pipelines.txtis still read and written directly under the root. The history is therefore shared across those cache identities.used-pipelines.txtremains append-only; there is no pruning or rotation, so it can grow indefinitely.With the feature disabled by default, I don't think these need to block this experimental PR. I'd keep them tracked before recommending the option or considering enabling it by default.
3d82a6419dtoed201a58ad@nikitronick-crypto on GitHub · 2026-12-06 01:27 UTC · original
Thanks, all three points are fair. Pushed (rebased on current
main, so on top of #376):LARP_KEEP_USED=1turns it on; otherwise nothing is kept and nothing is written.LARP_KEEP_USED_MAXmost recent (4096 unless set) and rewrites the file without the others, so neither the file nor the resident set grows past the limit.used-pipelines.txtnow lies in the scoped blob folder of #376 (newblobs::scoped()), so each adapter, driver and capture mode has its own list. Where there is no such folder (the identity is unavailable), nothing is kept.Checked on this revision:
cargo build --release --locked -p larpandcargo test --release --locked -p larp-gpu --lib usedon Windows (the two unit tests cover the limit, the order of last use and the rewrite). Not run: clippy, the rest of the workspace tests, AMD, Linux/Proton. Not yet run in the game on this revision; the game results in the description are from the first version.Memory: I will post before/after numbers from the same route on the RTX 3080 Ti (12 GB): peak and median process commit and working set, and the process's dedicated and shared GPU memory as Windows accounts it (the
GPU Process Memorycounters), with the count of pipelines loaded at the menu. If you wantQueryVideoMemoryInfo's own usage and budget I can add a log line for them. I have no 8 GB card; numbers from someone who has one would be welcome.@vanya890 on GitHub · 2026-12-06 01:29 UTC · original
Thanks, the current head addresses the two implementation concerns: the history is bounded by last use and stored inside the adapter/driver/capture-scoped blob directory, while the feature remains opt-in. The remaining evidence is the promised before/after process and GPU-memory measurements plus an in-game retest on this updated head; the description says the existing gameplay results are from the first revision. Since the default is off and the focused build/test pass, I do not see that as a blocker for an experimental opt-in merge, but please add the measurements before recommending or enabling this for general users. No further issue found in the updated diff.
@christopear on GitHub · 2026-12-06 01:57 UTC · original
I reproduced a small history recovery bug on
ed201a58. If the last key has all 32 hex digits but no trailing newline,recent()accepts it andUsed::openskips compaction. The next append joins two valid keys into a 64-character line. Both disappear on the following start.Reusing the existing rewrite path fixes this. With the new test alone I got 2 passes and 1 failure. With the fix all 3 history tests passed under Proton. This only affects the opt-in history file. I haven't measured in-game residency.
Tested fix and regression test (copy the diff into git apply)
@nikitronick-crypto on GitHub · 2026-12-06 02:41 UTC · original
@christopear: thank you, that is right. A whole key with no newline behind it was taken as kept, the file was not rewritten, and the next append joined two keys into one line that the following start dropped. I pushed your condition on the rewrite and your test as a commit crediting you; on Windows
cargo test --release --locked -p larp-gpu --lib usednow runs the three history tests and they pass.Measurements, as promised. RTX 3080 Ti 12 GB, Ryzen 5 7500F, 32 GB, release build, Series X, 4K output with DLSS from 1920x1088, hardware RT on. The same save each time, the route walked by hand (not scripted), sampled once a second from outside the process while in the world. "GPU dedicated" is Windows'
GPU Process Memorycounter for the process, notQueryVideoMemoryInfo; the budget was not read. Two rounds, because the first one alone would have misled me.ed201a5), on, empty listed201a5), on, list of the run above(A run before round 1, with the option off, is left out: it compiled 77,355 pipelines at the menu for the new scoped blob folder, which is not a normal start.)
What I read from it, and what I do not:
One observation that is not this change's: at the start of the world the sun's shadows are drawn as coarse square blocks for a while and then become right (the look of #391, on this RTX 3080 Ti). It happened with the option off and with it on.
So: opt-in and experimental is what the evidence supports. I would not turn it on by default on these numbers.
@christopear on GitHub · 2026-12-06 02:48 UTC · original
Thanks for taking the newline fix and adding the memory measurements. I confirmed all three history tests on
1cc41d96under Proton Experimental, including the normal recovery case.On the unchanged head, 34 larp-gpu library tests passed plus five opt-in hardware tests on an RTX 3090. I skipped the native Windows identity test and the populated-cache timing test. No gameplay or retention memory measurement in this run.
One low-priority edge remains if the rewrite fails but the original file is still appendable. I reproduced this with an ordinary Windows read handle that shares read/write but omits FILE_SHARE_DELETE. Given a complete key A without a newline, replacement fails, append succeeds, and the file ends up with one 64-character line. The next open loses both A and B. Only the optional retention history is affected. I wouldn't block the PR on it.
I added the test below locally. Three fresh processes each passed the existing three tests and failed the new one. A small fallback passed all four in three more processes. On failed rewrite of unterminated text, write a newline to the append handle before accepting more keys. If that write fails, leave recording disabled for the run. This keeps the normal path unchanged.
Regression test for the existing used.rs tests module
@nikitronick-crypto on GitHub · 2026-12-06 03:01 UTC · original
@christopear: thanks again. Fixed the way you suggest and pushed as a fifth commit crediting you: when the rewrite fails and the file's text ends in the middle of a line, a newline is written to the append handle before any key is appended; if that write fails too, nothing is recorded for the run. The normal path is unchanged.
Your test is in as you wrote it, under
#[cfg(windows)]because ofOpenOptionsExt. On Windows,cargo build --release --locked -p larpandcargo test --release --locked -p larp-gpu --lib usednow run the four history tests and they pass.Not run in the game on this commit (the change only acts when the rewrite fails), and clippy and the rest of the workspace tests are still not run.
@TrinityForever15 on GitHub · 2026-12-06 03:17 UTC · original
Works well on RX 6650 XT. One data point: the open world (car chases) reached ~4,880 active graphics pipelines, so the default
LARP_KEEP_USED_MAX=4096cut off part of what was used. I'm running 6144 now. Might be worth a higher default. https://github.com/iceboerg00/larp-amd/issues/64View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.