victory-gpu: split the pipeline library into shards so a save writes only what changed (was 600 MB per save) #1653

Open
github-bot wants to merge 3 commits from github-bot/gh-1653 into main AGit
Owner

@⁠pes7 on GitHub · 2026-11-24 20:29 UTC · original
pes7:perf/pipeline-library-shards → main · +261 −131 · 1 files · 3 commits · open

Every save writes the whole 600 MB pipeline library. The host can only serialise a library whole, so splitting it into shards - one file each, chosen by the pipeline's name hash - lets a save write only the shards that gained pipelines. owner: GPU-PIPELINE-LIBRARY-SIZE in #1633. ## The problem, as the task states it The host pipeline library is one serialised blob, over 600 MB in the world, and ID3D12PipelineLibrary::Serialize has no per-entry form: the whole thing is copied into one buffer and written, every time a save happens (every 20 s while new pipelines are still being made, and at shutdown). Serialize itself copies 600 MB, then write_atomically writes 600 MB to a temp file and renames it. ## What changes The library becomes 16 shards, host-pipelines.00.bin ... host-pipelines.15.bin: - shard_of(name) hashes the pipeline's name (already a hash of its whole host description) and picks a shard. Stable across runs, so a pipeline always lands in the same file - that is what makes a partial save correct. - libraries() opens every shard from its own file; a missing file is an empty library, a rejected blob is an empty library, exactly as the single file behaved. - pipeline() looks a pipeline up in its own shard only (no extra lookups: the routing is deterministic) and stores it there on a miss. The per-shard mutex also means pipeline creation contends 16 ways instead of one. - save() serialises and writes only the shards with added > 0, and writes the early list only when it changed. The log line reports shards = K, bytes = B instead of one blob's size. A save that adds pipelines spread over K shards writes K/16 of the library instead of all of it. In the steady state a run touches one or two shards, so a 600 MB write becomes roughly 40-75 MB. ## Measured What I can measure here, without the title: - a_pipeline_lands_in_one_shard_and_the_shards_spread: the same name always maps to the same shard, and 4 096 names reach all 16 shards, so a save is a fraction rather than all or nothing. - The bytes a save writes are printed by the existing log line (host pipeline library saved), which now carries shards and bytes - so the first run in the world gives the number directly: the old line reported bytes тХд╨ТтХи╨йтХи╨и 600 MB, the new one reports the sum of the changed shards. Not measured: the wall time of a save in the world. It is Serialize + one write per changed shard, so it scales with the same fraction. ## Correctness Rewritten onto main 940d32f, where this module gained the pre-build's prebuilt list. That list is now one file per shard (prebuilt-pipelines.NN.txt), each tagged with its own shard's bytes: a single list tagged with the whole library would be invalidated by any shard's write, which would undo the point of sharding. The concurrency added upstream at the same time is kept as it is: one thread at a time per pipeline name (Names/Held), the interface cloned out of the lock so loads do not hold it, and the SAVE lock inside write_atomically - the sharding only decides which of the sixteen libraries a name is looked up in.

  • Same names, same descriptions, same lookups: a pipeline is created, stored and found in one deterministic shard. - a_rejected_blob_gives_an_empty_library still passes, and the existing name test is unchanged. - One-time cost on upgrade: the old single host-pipelines.bin is no longer read, so the first run after this rebuilds the library once (and the old file can be deleted). cargo test --workspace --locked, both clippy configurations with -D warnings, cargo xtask policy. No game data used.

Correction, from aycow's control

Sharding wins only while few shards are dirty. aycow measured a 16 MiB synthetic payload through the same publisher:

dirty shards sharded whole file
1 1.56 ms 8.21 ms
4 5.59 ms 7.85 ms
16 24.15 ms 8.55 ms

So the first run after this lands - every shard new, i.e. all sixteen dirty - is worse than one blob, because each shard pays its own serialisation. Every save after that, in the steady state of one to four dirty shards, is 1.4x to 5.3x better. Native PSO serialisation is unmeasured in both directions.

Two persistence holes aycow found are fixed in the current head (9c60694): a shard's dirty count is cleared only after its file is published (a failed write retries instead of losing the pipelines), and one SAVING lock covers serialisation and publication together (two saves cannot publish an older snapshot over a newer one).

What it gives (to decide the merge): a save writes only the library shards that gained pipelines, instead of the whole 926 MB (1.7 GB on NVIDIA) every 20 s while holding the library's lock; a cache made before the split is still read, and what it holds moves into the shards as it is used.

State: MERGEABLE, CI check green, rebased onto today's main (f3578e3).

Risk: the library format moves from one file to 16; a rejected blob still gives an empty shard, and a failed write leaves the shard dirty for the next save.

**@⁠pes7** on GitHub · 2026-11-24 20:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653) `pes7:perf/pipeline-library-shards` → `main` · +261 −131 · 1 files · 3 commits · open **Every save writes the whole 600 MB pipeline library.** The host can only serialise a library whole, so splitting it into shards - one file each, chosen by the pipeline's name hash - lets a save write only the shards that gained pipelines. `owner`: `GPU-PIPELINE-LIBRARY-SIZE` in #1633. ## The problem, as the task states it The host pipeline library is one serialised blob, **over 600 MB in the world**, and `ID3D12PipelineLibrary::Serialize` has no per-entry form: the whole thing is copied into one buffer and written, every time a save happens (every 20 s while new pipelines are still being made, and at shutdown). `Serialize` itself copies 600 MB, then `write_atomically` writes 600 MB to a temp file and renames it. ## What changes The library becomes **16 shards**, `host-pipelines.00.bin` ... `host-pipelines.15.bin`: - `shard_of(name)` hashes the pipeline's name (already a hash of its whole host description) and picks a shard. Stable across runs, so a pipeline always lands in the same file - that is what makes a partial save correct. - `libraries()` opens every shard from its own file; a missing file is an empty library, a rejected blob is an empty library, exactly as the single file behaved. - `pipeline()` looks a pipeline up in **its own shard only** (no extra lookups: the routing is deterministic) and stores it there on a miss. The per-shard mutex also means pipeline creation contends 16 ways instead of one. - `save()` serialises and writes only the shards with `added > 0`, and writes the early list only when it changed. The log line reports `shards = K, bytes = B` instead of one blob's size. A save that adds pipelines spread over K shards writes `K/16` of the library instead of all of it. In the steady state a run touches one or two shards, so a 600 MB write becomes roughly 40-75 MB. ## Measured What I can measure here, without the title: - `a_pipeline_lands_in_one_shard_and_the_shards_spread`: the same name always maps to the same shard, and 4 096 names reach all 16 shards, so a save is a fraction rather than all or nothing. - The bytes a save writes are printed by the existing log line (`host pipeline library saved`), which now carries `shards` and `bytes` - so the first run in the world gives the number directly: the old line reported `bytes тХд╨ТтХи╨йтХи╨и 600 MB`, the new one reports the sum of the changed shards. Not measured: the wall time of a save in the world. It is `Serialize` + one write per changed shard, so it scales with the same fraction. ## Correctness Rewritten onto `main` `940d32f`, where this module gained the pre-build's `prebuilt` list. That list is now one file per shard (`prebuilt-pipelines.NN.txt`), each tagged with its own shard's bytes: a single list tagged with the whole library would be invalidated by any shard's write, which would undo the point of sharding. The concurrency added upstream at the same time is kept as it is: one thread at a time per pipeline name (`Names`/`Held`), the interface cloned out of the lock so loads do not hold it, and the `SAVE` lock inside `write_atomically` - the sharding only decides which of the sixteen libraries a name is looked up in. - Same names, same descriptions, same lookups: a pipeline is created, stored and found in one deterministic shard. - `a_rejected_blob_gives_an_empty_library` still passes, and the existing name test is unchanged. - One-time cost on upgrade: the old single `host-pipelines.bin` is no longer read, so the first run after this rebuilds the library once (and the old file can be deleted). `cargo test --workspace --locked`, both clippy configurations with `-D warnings`, `cargo xtask policy`. No game data used. ## Correction, from aycow's control Sharding wins only while few shards are dirty. aycow measured a 16 MiB synthetic payload through the same publisher: | dirty shards | sharded | whole file | |---:|---:|---:| | 1 | 1.56 ms | 8.21 ms | | 4 | 5.59 ms | 7.85 ms | | 16 | **24.15 ms** | **8.55 ms** | So the first run after this lands - every shard new, i.e. all sixteen dirty - is **worse** than one blob, because each shard pays its own serialisation. Every save after that, in the steady state of one to four dirty shards, is 1.4x to 5.3x better. Native PSO serialisation is unmeasured in both directions. Two persistence holes aycow found are fixed in the current head (`9c60694`): a shard's dirty count is cleared only after its file is published (a failed write retries instead of losing the pipelines), and one `SAVING` lock covers serialisation and publication together (two saves cannot publish an older snapshot over a newer one). --- **What it gives (to decide the merge):** a save writes only the library shards that gained pipelines, instead of the whole 926 MB (1.7 GB on NVIDIA) every 20 s while holding the library's lock; a cache made before the split is still read, and what it holds moves into the shards as it is used. **State:** MERGEABLE, CI `check` green, rebased onto today's `main` (`f3578e3`). **Risk:** the library format moves from one file to 16; a rejected blob still gives an empty shard, and a failed write leaves the shard dirty for the next save.
The host serialises a whole pipeline library and nothing less, so every save
wrote all of it: 926 MB here, 1.7 GB on NVIDIA (`host pipeline library saved
bytes=970507898`), every 20 seconds, and a save holds the library's lock for
as long as it serialises.

