pipelines: keep the graphics pipelines earlier runs drew with (LARP_KEEP_USED) #435

Open
github-bot wants to merge 5 commits from github-bot/gh-435 into main AGit
Owner

@⁠nikitronick-crypto on GitHub · 2026-12-06 00:50 UTC · original
nikitronick-crypto:keep-used-pipelines → main · +254 −5 · 5 files · 5 commits · open

Refs #390. Related: #424 (its LARP_OPT_ASYNC_WORLD_PSOS lets 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 to used-pipelines.txt, again at its first draw of each run, so the file's order is that of last use. At the next start the LARP_KEEP_USED_MAX most 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 to larp-shader or shader_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

Run Keys read Loaded at the menu Commit, median (MB) GPU dedicated, median (MB) Frames >= 300 ms
Off - 2,687 23,408 10,266 5 (longest 3.62 s)
On 2,079 4,761 23,375 10,056 1 (0.74 s)
  • Memory: with about 2,000 more pipelines resident, no difference outside the run-to-run noise on this 12 GB card. An earlier round showed +380 MB of commit, within the spread between runs. No per-pipeline cost can be given from this.
  • Hitches: fewer in one of two rounds, not worse in the other. Suggestive, not proof.
  • Start: about 2,000 more pipelines are loaded at the menu.

Checked, on the fourth commit. cargo build --release --locked -p larp and cargo test --release --locked -p larp-gpu --lib used on 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).

**@⁠nikitronick-crypto** on GitHub · 2026-12-06 00:50 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435) `nikitronick-crypto:keep-used-pipelines` → `main` · +254 −5 · 5 files · 5 commits · open Refs #390. Related: #424 (its `LARP_OPT_ASYNC_WORLD_PSOS` lets 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 to `used-pipelines.txt`, again at its first draw of each run, so the file's order is that of last use. At the next start the `LARP_KEEP_USED_MAX` most 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 to `larp-shader` or `shader_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: https://git.gtahub.st/github/gamingwithhomie--larp/pulls/435 | Run | Keys read | Loaded at the menu | Commit, median (MB) | GPU dedicated, median (MB) | Frames >= 300 ms | |---|---|---|---|---|---| | Off | - | 2,687 | 23,408 | 10,266 | 5 (longest 3.62 s) | | On | 2,079 | 4,761 | 23,375 | 10,056 | 1 (0.74 s) | - **Memory:** with about 2,000 more pipelines resident, no difference outside the run-to-run noise on this 12 GB card. An earlier round showed +380 MB of commit, within the spread between runs. No per-pipeline cost can be given from this. - **Hitches:** fewer in one of two rounds, not worse in the other. Suggestive, not proof. - **Start:** about 2,000 more pipelines are loaded at the menu. **Checked, on the fourth commit.** `cargo build --release --locked -p larp` and `cargo test --release --locked -p larp-gpu --lib used` on 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).
A graphics pipeline made at the menu with nothing asking for it is released,
its blob on disk, and its first draw makes it again 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 last one already had.

The key of each graphics pipeline a draw asks for is now appended to
used-pipelines.txt; at the next start those are made with the listed ones
and kept. LARP_KEEP_USED=0 turns it off.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 01:02:37 +00:00
Author
Owner

@⁠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:

  1. The history is unbounded. used-pipelines.txt only 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.
  2. The list is not scoped with the native blob store. used::note() / wanted() receive blobs::dir() (the cache root), while #376 places native blobs under adapter/driver/PIX-specific child directories. The same used-pipelines.txt is 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 ID3D12PipelineState objects, 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::QueryVideoMemoryInfo usage/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 toward LARP_KEEP_USED=0 by 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:01 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7448844391) · 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: 1. **The history is unbounded.** `used-pipelines.txt` only 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. 2. **The list is not scoped with the native blob store.** `used::note()` / `wanted()` receive `blobs::dir()` (the cache root), while #376 places native blobs under adapter/driver/PIX-specific child directories. The same `used-pipelines.txt` is 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 `ID3D12PipelineState` objects, 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::QueryVideoMemoryInfo` usage/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 toward `LARP_KEEP_USED=0` by 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.
The kept pipelines stay resident for the run, and what they take of the
PC's and the card's memory is not measured yet: off unless LARP_KEEP_USED=1.
Nothing is written to used-pipelines.txt while it is off.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Author
Owner

@⁠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 by Store::new, but used-pipelines.txt is still read and written directly under the root. The history is therefore shared across those cache identities.
  • used-pipelines.txt remains 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.

**@⁠vanya890** on GitHub · 2026-12-06 01:18 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7449065874) 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 by `Store::new`, but `used-pipelines.txt` is still read and written directly under the root. The history is therefore shared across those cache identities. - `used-pipelines.txt` remains 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.
github-bot force-pushed github-bot/gh-435 from 3d82a6419d to ed201a58ad 2026-12-06 01:32:30 +00:00 Compare
Author
Owner