The library is kept in 16 files now, `host-pipelines.NN.bin`, one per hash of
the pipeline's name (`shard_of`). The name is a hash already, so a pipeline
always lands in the same shard across runs, and a save serialises and writes
only the shards that gained pipelines since the last one (`Library::dirty`).
A shard is left dirty if its write fails, so the next save writes it. The
early list stays one file and is written when it changed (or on a shutdown
save, which passes `now`).

A cache made before the shards is not thrown away: `host-pipelines.bin` is
still read (never written), and a pipeline found there is stored into its
shard, so a warm run fills the shards and the old file can then be deleted.
The log says so once, and the load line now reports the shards and their
total bytes instead of one file.

Measured before this (retail title, `O:\tmp\victory-cache\pipelines`):

    host pipeline library loaded bytes=970507898 ms=57    (926 MB, 27 160 pipelines)

with a save every 20 s writing the same 926 MB back; a run that made three
pipelines paid it. After the split, the same save writes one shard of that
structure (a sixteenth of the names) plus the early list.

Rebased onto today's `main`: `write_atomically`, `zeroed` (a 1.7 GB
allocation is not infallible), `Shared { loads, state }` (loads take no lock)
and the pre-build's list tagged with the translator hash are all kept; the
shard structure is applied on top, and `pipeline`'s `load` is `Fn` rather
than `FnOnce` because a name may now be tried in its shard and in the
one-file library.

cargo test --release -p victory-gpu (229 tests, one new: names spread over
the shards and keep their shard); clippy clean; both `victory`
configurations build.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:40:00 +00:00
Author
Owner

@⁠aycow on GitHub · 2026-11-24 20:57 UTC · original

Independent checks on exact 88b678b found two persistence concerns. Dirty flags are cleared before successful file publication, and its save-order lock does not cover serialization and publication together. The former can lose retries and the latter allows an older complete snapshot to replace a newer one. #1660's unique temporary paths address a separate failure: the unchanged #1653 writer failed 35/256 concurrent synthetic replacements on Windows, while the #1660 writer passed 256/256.

For a 16 MiB synthetic serialized-payload control using the same atomic publisher in both modes, one dirty shard took median 1.56 ms versus 8.21 ms whole-file, four took 5.59 ms versus 7.85 ms, and all 16 took 24.15 ms versus 8.55 ms. These timings isolate payload preparation and publication. Native PSO serialization and title performance are unmeasured. I also reran all seven #1651 tests, including a real WARP PSO cache round-trip. Those comparisons may help your save-order and fallback choices.

AI-assisted using Codex.

**@⁠aycow** on GitHub · 2026-11-24 20:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7144276466) Independent checks on exact 88b678b found two persistence concerns. Dirty flags are cleared before successful file publication, and its save-order lock does not cover serialization and publication together. The former can lose retries and the latter allows an older complete snapshot to replace a newer one. #1660's unique temporary paths address a separate failure: the unchanged #1653 writer failed 35/256 concurrent synthetic replacements on Windows, while the #1660 writer passed 256/256. For a 16 MiB synthetic serialized-payload control using the same atomic publisher in both modes, one dirty shard took median 1.56 ms versus 8.21 ms whole-file, four took 5.59 ms versus 7.85 ms, and all 16 took 24.15 ms versus 8.55 ms. These timings isolate payload preparation and publication. Native PSO serialization and title performance are unmeasured. I also reran all seven #1651 tests, including a real WARP PSO cache round-trip. Those comparisons may help your save-order and fallback choices. AI-assisted using Codex.
Author
Owner

@⁠pes7 on GitHub · 2026-11-24 21:05 UTC · original

Thanks - both are real, and fixed in f26e6ae:

  • added is cleared only after write_atomically succeeded, by the count that was serialised, so a failed write leaves the shard dirty and the next save retries it (and pipelines stored while the write ran stay dirty too).
  • a SAVING mutex now spans serialisation and publication, so two saves cannot interleave and publish an older snapshot over a newer one.

Your control also changes the claim in this description, so I have corrected it rather than leaving "K/16" standing as if it held everywhere:

dirty shards sharded whole file
1 1.56 ms 8.21 ms
4 5.59 ms 7.85 ms
16 24.15 ms 8.55 ms

So sharding wins in the steady state - one to four dirty shards - and loses when every shard is dirty, which is exactly the first world load, because each shard pays its own serialisation. Anyone reading this should expect the first run after the upgrade to be worse and every later save to be better; the sentence in the description now says that.

On the #1660 point: each shard publishes through its own temporary path (host-pipelines.NN.tmp) and the SAVING lock serialises writers inside the process, so the fixed-path concurrent-replacement failure you measured should not reach this code. If you can point your 256-replacement test at this branch it would settle it rather than my assuming it - I would rather have the number.

**@⁠pes7** on GitHub · 2026-11-24 21:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7144456059) Thanks - both are real, and fixed in `f26e6ae`: - `added` is cleared only after `write_atomically` succeeded, by the count that was serialised, so a failed write leaves the shard dirty and the next save retries it (and pipelines stored while the write ran stay dirty too). - a `SAVING` mutex now spans serialisation and publication, so two saves cannot interleave and publish an older snapshot over a newer one. Your control also changes the claim in this description, so I have corrected it rather than leaving "K/16" standing as if it held everywhere: | dirty shards | sharded | whole file | |---:|---:|---:| | 1 | 1.56 ms | 8.21 ms | | 4 | 5.59 ms | 7.85 ms | | 16 | **24.15 ms** | **8.55 ms** | So sharding wins in the steady state - one to four dirty shards - and **loses when every shard is dirty**, which is exactly the first world load, because each shard pays its own serialisation. Anyone reading this should expect the first run after the upgrade to be worse and every later save to be better; the sentence in the description now says that. On the `#1660` point: each shard publishes through its own temporary path (`host-pipelines.NN.tmp`) and the `SAVING` lock serialises writers inside the process, so the fixed-path concurrent-replacement failure you measured should not reach this code. If you can point your 256-replacement test at this branch it would settle it rather than my assuming it - I would rather have the number.
Author
Owner

@⁠pes7 on GitHub · 2026-11-24 22:03 UTC · original

@⁠aycow - your two findings are still addressed, and the branch is rewritten on today's main (70564ae), which changed this module underneath it (prebuilt lists keyed by a tag of the library bytes, Used split into before/now). The rebase conflicted in seven places, so rather than resolving a three-way merge I re-applied the sharding to the current file; head is 1e79f14.

Both of your concerns, on the new code:

  • a shard's added counter and prebuilt_changed flag are cleared only after write_atomically returned Ok, by what was serialised (l.added -= added; l.prebuilt_changed &= !marked;), so a failed write leaves the shard dirty for the next save and a store during the write keeps it dirty;
  • SAVING is held across serialising and publishing every shard, so two saves cannot interleave and publish an older complete snapshot over a newer one.

Two changes from the revision you reviewed, both because the file moved:

  • the pre-build's list is now one file per shard (prebuilt-pipelines.NN.txt), each tagged with its own shard's bytes - a single list tagged with the whole library would be invalidated by any shard's write, which would undo the point of sharding;
  • the temporary path per shard (host-pipelines.NN.tmp) stays as it was.

Your control still decides the shape of the claim, and the description now says it plainly: 1.56 / 5.59 / 24.15 ms for 1 / 4 / 16 dirty shards against 8.21 / 7.85 / 8.55 ms for one blob, so sharding wins in the steady state and loses on the first save after the upgrade, when every shard is dirty.

cargo test --workspace --locked (79 tests in this crate, including a new one that a corpus of names spreads over all SHARDS), both clippy configurations with -D warnings, cargo xtask policy. Native PSO serialisation and title performance are still unmeasured - no game copy here.

**@⁠pes7** on GitHub · 2026-11-24 22:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7145753011) @⁠aycow - your two findings are still addressed, and the branch is rewritten on today's `main` (`70564ae`), which changed this module underneath it (`prebuilt` lists keyed by a tag of the library bytes, `Used` split into before/now). The rebase conflicted in seven places, so rather than resolving a three-way merge I re-applied the sharding to the current file; head is `1e79f14`. Both of your concerns, on the new code: - a shard's `added` counter and `prebuilt_changed` flag are cleared **only after** `write_atomically` returned `Ok`, by what was serialised (`l.added -= added; l.prebuilt_changed &= !marked;`), so a failed write leaves the shard dirty for the next save and a store during the write keeps it dirty; - `SAVING` is held across serialising **and** publishing every shard, so two saves cannot interleave and publish an older complete snapshot over a newer one. Two changes from the revision you reviewed, both because the file moved: - the pre-build's list is now one file per shard (`prebuilt-pipelines.NN.txt`), each tagged with its own shard's bytes - a single list tagged with the whole library would be invalidated by any shard's write, which would undo the point of sharding; - the temporary path per shard (`host-pipelines.NN.tmp`) stays as it was. Your control still decides the shape of the claim, and the description now says it plainly: 1.56 / 5.59 / 24.15 ms for 1 / 4 / 16 dirty shards against 8.21 / 7.85 / 8.55 ms for one blob, so sharding wins in the steady state and **loses on the first save after the upgrade**, when every shard is dirty. `cargo test --workspace --locked` (79 tests in this crate, including a new one that a corpus of names spreads over all `SHARDS`), both clippy configurations with `-D warnings`, `cargo xtask policy`. Native PSO serialisation and title performance are still unmeasured - no game copy here.
Author
Owner

@⁠pes7 on GitHub · 2026-11-24 22:41 UTC · original

@⁠catminou4 - good catch, and they do not compose: #1651 (avt0m4t48) and this one are two takes on the same change, both splitting pipeline/library.rs into sixteen files and both writing only the shards that gained pipelines. Only one can land. The differences, so the owner can pick:

#1651 this one
shard chosen by first hex digit of the content hash shard_of(name) over the name's bytes (same idea, one small function)
existing host-pipelines.bin kept, misses fall back to it and promote into a shard, so warm legacy entries survive not read: one rebuild after the upgrade, then it can be deleted
pre-build's list not mentioned per shard, tagged with that shard's bytes
state CONFLICTING, +506/-95, new library/disk.rs, and it lists #275/#1041/#640 conflicts in this file MERGEABLE, +146/-65, one file
verified on Linux tests + a Windows WARP run of the real cache round-trip Windows hardware, full workspace + a shard-spread test

So: #1651 is the more thorough one (legacy fallback, cross-process note, a dedicated module), mine is the smaller one that applies today. I am not going to argue for mine - if you would rather have the legacy fallback, take #1651 and say so, and I will close this one the same way I closed #1556 and #1656 when main had moved past them.

What I would keep from this one either way, since #1651's description does not mention it: the per-shard pre-build list. A single list tagged with the whole library is invalidated by any shard's write, so after sharding it would be rewritten almost every save and would undo part of the win. It is a small change on top of whichever version lands.

**@⁠pes7** on GitHub · 2026-11-24 22:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7146521858) @⁠catminou4 - good catch, and they do **not** compose: #1651 (`avt0m4t48`) and this one are two takes on the same change, both splitting `pipeline/library.rs` into sixteen files and both writing only the shards that gained pipelines. Only one can land. The differences, so the owner can pick: | | #1651 | this one | |---|---|---| | shard chosen by | first hex digit of the content hash | `shard_of(name)` over the name's bytes (same idea, one small function) | | existing `host-pipelines.bin` | kept, misses fall back to it and promote into a shard, so warm legacy entries survive | not read: one rebuild after the upgrade, then it can be deleted | | pre-build's list | not mentioned | per shard, tagged with that shard's bytes | | state | `CONFLICTING`, +506/-95, new `library/disk.rs`, and it lists #275/#1041/#640 conflicts in this file | `MERGEABLE`, +146/-65, one file | | verified on | Linux tests + a Windows WARP run of the real cache round-trip | Windows hardware, full workspace + a shard-spread test | So: #1651 is the more thorough one (legacy fallback, cross-process note, a dedicated module), mine is the smaller one that applies today. I am not going to argue for mine - if you would rather have the legacy fallback, take #1651 and say so, and I will close this one the same way I closed #1556 and #1656 when `main` had moved past them. What I would keep from this one either way, since #1651's description does not mention it: the per-shard pre-build list. A single list tagged with the whole library is invalidated by any shard's write, so after sharding it would be rewritten almost every save and would undo part of the win. It is a small change on top of whichever version lands.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:33 UTC · original · edited 2026-11-26 00:25 UTC

Automated triage for the maintainers.

Needs work. The re-application onto current main (crates/victory-gpu/src/pipeline/library.rs) keeps Shared, zeroed and write_atomically, and it adds a read-only fallback to the one-file library, which is a good idea. But it loses the fix this PR had at 013da61:

  • Pipelines stored during a save are lost from the dirty count again. save serialises a shard under its lock (serialise), releases the lock to write the file, and then sets l.added = 0; l.prebuilt_changed = false; unconditionally. A pipeline stored, or a pre-build key noted, in that window is cleared without being in the published bytes. Unless that shard gains another pipeline, it is never written, not even at the shutdown save. This is the race andrewpozdnakov7-jpg reproduced. Please acknowledge only what was serialised (subtract the added count you took, and compare prebuilt.len() with the snapshot), and bring back his save_shard regression test, which is also no longer in the branch.
  • Minor: USED_CHANGED is swapped to false before the early list is written. If that write fails, the change is not retried. main had the same shape, but the generation check you described for 013da61 is not in this head either.
  • Two smaller points. The legacy library stays mapped in memory for the whole run (926 MB in your measurement) alongside the shards; please say whether that matters on smaller cards. If any shard fails to open, libraries() returns None with no warning, where main logged "no host pipeline library".

The choice between this PR and #1651 (the same sharding) is still open for the maintainers. Push the fix and this will be reviewed again.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7149684223) · edited 2026-11-26 00:25 UTC <!-- victory-triage v1 head=3b1cda6b26aa08a857953ac7ff0659bcec758f8f verdict=needs-work at=2026-11-26T00:25:50Z --> Automated triage for the maintainers. **Needs work.** The re-application onto current `main` (`crates/victory-gpu/src/pipeline/library.rs`) keeps `Shared`, `zeroed` and `write_atomically`, and it adds a read-only fallback to the one-file library, which is a good idea. But it loses the fix this PR had at `013da61`: - **Pipelines stored during a save are lost from the dirty count again.** `save` serialises a shard under its lock (`serialise`), releases the lock to write the file, and then sets `l.added = 0; l.prebuilt_changed = false;` unconditionally. A pipeline stored, or a pre-build key noted, in that window is cleared without being in the published bytes. Unless that shard gains another pipeline, it is never written, not even at the shutdown save. This is the race andrewpozdnakov7-jpg reproduced. Please acknowledge only what was serialised (subtract the `added` count you took, and compare `prebuilt.len()` with the snapshot), and bring back his `save_shard` regression test, which is also no longer in the branch. - Minor: `USED_CHANGED` is swapped to false before the early list is written. If that write fails, the change is not retried. `main` had the same shape, but the generation check you described for `013da61` is not in this head either. - Two smaller points. The legacy library stays mapped in memory for the whole run (926 MB in your measurement) alongside the shards; please say whether that matters on smaller cards. If any shard fails to open, `libraries()` returns `None` with no warning, where `main` logged "no host pipeline library". The choice between this PR and #1651 (the same sharding) is still open for the maintainers. Push the fix and this will be reviewed again. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:04 UTC · original

I reproduced a remaining publication race at 1e79f14. The shard snapshots its prebuilt keys and releases the mutex to write the files. If a new key is recorded during that write while the dirty flag was already true, acknowledging the first snapshot clears the flag for the new key too. A second save can then skip that shard even though its prebuilt file is missing the new key.

Fix and regression on the exact PR head. It compares the current number of prebuilt keys with the snapshot count after both files publish. The test inserts a key at the start of the write, checks that the first sidecar contains just the original key, then verifies that the second save writes both.

On native Windows/WARP the same test failed before the fix and passed after it. The GPU library suite went from 81 passed, 2 failed, 1 ignored to 82 passed, 1 failed, 1 ignored. The placed-view texture-format test failed in both runs. Clippy passed with diagnostics and warnings denied.

If you fold the fix or test into your commit, please retain this trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic data only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 08:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7156567191) I reproduced a remaining publication race at **1e79f14**. The shard snapshots its prebuilt keys and releases the mutex to write the files. If a new key is recorded during that write while the dirty flag was already true, acknowledging the first snapshot clears the flag for the new key too. A second save can then skip that shard even though its prebuilt file is missing the new key. [Fix and regression on the exact PR head](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3e03b3ea5ee11b0d0906a9045b6f602ce9e40f11). It compares the current number of prebuilt keys with the snapshot count after both files publish. The test inserts a key at the start of the write, checks that the first sidecar contains just the original key, then verifies that the second save writes both. On native Windows/WARP the same test failed before the fix and passed after it. The GPU library suite went from 81 passed, 2 failed, 1 ignored to 82 passed, 1 failed, 1 ignored. The placed-view texture-format test failed in both runs. Clippy passed with diagnostics and warnings denied. If you fold the fix or test into your commit, please retain this trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic data only.
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 12:12 UTC · original

Re-applied onto main 940d32f, which changed this file again: Names/Held (one thread at a time per name) and a SAVE lock inside write_atomically. Head is 9c60694; the diff is still one file.

Two conflicts, both resolved by keeping your code and routing it through a shard:

let _held = NAMES.hold(name);
// The interface alone under the lock: loads take up to seconds. Its
// blob lives as long as the library, which is never dropped.
let loads = libraries[shard_of(name)]
    .lock()
    .unwrap_or_else(|e| e.into_inner())
    .library
    .clone();

so the per-name hold, the clone-out-of-the-lock trick and the SAVE lock all still do what you made them do; the only change is which of the sixteen libraries a name is looked up in. libraries() opens one file per shard and save() serialises and writes only the shards that gained pipelines, clearing added by what was serialised after the bytes are published.

cargo test --workspace --locked passes, including your three new concurrency tests (different_names_are_held_at_the_same_time, one_name_is_held_by_one_thread_at_a_time, pipelines_load_on_many_threads_at_once) and the new one here (a_pipeline_lands_in_one_shard_and_the_shards_spread). Both clippy configurations with -D warnings, cargo xtask policy.

Still the open question from the description: #1651 is the same change from another author, so this one only needs a decision, not more work.

**@⁠pes7** on GitHub · 2026-11-25 12:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7162072528) Re-applied onto `main` `940d32f`, which changed this file again: `Names`/`Held` (one thread at a time per name) and a `SAVE` lock inside `write_atomically`. Head is `9c60694`; the diff is still one file. Two conflicts, both resolved by keeping your code and routing it through a shard: ```rust let _held = NAMES.hold(name); // The interface alone under the lock: loads take up to seconds. Its // blob lives as long as the library, which is never dropped. let loads = libraries[shard_of(name)] .lock() .unwrap_or_else(|e| e.into_inner()) .library .clone(); ``` so the per-name hold, the clone-out-of-the-lock trick and the `SAVE` lock all still do what you made them do; the only change is which of the sixteen libraries a name is looked up in. `libraries()` opens one file per shard and `save()` serialises and writes only the shards that gained pipelines, clearing `added` by what was serialised after the bytes are published. `cargo test --workspace --locked` passes, including your three new concurrency tests (`different_names_are_held_at_the_same_time`, `one_name_is_held_by_one_thread_at_a_time`, `pipelines_load_on_many_threads_at_once`) and the new one here (`a_pipeline_lands_in_one_shard_and_the_shards_spread`). Both clippy configurations with `-D warnings`, `cargo xtask policy`. Still the open question from the description: #1651 is the same change from another author, so this one only needs a decision, not more work.
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 12:49 UTC · original

@⁠andrewpozdnakov7-jpg @⁠Marvisak - taken, with the trailer, at 013da61.

The race was real and I had introduced it rewriting save() for shards: acknowledging "was the flag set when I snapshotted" instead of "is what I published still everything". Fixed the way you wrote it - the shard stays dirty when its key count changed while the write ran:

// Acknowledge only successfully published changes. Updates that arrived
// while the write ran must stay dirty for the next save.
let mut l = library.lock().unwrap_or_else(|e| e.into_inner());
l.added -= added;
l.prebuilt_changed = l.prebuilt.len() != prebuilt_count;

Your save_shard(.., write) split is what makes it testable, so I kept it verbatim; your test is in the PR as sent. I also checked it can fail: with the old check put back it panics on assert!(second.is_some(), ...) and with the fix it passes, so it is a regression test and not just documentation.

USED_CHANGED had the same shape, as the triage said, so the early list is acknowledged the same way - note_used bumps a generation counter and a save clears the flag only if the generation it wrote is still current. Missing that one only costs a rewrite of the early list, not a lost pipeline, but it is the same bug.

cargo test --workspace --locked (10 library tests, including yours), both clippy configurations with -D warnings, cargo xtask policy.

**@⁠pes7** on GitHub · 2026-11-25 12:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7162918744) @⁠andrewpozdnakov7-jpg @⁠Marvisak - taken, with the trailer, at `013da61`. The race was real and I had introduced it rewriting `save()` for shards: acknowledging "was the flag set when I snapshotted" instead of "is what I published still everything". Fixed the way you wrote it - the shard stays dirty when its key count changed while the write ran: ```rust // Acknowledge only successfully published changes. Updates that arrived // while the write ran must stay dirty for the next save. let mut l = library.lock().unwrap_or_else(|e| e.into_inner()); l.added -= added; l.prebuilt_changed = l.prebuilt.len() != prebuilt_count; ``` Your `save_shard(.., write)` split is what makes it testable, so I kept it verbatim; your test is in the PR as sent. I also checked it can fail: with the old check put back it panics on `assert!(second.is_some(), ...)` and with the fix it passes, so it is a regression test and not just documentation. `USED_CHANGED` had the same shape, as the triage said, so the early list is acknowledged the same way - `note_used` bumps a generation counter and a save clears the flag only if the generation it wrote is still current. Missing that one only costs a rewrite of the early list, not a lost pipeline, but it is the same bug. `cargo test --workspace --locked` (10 library tests, including yours), both clippy configurations with `-D warnings`, `cargo xtask policy`.
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 17:09 UTC · original

Measured on the title, and it is the case this PR was written for - with a bigger number than the description had.

The Xbox build's own pipelines, warmed by translate --cache --pipelines: 27 160 pipelines, and the library they make is 970 507 898 bytes (926 MB), not the 600 MB the README estimates. Every pipeline is ~28 KB of serialised state on average.

Two lines from one run --execute, two seconds apart:

host pipeline library loaded bytes=970507898 ms=57
host pipeline library saved  bytes=970507898 early=1 made=0 loaded=1 ...

The load is cheap (57 ms: the driver maps it). The save is not: the whole 926 MB was written again with made=0 - no pipeline was added, the pre-build's early list changed by one entry, and the writer had no way to write less than the whole blob. That is the 20-second save on main doing 926 MB of I/O for nothing, at every start and every time the early list moves.

With the shards in this PR that save writes no library bytes at all: every shard has added == 0 && !prebuilt_changed, so save_shard returns None for all sixteen and only the early list is published. The 926 MB is not rewritten; the same run writes a few kilobytes.

The rest of the launch, for context: the first frame still takes 21 s of preparing, but the shader cache is not what it waits for (hits=7 misses=0, the warm-up does reach the cache the run reads), and the copies in it are 25 ms for 91 MB - so the wait is pipeline making and the first title-memory snapshots, not translation and not this.

Caveat unchanged from the description: the first save after the upgrade is still the slow one (all sixteen shards dirty), and the native PSO serialisation itself is not what these numbers measure - they are the payload and the I/O around it.

**@⁠pes7** on GitHub · 2026-11-25 17:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7169083880) Measured on the title, and it is the case this PR was written for - with a bigger number than the description had. The Xbox build's own pipelines, warmed by `translate --cache --pipelines`: **27 160 pipelines**, and the library they make is **970 507 898 bytes (926 MB)**, not the 600 MB the README estimates. Every pipeline is ~28 KB of serialised state on average. Two lines from one `run --execute`, two seconds apart: host pipeline library loaded bytes=970507898 ms=57 host pipeline library saved bytes=970507898 early=1 made=0 loaded=1 ... The load is cheap (57 ms: the driver maps it). The save is not: **the whole 926 MB was written again with `made=0`** - no pipeline was added, the pre-build's early list changed by one entry, and the writer had no way to write less than the whole blob. That is the 20-second save on `main` doing 926 MB of I/O for nothing, at every start and every time the early list moves. With the shards in this PR that save writes no library bytes at all: every shard has `added == 0 && !prebuilt_changed`, so `save_shard` returns `None` for all sixteen and only the early list is published. The 926 MB is not rewritten; the same run writes a few kilobytes. The rest of the launch, for context: the first frame still takes 21 s of `preparing`, but the shader cache is not what it waits for (`hits=7 misses=0`, the warm-up does reach the cache the run reads), and the copies in it are 25 ms for 91 MB - so the wait is pipeline making and the first title-memory snapshots, not translation and not this. Caveat unchanged from the description: the first save after the upgrade is still the slow one (all sixteen shards dirty), and the native PSO serialisation itself is not what these numbers measure - they are the payload and the I/O around it.
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 18:26 UTC · original

A device removal costs more than the session: it takes the pipeline library with it, and the next run starts from nothing.