@⁠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):

  1. Off by default. LARP_KEEP_USED=1 turns it on; otherwise nothing is kept and nothing is written.
  2. Bounded, by last use. A key is written again at its first draw of each run, so the file's order is that of last use. A start keeps the LARP_KEEP_USED_MAX most recent (4096 unless set) and rewrites the file without the others, so neither the file nor the resident set grows past the limit.
  3. Scoped with the blobs. used-pipelines.txt now lies in the scoped blob folder of #376 (new blobs::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 larp and cargo test --release --locked -p larp-gpu --lib used on 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 Memory counters), with the count of pipelines loaded at the menu. If you want QueryVideoMemoryInfo'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.

**@⁠nikitronick-crypto** on GitHub · 2026-12-06 01:27 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7449187100) Thanks, all three points are fair. Pushed (rebased on current `main`, so on top of #376): 1. **Off by default.** `LARP_KEEP_USED=1` turns it on; otherwise nothing is kept and nothing is written. 2. **Bounded, by last use.** A key is written again at its first draw of each run, so the file's order is that of last use. A start keeps the `LARP_KEEP_USED_MAX` most recent (4096 unless set) and rewrites the file without the others, so neither the file nor the resident set grows past the limit. 3. **Scoped with the blobs.** `used-pipelines.txt` now lies in the scoped blob folder of #376 (new `blobs::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 larp` and `cargo test --release --locked -p larp-gpu --lib used` on 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 Memory` counters), with the count of pipelines loaded at the menu. If you want `QueryVideoMemoryInfo`'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.
Author
Owner

@⁠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.

**@⁠vanya890** on GitHub · 2026-12-06 01:29 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7449215218) 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.
Author
Owner