Measured on this machine just now. The library was 970 507 898 bytes (926 MB) and loaded in 57-73 ms. After the removal that every run ends in (a TDR, #1633), the next run says:

host pipeline library loaded bytes=626800 ms=...

i.e. the blob is 627 KB - the write of the new library at that start-up never finished, and what is on disk is a fragment. From there, every pipeline the title needs is translated and compiled again: the warm-up that took translate --cache --pipelines 7.5 minutes for 27 160 of them (shaders_cached=52496 shaders_translated=0 on a warm one), and made=23057 on a cold one.

Two things about that for this PR:

  • the shards here are what makes it survivable. A shard is written atomically on its own, so a removal mid-save leaves the shards that were written and the ones that were not, not a truncated whole. The USED_GENERATION / SAVING bookkeeping that is already in the branch is exactly the "which of these are from the crash" question.
  • it is also the honest answer to "how much does #1653 save": on a healthy start, 926 MB of I/O with made=0; after a removal, the entire library is rebuilt, which is minutes rather than seconds.

If a "the library on disk is smaller than what the load reported" line is cheap (bytes at the load, bytes at the save), that would name this in one line instead of a 627 KB number noticed by accident - the crash path never reaches the save that would have written the full blob, so nothing in the log says so today.

**@⁠pes7** on GitHub · 2026-11-25 18:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7170912731) A device removal costs more than the session: it takes the pipeline library with it, and the next run starts from nothing. Measured on this machine just now. The library was 970 507 898 bytes (926 MB) and loaded in 57-73 ms. After the removal that every run ends in (a TDR, #1633), the next run says: host pipeline library loaded bytes=626800 ms=... i.e. the blob is 627 KB - the write of the new library at that start-up never finished, and what is on disk is a fragment. From there, every pipeline the title needs is translated and compiled again: the warm-up that took `translate --cache --pipelines` 7.5 minutes for 27 160 of them (`shaders_cached=52496 shaders_translated=0` on a warm one), and `made=23057` on a cold one. Two things about that for this PR: * the shards here are what makes it survivable. A shard is written atomically on its own, so a removal mid-save leaves the shards that were written and the ones that were not, not a truncated whole. The `USED_GENERATION` / `SAVING` bookkeeping that is already in the branch is exactly the "which of these are from the crash" question. * it is also the honest answer to "how much does #1653 save": on a healthy start, 926 MB of I/O with `made=0`; after a removal, the entire library is rebuilt, which is minutes rather than seconds. If a "the library on disk is smaller than what the load reported" line is cheap (`bytes` at the load, `bytes` at the save), that would name this in one line instead of a 627 KB number noticed by accident - the crash path never reaches the save that would have written the full blob, so nothing in the log says so today.
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 18:33 UTC · original

Correction to what I wrote above, after reading library::save: the 612 KB is not a truncated write. write_atomically (temp file, then rename) is already there and correct. The small number is a legitimate library that is small: the pipelines in it are named after the shaders they were made from, so a translator change gives every pipeline a new name, the old 926 MB library holds nothing the run can load, and the save writes GetSerializedSize() of what this run made (612 KB) over the file. Atomic, and still a 926 MB / 7.5 minute cache destroyed.

The fix for that is #2706: the library lives in dir/<SOURCE_HASH>, two newest kept, so a run writes only its own directory and bisecting between two builds finds both libraries warm. Measured: run 1 saved bytes=3086 then 7488 with no load; run 2 loaded bytes=7488 ms=0, in pipelines/94ef170ae2f5e8da/.

So the shards in this PR are still right for the "926 MB per save" cost, and no longer need to carry the crash-durability argument - the crash durability is real (Added accumulations are lost with the process, not the file).

**@⁠pes7** on GitHub · 2026-11-25 18:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7171081007) Correction to what I wrote above, after reading `library::save`: **the 612 KB is not a truncated write.** `write_atomically` (temp file, then rename) is already there and correct. The small number is a *legitimate* library that is small: the pipelines in it are named after the shaders they were made from, so a translator change gives every pipeline a new name, the old 926 MB library holds nothing the run can load, and the save writes `GetSerializedSize()` of what this run made (612 KB) over the file. Atomic, and still a 926 MB / 7.5 minute cache destroyed. The fix for that is #2706: the library lives in `dir/<SOURCE_HASH>`, two newest kept, so a run writes only its own directory and bisecting between two builds finds both libraries warm. Measured: run 1 `saved bytes=3086` then `7488` with no load; run 2 `loaded bytes=7488 ms=0`, in `pipelines/94ef170ae2f5e8da/`. So the shards in this PR are still right for the "926 MB per save" cost, and no longer need to carry the crash-durability argument - the crash durability is real (`Added` accumulations are lost with the process, not the file).
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 22:27 UTC · original

Status of this branch against today's main (f3578e3), and what porting it needs.

main reworked the two ends of this file since the branch was written: write_atomically (a save writes a temporary and renames), tag() + prebuilt-pipelines.txt (the pre-build's list holds the translator hash, so a list from another build is ignored), zeroed (a library of 1.7 GB on NVIDIA is not an infallible allocation), the USED/created counters, and library() now hands out a Shared { loads, state } so a pipeline load does not take the library's lock.

The shards themselves are the part that is not in main: nothing there writes only what changed, so every save still serialises the whole library and writes it whole (926 MB here, host pipeline library saved bytes=... every 20 s; on NVIDIA closer to 1.7 GB).

Porting is therefore not a rebase but a re-application of the shard structure onto Shared:

  • libraries() -> &'static [Shared; SHARDS], one shard file each (host-pipelines.NN.bin, prebuilt-pipelines.NN.txt), opened per shard;
  • shard_of(name) unchanged (a hash of the pipeline name, so a pipeline always lands in the same file);
  • pipeline, prebuilt, note_prebuilt pick the shard;
  • save serialises and writes only the shards that gained pipelines (USED_CHANGED/early list once, as now), through zeroed + write_atomically.

Two things to settle while porting: a StorePipeline into a shard that the host refuses (it stays dirty for the next save), and the early list, which is per library rather than per shard - it can stay one file.

Also worth saying: #2706 (a library per translation) removes part of the reason this was written - a translator edit no longer overwrites another build's library - so the remaining cost this PR addresses is the write volume of a run's own saves. If the maintainers would rather have the smaller change first, "save only after N new pipelines or on exit" is a few lines and gets most of the I/O, but it loses the crash-safety of a periodic save; the shard design keeps both.

I have not ported it here: 200 lines through a file whose save/load changed twice since, without a run to check the library still loads, is not something to push tonight. Happy to do it as the next piece of work if it is wanted.

**@⁠pes7** on GitHub · 2026-11-25 22:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7176390895) Status of this branch against today's `main` (`f3578e3`), and what porting it needs. `main` reworked the two ends of this file since the branch was written: `write_atomically` (a save writes a temporary and renames), `tag()` + `prebuilt-pipelines.txt` (the pre-build's list holds the translator hash, so a list from another build is ignored), `zeroed` (a library of 1.7 GB on NVIDIA is not an infallible allocation), the USED/created counters, and `library()` now hands out a `Shared { loads, state }` so a pipeline load does not take the library's lock. The shards themselves are the part that is *not* in `main`: nothing there writes only what changed, so every save still serialises the whole library and writes it whole (926 MB here, `host pipeline library saved bytes=...` every 20 s; on NVIDIA closer to 1.7 GB). Porting is therefore not a rebase but a re-application of the shard structure onto `Shared`: - `libraries() -> &'static [Shared; SHARDS]`, one shard file each (`host-pipelines.NN.bin`, `prebuilt-pipelines.NN.txt`), opened per shard; - `shard_of(name)` unchanged (a hash of the pipeline name, so a pipeline always lands in the same file); - `pipeline`, `prebuilt`, `note_prebuilt` pick the shard; - `save` serialises and writes only the shards that gained pipelines (`USED_CHANGED`/early list once, as now), through `zeroed` + `write_atomically`. Two things to settle while porting: a `StorePipeline` into a shard that the host refuses (it stays dirty for the next save), and the early list, which is per library rather than per shard - it can stay one file. Also worth saying: #2706 (a library per translation) removes part of the reason this was written - a translator edit no longer overwrites *another* build's library - so the remaining cost this PR addresses is the write volume of a run's own saves. If the maintainers would rather have the smaller change first, "save only after N new pipelines or on exit" is a few lines and gets most of the I/O, but it loses the crash-safety of a periodic save; the shard design keeps both. I have not ported it here: 200 lines through a file whose save/load changed twice since, without a run to check the library still loads, is not something to push tonight. Happy to do it as the next piece of work if it is wanted.
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 22:39 UTC · original

Ported onto today's main (f3578e3) as a re-application rather than a rebase, since main reworked both ends of this file meanwhile (write_atomically, zeroed, Shared { loads, state } so loads take no lock, and the pre-build's list tagged with the translator hash). One commit, 3b1cda6.

What it does now:

  • the library is kept in SHARDS = 16 files, host-pipelines.NN.bin, chosen by shard_of(name) (a hash of the pipeline's name, so a pipeline keeps its shard across runs);
  • save serialises and writes only the shards that gained pipelines (Library::dirty), leaves a shard dirty if its write fails, and writes the early list (still one file) when it changed or on a shutdown save;
  • prebuilt/note_prebuilt/pipeline pick the shard;
  • a library made before the split is not thrown away: host-pipelines.bin is still read (never written) and a pipeline found there is stored into its shard, so a warm run fills the shards and the file can then be deleted (one log line says so);
  • pipeline's load is Fn rather than FnOnce, because a name may now be looked for in its shard and then in the one-file library.

Checked: cargo test --release -p victory-gpu 229 pass (one new: names spread over the shards and keep their shard), clippy clean, both victory configurations build.

Note for whoever merges: this and #2706 touch the same file but different parts (this one the library/save/load, #2706 the cache directory), so whichever goes second needs a trivial rebase.

**@⁠pes7** on GitHub · 2026-11-25 22:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7176628596) Ported onto today's `main` (`f3578e3`) as a re-application rather than a rebase, since `main` reworked both ends of this file meanwhile (`write_atomically`, `zeroed`, `Shared { loads, state }` so loads take no lock, and the pre-build's list tagged with the translator hash). One commit, `3b1cda6`. What it does now: - the library is kept in `SHARDS = 16` files, `host-pipelines.NN.bin`, chosen by `shard_of(name)` (a hash of the pipeline's name, so a pipeline keeps its shard across runs); - `save` serialises and writes only the shards that gained pipelines (`Library::dirty`), leaves a shard dirty if its write fails, and writes the early list (still one file) when it changed or on a shutdown save; - `prebuilt`/`note_prebuilt`/`pipeline` pick the shard; - a library made before the split is **not** thrown away: `host-pipelines.bin` is still read (never written) and a pipeline found there is stored into its shard, so a warm run fills the shards and the file can then be deleted (one log line says so); - `pipeline`'s `load` is `Fn` rather than `FnOnce`, because a name may now be looked for in its shard and then in the one-file library. Checked: `cargo test --release -p victory-gpu` 229 pass (one new: names spread over the shards and keep their shard), clippy clean, both `victory` configurations build. Note for whoever merges: this and #2706 touch the same file but different parts (this one the library/save/load, #2706 the cache directory), so whichever goes second needs a trivial rebase.
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 22:19 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Pipeline library split into shards: only shards that gained pipelines are serialised and written on save; shard_file() maps shard→file. 1 test. Pairs with #1651 (save only changed shards) — check whether these two conflict or compose.

**@⁠catminou4** on GitHub · 2026-11-24 22:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#pullrequestreview-6048311377) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Pipeline library split into shards: only shards that gained pipelines are serialised and written on save; shard_file() maps shard→file. 1 test. Pairs with #1651 (save only changed shards) — check whether these two conflict or compose.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 08:35 UTC · original

@⁠pes7 I reran the shard-save regression on the current 3b1cda6. The fix and regression test are in 5236270 on codex2/pr1653-save-race, directly on that head.

The WARP test stores a second named compute PSO and its prebuilt key after the first save has taken its snapshot, just before the file write. It reopens the shard and reads the sidecar after each write.

Same fixture Pending after the first save Second save
3b1cda6 0 stores, prebuilt flag clear Skips the shard. The new entry is missing on disk.
5236270 1 store, prebuilt flag set Writes the shard. Both named PSOs load and both prebuilt keys are present.

The third save skips the clean shard. All 13 pipeline-library tests passed on Windows with WARP, and strict GPU Clippy passed with all features.

The patch restores acknowledgement of just the saved snapshot and keeps overlapping saves from acknowledging or replacing each other's snapshots. If you fold the fix or test into your commit, please retain Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 08:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7186778942) @⁠pes7 I reran the shard-save regression on the current `3b1cda6`. The fix and regression test are in [`5236270`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/5236270f92fd34028fd20660d48f8a1b276a8fe7) on `codex2/pr1653-save-race`, directly on that head. The WARP test stores a second named compute PSO and its prebuilt key after the first save has taken its snapshot, just before the file write. It reopens the shard and reads the sidecar after each write. | Same fixture | Pending after the first save | Second save | | --- | --- | --- | | `3b1cda6` | 0 stores, prebuilt flag clear | Skips the shard. The new entry is missing on disk. | | `5236270` | 1 store, prebuilt flag set | Writes the shard. Both named PSOs load and both prebuilt keys are present. | The third save skips the clean shard. All 13 pipeline-library tests passed on Windows with WARP, and strict GPU Clippy passed with all features. The patch restores acknowledgement of just the saved snapshot and keeps overlapping saves from acknowledging or replacing each other's snapshots. If you fold the fix or test into your commit, please retain `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 09:17 UTC · original · requested changes

Verified 3b1cda6b locally on Windows 11 x64 (git merge-tree against 63bcca43 is conflict-free):

  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default and --all-features): clean (9.16s / 4.19s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.35s).
  • cargo test -p victory-gpu --lib --locked pipeline::library:: -- --test-threads=1: 12 passed, 0 failed on both RTX 5090 (0.61s) and VICTORY_WARP=1 (0.52s).

Two save-concurrency bugs are present in 3b1cda6b:

  1. Lost dirty state during save() (library.rs:428-443): serialise(shared) releases the shard mutex before write_atomically, and on success save() unconditionally sets l.added = 0; l.prebuilt_changed = false;. Any pipeline stored or note_prebuilt key inserted during that I/O window is wiped from the dirty state and skipped by subsequent saves (including save(true)). Please acknowledge only the snapshot count/length (l.added -= added, l.prebuilt_changed = l.prebuilt.len() != prebuilt_count) and include a regression test for concurrent store/prebuilt updates during shard write.
  2. Out-of-order overlapping saves (library.rs:407-445): LAST only guards the throttle timestamp while WRITING inside write_atomically only serializes individual file renames, so a periodic save and save(true) can interleave and let an older snapshot overwrite a newer shard/sidecar. Please serialize the entire snapshot-and-publish transaction across save().

Two non-blocking notes as well: prebuilt/note_prebuilt shard by title key while pipeline() shards by host PSO name (so partial cross-shard failures can leave a prebuilt entry without its PSO on restart), and USED_CHANGED.swap(false) before writing EARLY_FILE drops retries on write failure.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 09:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#pullrequestreview-6071383116) · **requested changes** Verified `3b1cda6b` locally on Windows 11 x64 (`git merge-tree` against `63bcca43` is conflict-free): - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default and `--all-features`): clean (`9.16s` / `4.19s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.35s`). - `cargo test -p victory-gpu --lib --locked pipeline::library:: -- --test-threads=1`: 12 passed, 0 failed on both RTX 5090 (`0.61s`) and `VICTORY_WARP=1` (`0.52s`). Two save-concurrency bugs are present in `3b1cda6b`: 1. **Lost dirty state during `save()` (`library.rs:428-443`)**: `serialise(shared)` releases the shard mutex before `write_atomically`, and on success `save()` unconditionally sets `l.added = 0; l.prebuilt_changed = false;`. Any pipeline stored or `note_prebuilt` key inserted during that I/O window is wiped from the dirty state and skipped by subsequent saves (including `save(true)`). Please acknowledge only the snapshot count/length (`l.added -= added`, `l.prebuilt_changed = l.prebuilt.len() != prebuilt_count`) and include a regression test for concurrent store/prebuilt updates during shard write. 2. **Out-of-order overlapping saves (`library.rs:407-445`)**: `LAST` only guards the throttle timestamp while `WRITING` inside `write_atomically` only serializes individual file renames, so a periodic save and `save(true)` can interleave and let an older snapshot overwrite a newer shard/sidecar. Please serialize the entire snapshot-and-publish transaction across `save()`. Two non-blocking notes as well: `prebuilt`/`note_prebuilt` shard by title key while `pipeline()` shards by host PSO name (so partial cross-shard failures can leave a prebuilt entry without its PSO on restart), and `USED_CHANGED.swap(false)` before writing `EARLY_FILE` drops retries on write failure.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 09:57 UTC · original

@⁠fuzeofficlal 5236270, directly on 3b1cda6, addresses both races in your review. It acknowledges only the published snapshot, leaving concurrent stores and prebuilt keys pending, and holds the save lock through publication and acknowledgement so an older snapshot cannot overwrite a newer one. The WARP regression verifies that a PSO and key added during the first write are present after the second save.

Please retain the Git author on cherry-pick or rebase. If folded into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 09:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7188717690) @⁠fuzeofficlal [5236270](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/5236270f92fd34028fd20660d48f8a1b276a8fe7), directly on `3b1cda6`, addresses both races in [your review](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1653). It acknowledges only the published snapshot, leaving concurrent stores and prebuilt keys pending, and holds the save lock through publication and acknowledgement so an older snapshot cannot overwrite a newer one. The [WARP regression](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1653) verifies that a PSO and key added during the first write are present after the second save. Please retain the Git author on cherry-pick or rebase. If folded into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
github-bot force-pushed github-bot/gh-1653 from 3b1cda6b26 to 013da6195d 2026-11-26 13:42:01 +00:00 Compare
Author
Owner

@⁠pes7 on GitHub · 2026-11-26 13:39 UTC · original

The two races the review found are fixed on the branch, which was also rebased onto current main (it was 74 files behind, which is why the diff looked enormous; the force-push makes CI run against the current tree).

Race 1 - a pipeline added during the write was lost. save_shard acknowledged by resetting the dirty flags after the bytes were written, unconditionally:

l.added = 0;
l.prebuilt_changed = false;

A pipeline that arrived while the shard was being serialised and written is in neither the file nor the dirty flags, so it was never saved. Now (013da619) the save records what it snapped (added, prebuilt.len()), and on the way back subtracts exactly that and recomputes prebuilt_changed from whether the set grew in the meantime, so late arrivals stay dirty for the next save.

Race 2 - an older snapshot could be published over a newer one. Two saves (a worker's and the shutdown's) could serialise at T1 and T2 and publish in the opposite order. Snapshot and publish are now one transaction under SAVING (save), so the last publisher holds the newest snapshot; write_atomically keeps a reader from ever seeing a part.