@⁠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 and Used::open skips 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)
--- a/crates/larp-gpu/src/pipeline/used.rs
+++ b/crates/larp-gpu/src/pipeline/used.rs
@@ -78,12 +78,14 @@
 
 impl Used {
     /// Reads the list in `dir`, keeps its `max` most recent keys and, when
-    /// the file held more lines than those, writes it again with them alone.
+    /// the file needs pruning or a final newline, rewrites it before appending.
     fn open(dir: &Path, max: usize) -> Used {
         let path = dir.join(FILE);
         let text = std::fs::read_to_string(&path).unwrap_or_default();
         let kept = recent(&text, max);
-        if text.lines().count() > kept.len() {
+        // A run can end after the last hex digit but before the newline.
+        // Separate that valid key from the next append.
+        if (!text.is_empty() && !text.ends_with('\n')) || text.lines().count() > kept.len() {
             let whole: String = kept.iter().map(|k| format!("{k}\n")).collect();
             let tmp = dir.join(format!("{FILE}.tmp"));
             if std::fs::write(&tmp, whole).and_then(|()| std::fs::rename(&tmp, &path)).is_err() {
@@ -150,6 +152,21 @@
     const C: &str = "00112233445566778899aabbccddeeff";
 
     #[test]
+    fn appending_after_a_complete_key_without_a_newline_preserves_both_keys() {
+        let dir = std::env::temp_dir().join(format!("larp-used-newline-{}", std::process::id()));
+        std::fs::create_dir_all(&dir).unwrap();
+        std::fs::write(dir.join(FILE), A).unwrap();
+        let mut run = Used::open(&dir, 2);
+        run.note(B);
+        drop(run);
+
+        let next = Used::open(&dir, 2);
+        assert!(next.earlier.contains(A) && next.earlier.contains(B));
+        drop(next);
+        std::fs::remove_dir_all(&dir).unwrap();
+    }
+
+    #[test]
     fn the_most_recent_keys_are_kept_each_at_its_last_line() {
         let text = format!("{A}\n\n{B}\n0123456789abcdef\nnot a key at all, thirty-two long!\n{A}\n{C}\n");
         assert_eq!(recent(&text, 10), [B, A, C]);
**@⁠christopear** on GitHub · 2026-12-06 01:57 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7449583424) 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 and `Used::open` skips 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. <details> <summary>Tested fix and regression test (copy the diff into git apply)</summary> ```diff --- a/crates/larp-gpu/src/pipeline/used.rs +++ b/crates/larp-gpu/src/pipeline/used.rs @@ -78,12 +78,14 @@ impl Used { /// Reads the list in `dir`, keeps its `max` most recent keys and, when - /// the file held more lines than those, writes it again with them alone. + /// the file needs pruning or a final newline, rewrites it before appending. fn open(dir: &Path, max: usize) -> Used { let path = dir.join(FILE); let text = std::fs::read_to_string(&path).unwrap_or_default(); let kept = recent(&text, max); - if text.lines().count() > kept.len() { + // A run can end after the last hex digit but before the newline. + // Separate that valid key from the next append. + if (!text.is_empty() && !text.ends_with('\n')) || text.lines().count() > kept.len() { let whole: String = kept.iter().map(|k| format!("{k}\n")).collect(); let tmp = dir.join(format!("{FILE}.tmp")); if std::fs::write(&tmp, whole).and_then(|()| std::fs::rename(&tmp, &path)).is_err() { @@ -150,6 +152,21 @@ const C: &str = "00112233445566778899aabbccddeeff"; #[test] + fn appending_after_a_complete_key_without_a_newline_preserves_both_keys() { + let dir = std::env::temp_dir().join(format!("larp-used-newline-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + std::fs::write(dir.join(FILE), A).unwrap(); + let mut run = Used::open(&dir, 2); + run.note(B); + drop(run); + + let next = Used::open(&dir, 2); + assert!(next.earlier.contains(A) && next.earlier.contains(B)); + drop(next); + std::fs::remove_dir_all(&dir).unwrap(); + } + + #[test] fn the_most_recent_keys_are_kept_each_at_its_last_line() { let text = format!("{A}\n\n{B}\n0123456789abcdef\nnot a key at all, thirty-two long!\n{A}\n{C}\n"); assert_eq!(recent(&text, 10), [B, A, C]); ``` </details>
Found, fixed and tested by christopear in the review of #435: a whole key
at the file's end with no newline was taken as kept and the file left as
it was, so the next append made one 64-character line of two keys, and the
following start dropped both. The file is now written again in that case
too.

Co-authored-by: christopear <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Author
Owner

@⁠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 used now 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 Memory counter for the process, not QueryVideoMemoryInfo; the budget was not read. Two rounds, because the first one alone would have misled me.

Round, run Keys read Loaded at the menu In the world Commit, peak / median (MB) Working set, peak / median (MB) GPU dedicated, peak / median (MB) Frames >= 300 ms
1 (ed201a5), on, empty list 0 2,687 4 min 15 s 24,000 / 23,342 11,352 / 10,873 10,240 / 9,982 0
1 (ed201a5), on, list of the run above 1,970 4,652 4 min 57 s 24,573 / 23,722 13,570 / 13,165 10,472 / 10,168 1 (0.49 s)
2 (with the newline fix), off - 2,687 4 min 37 s 24,258 / 23,408 13,325 / 12,742 10,543 / 10,266 5 (0.97, 0.44, 3.62, 1.18, 0.48 s)
2 (with the newline fix), on 2,079 4,761 4 min 32 s 24,039 / 23,375 13,314 / 12,785 10,348 / 10,056 1 (0.74 s)

(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:

  • Memory. With about 2,000 more pipelines resident, round 2 shows no difference outside the noise (commit median 23,408 against 23,375 MB, working set 12,742 against 12,785 MB, GPU dedicated 10,266 against 10,056 MB). Round 1 shows +380 MB of commit and +2.3 GB of working set, but its first run was unusually low in working set next to every other run, so I take the round-to-round spread to be larger than the effect. I cannot give a per-pipeline cost from this.
  • Hitches. Round 2: five frames of 300 ms or more with the option off, one with it on. Round 1: none with an empty list, one with the list. With a route walked by hand, that is suggestive and not proof; I would not claim more than "it did not get worse, and in one of two rounds it was clearly better".
  • Not tested: an 8 GB card, AMD, Linux/Proton, clippy, the rest of the workspace tests.

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.

**@⁠nikitronick-crypto** on GitHub · 2026-12-06 02:41 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7450129719) @⁠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 used` now 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 Memory` counter for the process, not `QueryVideoMemoryInfo`; the budget was not read. Two rounds, because the first one alone would have misled me. | Round, run | Keys read | Loaded at the menu | In the world | Commit, peak / median (MB) | Working set, peak / median (MB) | GPU dedicated, peak / median (MB) | Frames >= 300 ms | |---|---|---|---|---|---|---|---| | 1 (`ed201a5`), on, empty list | 0 | 2,687 | 4 min 15 s | 24,000 / 23,342 | 11,352 / 10,873 | 10,240 / 9,982 | 0 | | 1 (`ed201a5`), on, list of the run above | 1,970 | 4,652 | 4 min 57 s | 24,573 / 23,722 | 13,570 / 13,165 | 10,472 / 10,168 | 1 (0.49 s) | | 2 (with the newline fix), off | - | 2,687 | 4 min 37 s | 24,258 / 23,408 | 13,325 / 12,742 | 10,543 / 10,266 | 5 (0.97, 0.44, 3.62, 1.18, 0.48 s) | | 2 (with the newline fix), on | 2,079 | 4,761 | 4 min 32 s | 24,039 / 23,375 | 13,314 / 12,785 | 10,348 / 10,056 | 1 (0.74 s) | (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: - **Memory.** With about 2,000 more pipelines resident, round 2 shows no difference outside the noise (commit median 23,408 against 23,375 MB, working set 12,742 against 12,785 MB, GPU dedicated 10,266 against 10,056 MB). Round 1 shows +380 MB of commit and +2.3 GB of working set, but its first run was unusually low in working set next to every other run, so I take the round-to-round spread to be larger than the effect. I cannot give a per-pipeline cost from this. - **Hitches.** Round 2: five frames of 300 ms or more with the option off, one with it on. Round 1: none with an empty list, one with the list. With a route walked by hand, that is suggestive and not proof; I would not claim more than "it did not get worse, and in one of two rounds it was clearly better". - **Not tested:** an 8 GB card, AMD, Linux/Proton, clippy, the rest of the workspace tests. 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.
Author
Owner

@⁠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 1cc41d96 under 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

#[test]
fn locked_rewrite_does_not_join_keys() {
    use std::os::windows::fs::OpenOptionsExt;
    let dir = std::env::temp_dir().join(format!("used-locked-{}", std::process::id()));
    std::fs::create_dir(&dir).unwrap();
    let path = dir.join(FILE);
    std::fs::write(&path, A).unwrap();
    // Allow concurrent reads and writes, but deny replacement while the reader is open.
    let reader = std::fs::OpenOptions::new().read(true).share_mode(3).open(&path).unwrap();
    let mut run = Used::open(&dir, 2);
    run.note(B);
    drop(run);
    drop(reader);
    let bytes = std::fs::read_to_string(&path).unwrap();
    let next = Used::open(&dir, 2);
    let saved = (next.earlier.contains(A), next.earlier.contains(B));
    drop(next);
    std::fs::remove_dir_all(&dir).unwrap();
    assert_eq!(saved, (true, true), "history after append: {bytes:?}");
}
**@⁠christopear** on GitHub · 2026-12-06 02:48 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7450223123) Thanks for taking the newline fix and adding the memory measurements. I confirmed all three history tests on `1cc41d96` under 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. <details> <summary>Regression test for the existing used.rs tests module</summary> ```rust #[test] fn locked_rewrite_does_not_join_keys() { use std::os::windows::fs::OpenOptionsExt; let dir = std::env::temp_dir().join(format!("used-locked-{}", std::process::id())); std::fs::create_dir(&dir).unwrap(); let path = dir.join(FILE); std::fs::write(&path, A).unwrap(); // Allow concurrent reads and writes, but deny replacement while the reader is open. let reader = std::fs::OpenOptions::new().read(true).share_mode(3).open(&path).unwrap(); let mut run = Used::open(&dir, 2); run.note(B); drop(run); drop(reader); let bytes = std::fs::read_to_string(&path).unwrap(); let next = Used::open(&dir, 2); let saved = (next.earlier.contains(A), next.earlier.contains(B)); drop(next); std::fs::remove_dir_all(&dir).unwrap(); assert_eq!(saved, (true, true), "history after append: {bytes:?}"); } ``` </details>
Found and tested by christopear in the review of #435: where the file ends
in a whole key with no newline and cannot be written again (another program
holds it open without letting it be replaced), the next append still made
one 64-character line of two keys, and the following start dropped both.
The line is now ended before a key is appended; where not even that can be
written, the run writes none.

Co-authored-by: christopear <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Author
Owner

@⁠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 of OpenOptionsExt. On Windows, cargo build --release --locked -p larp and cargo test --release --locked -p larp-gpu --lib used now 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.

**@⁠nikitronick-crypto** on GitHub · 2026-12-06 03:01 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7450372211) @⁠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 of `OpenOptionsExt`. On Windows, `cargo build --release --locked -p larp` and `cargo test --release --locked -p larp-gpu --lib used` now 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.
Author
Owner

@⁠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=4096 cut off part of what was used. I'm running 6144 now. Might be worth a higher default. https://github.com/iceboerg00/larp-amd/issues/64

**@⁠TrinityForever15** on GitHub · 2026-12-06 03:17 UTC · [original](https://github.com/gamingwithhomie/larp/pull/435#issuecomment-7450572945) 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=4096` cut off part of what was used. I'm running 6144 now. Might be worth a higher default. https://github.com/iceboerg00/larp-amd/issues/64
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/435/head:github-bot/gh-435'
git switch 'github-bot/gh-435'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-435'
git switch 'github-bot/gh-435'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-435'
git switch 'github-bot/gh-435'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-435'
git switch 'main'
git merge --squash 'github-bot/gh-435'
git switch 'main'
git merge --ff-only 'github-bot/gh-435'
git switch 'main'
git merge 'github-bot/gh-435'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.