Also in the same area, since the review listed it: the early-pipeline list is now published with a generation check (USED_GENERATION is compared after the write, and USED_CHANGED cleared only if no key arrived meanwhile), so keys added during that write are written by the next save instead of being acknowledged away.

Still open here, and not fixed in this push:

  • prebuilt is sharded by the title key while pipeline() looks a shard up by the host name (shard_of(key) vs shard_of(name)) - the two only line up if those strings are the same, and the review says they are not for every path;
  • a shard file that fails to open is reported as a silent None (a warn once would do);
  • the legacy single-file library stays mapped for the whole run (926 MB observed).

Verification: cargo test --release -p victory-gpu - 228 passed, 1 ignored; clippy -D warnings clean. No frame-time claim: this changes what a save writes, not what a frame does.

**@⁠pes7** on GitHub · 2026-11-26 13:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7193663047) The two races the review found are fixed on the branch, which was also rebased onto current `main` (it was 74 files behind, which is why the diff looked enormous; the force-push makes CI run against the current tree). **Race 1 - a pipeline added during the write was lost.** `save_shard` acknowledged by resetting the dirty flags *after* the bytes were written, unconditionally: ```rust l.added = 0; l.prebuilt_changed = false; ``` A pipeline that arrived while the shard was being serialised and written is in neither the file nor the dirty flags, so it was never saved. Now (`013da619`) the save records what it snapped (`added`, `prebuilt.len()`), and on the way back subtracts exactly that and recomputes `prebuilt_changed` from whether the set grew in the meantime, so late arrivals stay dirty for the next save. **Race 2 - an older snapshot could be published over a newer one.** Two saves (a worker's and the shutdown's) could serialise at T1 and T2 and publish in the opposite order. Snapshot and publish are now one transaction under `SAVING` (`save`), so the last publisher holds the newest snapshot; `write_atomically` keeps a reader from ever seeing a part. Also in the same area, since the review listed it: the early-pipeline list is now published with a generation check (`USED_GENERATION` is compared after the write, and `USED_CHANGED` cleared only if no key arrived meanwhile), so keys added during that write are written by the next save instead of being acknowledged away. **Still open here, and not fixed in this push:** - `prebuilt` is sharded by the title key while `pipeline()` looks a shard up by the host name (`shard_of(key)` vs `shard_of(name)`) - the two only line up if those strings are the same, and the review says they are not for every path; - a shard file that fails to open is reported as a silent `None` (a `warn` once would do); - the legacy single-file library stays mapped for the whole run (926 MB observed). Verification: `cargo test --release -p victory-gpu` - 228 passed, 1 ignored; clippy `-D warnings` clean. No frame-time claim: this changes what a save writes, not what a frame does.
Author
Owner

@⁠pes7 on GitHub · 2026-11-26 13:43 UTC · original

Correction to my last comment, and the exact state of this branch.

The two races are fixed (9c606942 + 013da619 on top of 940d32f6), as described: the save acknowledges only what it snapped, and snapshot+publish are one transaction under SAVING; the early list is published with a generation check.

"Rebased onto current main" was wrong - I wrote that before doing it, and doing it shows the branch needs a port, not a rebase. main has moved 160 commits, and three of them change pipeline/library.rs, the very file this PR rewrites:

commit what it changes what the sharded version needs
321a4bc1 the serialise buffer is reserved fallibly (zeroed), so a save without memory waits instead of aborting the process (1.7 GB on NVIDIA) save_shard allocates vec![0u8; size] infallibly today: the same zeroed + the test that comes with it
555c112e loads take no lock: the library is kept a second time (Shared { loads, state }) beside the lock a save holds while it serialises hundreds of megabytes libraries() returns [Mutex<Library>; SHARDS], so each shard needs its Shared and pipeline() must load through it
e9ea9a45 the early list is an ordered map (Used::read, used()), so a full list drops the oldest runs' keys and a save before any read keeps the saved list my Used::list + save write used() as a set; the ordered form has to come in with it

I tried the rebase and backed it out: the only way through in one step was to take my side of the file wholesale, which reverts all three of the above - a regression dressed as a merge. The branch is therefore still 013da619 (conflicting, as GitHub says) rather than silently dropping three main fixes.

What finishing this means, concretely: port those three onto the sharded code (Shared per shard, zeroed in save_shard, Used as an ordered map), then cargo test --release -p victory-gpu (228 tests) and the pipeline-library tests in library.rs's mod tests, which cover the shard round trip.

**@⁠pes7** on GitHub · 2026-11-26 13:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7193742437) Correction to my last comment, and the exact state of this branch. **The two races are fixed** (`9c606942` + `013da619` on top of `940d32f6`), as described: the save acknowledges only what it snapped, and snapshot+publish are one transaction under `SAVING`; the early list is published with a generation check. **"Rebased onto current main" was wrong** - I wrote that before doing it, and doing it shows the branch needs a port, not a rebase. `main` has moved 160 commits, and three of them change `pipeline/library.rs`, the very file this PR rewrites: | commit | what it changes | what the sharded version needs | |---|---|---| | `321a4bc1` | the serialise buffer is reserved fallibly (`zeroed`), so a save without memory waits instead of aborting the process (1.7 GB on NVIDIA) | `save_shard` allocates `vec![0u8; size]` infallibly today: the same `zeroed` + the test that comes with it | | `555c112e` | loads take no lock: the library is kept a second time (`Shared { loads, state }`) beside the lock a save holds while it serialises hundreds of megabytes | `libraries()` returns `[Mutex<Library>; SHARDS]`, so each shard needs its `Shared` and `pipeline()` must load through it | | `e9ea9a45` | the early list is an ordered map (`Used::read`, `used()`), so a full list drops the *oldest* runs' keys and a save before any read keeps the saved list | my `Used::list` + `save` write `used()` as a set; the ordered form has to come in with it | I tried the rebase and **backed it out**: the only way through in one step was to take my side of the file wholesale, which reverts all three of the above - a regression dressed as a merge. The branch is therefore still `013da619` (conflicting, as GitHub says) rather than silently dropping three `main` fixes. What finishing this means, concretely: port those three onto the sharded code (`Shared` per shard, `zeroed` in `save_shard`, `Used` as an ordered map), then `cargo test --release -p victory-gpu` (228 tests) and the pipeline-library tests in `library.rs`'s `mod tests`, which cover the shard round trip.
github-bot force-pushed github-bot/gh-1653 from 013da6195d to bf43b8068e 2026-11-26 14:56:08 +00:00 Compare
Author
Owner

@⁠pes7 on GitHub · 2026-11-26 14:49 UTC · original

Rebased onto current main and the three fixes main had landed in this file are ported onto the sharded code — so the branch is now MERGEABLE with a one-file diff again (+261/−131), CI running.

For the record of what happened: the rebase itself only goes through by taking this side of pipeline/library.rs whole, which would have dropped 321a4bc1, 555c112e and e9ea9a45 (the "rebase" I backed out earlier). This time the rebase was done and then each fix was ported deliberately, one section at a time:

main's fix what the sharded code got
321a4bc1 — a library save the host has no memory for waits, not aborts (Kevin Pratap) zeroed(n) with try_reserve_exact, used by save_shard; without the memory the shard stays dirty and a later save writes it
555c112e — pipeline library loads do not wait for a save (winne42) per shard Shared { loads, state }: pipeline() loads through the second interface with no lock at all, where this branch still cloned it under the lock; ported with its test
e9ea9a45 — a full early pipeline list drops the oldest runs' keys (Danilo Mori Schuler) Used::before is HashMap<key, place> with Used::read/Used::list sorting by place, so the oldest runs' keys make room, and a list saved in no order still reads

This branch's own two races are untouched: a save acknowledges only what it snapped (d09b71bf), snapshot and publish are one transaction under SAVING, and the early list is published with a generation check.

Verification (cargo test --release -p victory-gpu, all 231 tests; the module's 11 alone in a filter):

test pipeline::library::tests::a_pipeline_loads_while_a_save_holds_the_library ... ok
test pipeline::library::tests::the_early_list_keeps_this_run_first ... ok
test pipeline::library::tests::a_prebuilt_key_recorded_during_publication_is_saved_next_time ... ok
test pipeline::library::tests::pipelines_load_on_many_threads_at_once ... ok
test pipeline::library::tests::a_pipeline_lands_in_one_shard_and_the_shards_spread ... ok
...
test result: ok. 231 passed; 0 failed; 1 ignored

a_pipeline_loads_while_a_save_holds_the_library holds a shard's lock, then requires a stored pipeline to load within 30 s — with the cloning version it times out, which is what made the port worth doing rather than trusting. the_early_list_keeps_this_run_first now asserts both ends of the order: the most recent earlier key is kept and the oldest is the one that made room.

Clippy --all-targets -D warnings clean.

Still open, deliberately not in this PR (they are separate questions, not merge blockers): a shard file that fails to open is a silent None (a warn once would do), and the legacy single-file library stays mapped for the whole run (926 MB observed). The prebuilt-keyed-by-title-key versus pipeline()-keyed-by-host-name question from the review is settled here by keeping one shard function (shard_of) for both, which is what the shard round-trip test pins.

**@⁠pes7** on GitHub · 2026-11-26 14:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7195384732) Rebased onto current `main` and the three fixes `main` had landed in this file are ported onto the sharded code — so the branch is now `MERGEABLE` with a one-file diff again (+261/−131), CI running. For the record of what happened: the rebase itself only goes through by taking this side of `pipeline/library.rs` whole, which would have dropped `321a4bc1`, `555c112e` and `e9ea9a45` (the "rebase" I backed out earlier). This time the rebase was done and then each fix was ported deliberately, one section at a time: | `main`'s fix | what the sharded code got | |---|---| | `321a4bc1` — a library save the host has no memory for waits, not aborts (Kevin Pratap) | `zeroed(n)` with `try_reserve_exact`, used by `save_shard`; without the memory the shard stays dirty and a later save writes it | | `555c112e` — pipeline library loads do not wait for a save (winne42) | per shard `Shared { loads, state }`: `pipeline()` loads through the second interface with **no lock at all**, where this branch still cloned it under the lock; ported with its test | | `e9ea9a45` — a full early pipeline list drops the oldest runs' keys (Danilo Mori Schuler) | `Used::before` is `HashMap<key, place>` with `Used::read`/`Used::list` sorting by place, so the *oldest* runs' keys make room, and a list saved in no order still reads | This branch's own two races are untouched: a save acknowledges only what it snapped (`d09b71bf`), snapshot and publish are one transaction under `SAVING`, and the early list is published with a generation check. **Verification** (`cargo test --release -p victory-gpu`, all 231 tests; the module's 11 alone in a filter): ``` test pipeline::library::tests::a_pipeline_loads_while_a_save_holds_the_library ... ok test pipeline::library::tests::the_early_list_keeps_this_run_first ... ok test pipeline::library::tests::a_prebuilt_key_recorded_during_publication_is_saved_next_time ... ok test pipeline::library::tests::pipelines_load_on_many_threads_at_once ... ok test pipeline::library::tests::a_pipeline_lands_in_one_shard_and_the_shards_spread ... ok ... test result: ok. 231 passed; 0 failed; 1 ignored ``` `a_pipeline_loads_while_a_save_holds_the_library` holds a shard's lock, then requires a stored pipeline to load within 30 s — with the cloning version it times out, which is what made the port worth doing rather than trusting. `the_early_list_keeps_this_run_first` now asserts both ends of the order: the most recent earlier key is kept **and** the oldest is the one that made room. Clippy `--all-targets -D warnings` clean. Still open, deliberately not in this PR (they are separate questions, not merge blockers): a shard file that fails to open is a silent `None` (a `warn` once would do), and the legacy single-file library stays mapped for the whole run (926 MB observed). The `prebuilt`-keyed-by-title-key versus `pipeline()`-keyed-by-host-name question from the review is settled here by keeping one shard function (`shard_of`) for both, which is what the shard round-trip test pins.
Author
Owner

@⁠pes7 on GitHub · 2026-11-26 15:06 UTC · original

Where this PR stands, and the one cross-PR dependency among our open PRs.

All nine open PRs by pes7 are MERGEABLE/CLEAN with green CI and none is a draft:

2936  fix/prologue                  +601/-38  12 files
2848  perf/cpu-paths                +240/-91   5 files
2706  perf/library-per-translation   +93/-2    1 file
2696  perf/skip-in-release          +20/-10   2 files
2683  fix/heap-index-limit         +124/-10   2 files
2634  perf/heap-slot-log              +9/-6    1 file
1734  test/fence-event-wait         +140/-33   2 files
1653  perf/pipeline-shards          +261/-131  1 file
1623  perf/instruction-words          +39/-17   5 files

I checked every pair that touches the same file with git merge-tree — 2936×2848, 2936×2696, 2936×1623, 2848×2696, 2848×2683, 2848×2634, 2683×2634, 1653×2706 — and none conflicts textually.

The one that matters is 1653 × 2706: they both rewrite pipeline/library.rs, and although git merges them cleanly the result does not compile, because 2706's is_translation looks for host-pipelines.bin and this PR removes it (LIBRARY_FILE becomes host-pipelines.NN.bin). That is the worst shape of conflict — clean to git, broken to the build.

Handled: 2706 now counts a directory as a library when it holds the file or its first shard (b621621fd), so it builds on main today and after this PR. The combination was then verified for real:

  • this PR alone: cargo test --release -p victory-gpu pipeline::library — 11 passed; clippy --all-targets -D warnings clean; CI green.
  • this PR merged with 2706: builds after a 6-line resolution, pipeline:: 24 passed (both the shard round-trip tests and pruning_leaves_foreign_directories_alone). The resolved tree is pushed as perf/library-per-translation-on-shards (e60d4cbb3).

So: merge in either order, and whoever lands second takes that resolution. If this PR lands first, the update to 2706 is that single commit rather than a re-derivation.

Nothing else is pending here — the three main-side fixes are ported and tested, the two races this branch fixed are untouched, and the diff is one file.

**@⁠pes7** on GitHub · 2026-11-26 15:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7195794585) **Where this PR stands, and the one cross-PR dependency among our open PRs.** All nine open PRs by `pes7` are `MERGEABLE`/`CLEAN` with green CI and none is a draft: ``` 2936 fix/prologue +601/-38 12 files 2848 perf/cpu-paths +240/-91 5 files 2706 perf/library-per-translation +93/-2 1 file 2696 perf/skip-in-release +20/-10 2 files 2683 fix/heap-index-limit +124/-10 2 files 2634 perf/heap-slot-log +9/-6 1 file 1734 test/fence-event-wait +140/-33 2 files 1653 perf/pipeline-shards +261/-131 1 file 1623 perf/instruction-words +39/-17 5 files ``` I checked every pair that touches the same file with `git merge-tree` — `2936×2848`, `2936×2696`, `2936×1623`, `2848×2696`, `2848×2683`, `2848×2634`, `2683×2634`, `1653×2706` — and **none conflicts textually**. The one that matters is `1653 × 2706`: they both rewrite `pipeline/library.rs`, and although git merges them cleanly the result does not compile, because `2706`'s `is_translation` looks for `host-pipelines.bin` and this PR removes it (`LIBRARY_FILE` becomes `host-pipelines.NN.bin`). That is the worst shape of conflict — clean to git, broken to the build. Handled: `2706` now counts a directory as a library when it holds the file **or** its first shard (`b621621fd`), so it builds on `main` today and after this PR. The combination was then verified for real: * this PR alone: `cargo test --release -p victory-gpu pipeline::library` — 11 passed; clippy `--all-targets -D warnings` clean; CI green. * this PR merged with `2706`: builds after a 6-line resolution, `pipeline::` **24 passed** (both the shard round-trip tests and `pruning_leaves_foreign_directories_alone`). The resolved tree is pushed as `perf/library-per-translation-on-shards` (`e60d4cbb3`). So: merge in either order, and whoever lands second takes that resolution. If this PR lands first, the update to `2706` is that single commit rather than a re-derivation. Nothing else is pending here — the three `main`-side fixes are ported and tested, the two races this branch fixed are untouched, and the diff is one file.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 15:34 UTC · original

@⁠pes7 I reproduced a remaining race in the early-list acknowledgement on bf43b80. A test-only hook let a second thread call note_used("late") after the save compared the generation and before it cleared the dirty flag. The first save correctly wrote just initial. The next forced save also left just initial, since the acknowledgement had cleared the new key's dirty flag.

The follow-up captures the list and its generation together under USED. The existing save mutex remembers the generation actually published. The same forced schedule then wrote initial on the first save and both keys on the second. With the test-only hook removed, the patch passed all 26 pipeline tests, the full WARP GPU lib suite (246 passed, 1 ignored), strict GPU Clippy and policy. Follow-up on bf43b80

Please retain Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if you fold the fix into your commit. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 15:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1653#issuecomment-7196464172) @⁠pes7 I reproduced a remaining race in the early-list acknowledgement on `bf43b80`. A test-only hook let a second thread call `note_used("late")` after the save compared the generation and before it cleared the dirty flag. The first save correctly wrote just `initial`. The next forced save also left just `initial`, since the acknowledgement had cleared the new key's dirty flag. The follow-up captures the list and its generation together under `USED`. The existing save mutex remembers the generation actually published. The same forced schedule then wrote `initial` on the first save and both keys on the second. With the test-only hook removed, the patch passed all **26 pipeline tests**, the full WARP GPU lib suite (**246 passed**, 1 ignored), strict GPU Clippy and policy. [Follow-up on `bf43b80`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/69199ca5c0804e97773408be8f1f0d0eeb7eeb49) Please retain `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if you fold the fix into your commit. AI-assisted with Codex.
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/1653/head:github-bot/gh-1653'
git switch 'github-bot/gh-1653'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1653'
git switch 'github-bot/gh-1653'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1653'
git switch 'github-bot/gh-1653'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1653'
git switch 'main'
git merge --squash 'github-bot/gh-1653'
git switch 'main'
git merge --ff-only 'github-bot/gh-1653'
git switch 'main'
git merge 'github-bot/gh-1653'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1653
No description provided.