Repository navigation
Conversation
|
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. |
… one at a time aycow's review of Marvisak#1653 found two persistence holes, both real. `added` was cleared when the shard was *serialised*, before the write: a failed write left the shard marked clean, so its pipelines were never retried and died with the process. It is cleared after the file is published now, by the count that was serialised - pipelines stored while the write ran stay dirty and go out next time. The save-order interval lock was released before serialisation and publication, so two saves could interleave and publish an older snapshot over a newer one. One `SAVING` lock now covers both, per save.
|
Thanks - both are real, and fixed in
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:
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 |
f26e6ae to
1e79f14
Compare
|
@aycow - your two findings are still addressed, and the branch is rewritten on today's Both of your concerns, on the new code:
Two changes from the revision you reviewed, both because the file moved:
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.
|
catminou4
left a comment
There was a problem hiding this comment.
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 - good catch, and they do not compose: #1651 (
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 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. |
|
Automated triage for the maintainers. Needs work. The re-application onto current
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 ( Generated by Claude Code |
|
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 andrewpozdnakov7-jpg@users.noreply.github.com AI-assisted. Synthetic data only. |
A load still took the library's lock to clone the interface, and a save holds that lock while it serialises the whole library (230-600 MB in the world, Marvisak#1683, Marvisak#1653). Saves run every 20 s while pipelines are being made, some on the pipeline workers themselves, so every load waited out each save: the part of Marvisak#1615 that Marvisak#1000 left. The library is kept a second time beside its lock, and loads use that one without locking. A load adds nothing to the library, so the size a save asks for still holds when it serialises; the library is free-threaded but for loads of one name, which NAMES keeps apart. Stores and saves keep the lock. New test: a stored pipeline loads while the lock is held as a save holds it. With the old locking it times out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1e79f14 to
9c60694
Compare
|
Re-applied onto 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
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. |
A save snapshots a shard's prebuilt keys, releases the lock and writes the files. A key recorded while it writes was not in the file, but clearing the flag by "was it set at snapshot time" marked it saved anyway, so the next save skipped the shard and the published list never gained the key. Acknowledge only what was published: the shard stays dirty when its key count changed while the write ran. `save_shard` is split out so the race is testable, and the regression test injects a key from inside the write - it fails on the old check and passes on this one. `USED_CHANGED` had the same shape, so the early list is acknowledged the same way: a generation counter bumped by `note_used` decides whether the list that was written is still the whole list. Fix and regression test by andrewpozdnakov7-jpg, from the analysis on Marvisak#1653. Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>
|
@andrewpozdnakov7-jpg @Marvisak - taken, with the trailer, at The race was real and I had introduced it rewriting // 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
|
|
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 Two lines from one The load is cheap (57 ms: the driver maps it). The save is not: the whole 926 MB was written again with With the shards in this PR that save writes no library bytes at all: every shard has The rest of the launch, for context: the first frame still takes 21 s of 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. |
|
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: 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 Two things about that for this PR:
If a "the library on disk is smaller than what the load reported" line is cheap ( |
|
Correction to what I wrote above, after reading The fix for that is #2706: the library lives in 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 ( |
A load still took the library's lock to clone the interface, and a save holds that lock while it serialises the whole library (230-600 MB in the world, #1683, #1653). Saves run every 20 s while pipelines are being made, some on the pipeline workers themselves, so every load waited out each save: the part of #1615 that #1000 left. The library is kept a second time beside its lock, and loads use that one without locking. A load adds nothing to the library, so the size a save asks for still holds when it serialises; the library is free-threaded but for loads of one name, which NAMES keeps apart. Stores and saves keep the lock. New test: a stored pipeline loads while the lock is held as a save holds it. With the old locking it times out. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
Status of this branch against today's
The shards themselves are the part that is not in Porting is therefore not a rebase but a re-application of the shard structure onto
Two things to settle while porting: a 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. |
…only what changed
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.
013da61 to
3b1cda6
Compare
|
Ported onto today's What it does now:
Checked: 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. |
…rds so a save writes only what changed (was 600 MB per save)
|
@pes7 I reran the shard-save regression on the current 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.
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 AI-assisted. |
fuzeofficlal
left a comment
There was a problem hiding this comment.
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) andVICTORY_WARP=1(0.52s).
Two save-concurrency bugs are present in 3b1cda6b:
- Lost dirty state during
save()(library.rs:428-443):serialise(shared)releases the shard mutex beforewrite_atomically, and on successsave()unconditionally setsl.added = 0; l.prebuilt_changed = false;. Any pipeline stored ornote_prebuiltkey inserted during that I/O window is wiped from the dirty state and skipped by subsequent saves (includingsave(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. - Out-of-order overlapping saves (
library.rs:407-445):LASTonly guards the throttle timestamp whileWRITINGinsidewrite_atomicallyonly serializes individual file renames, so a periodic save andsave(true)can interleave and let an older snapshot overwrite a newer shard/sidecar. Please serialize the entire snapshot-and-publish transaction acrosssave().
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 5236270, directly on Please retain the Git author on cherry-pick or rebase. If folded into another commit, please add |
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-SIZEin #1633. ## The problem, as the task states it The host pipeline library is one serialised blob, over 600 MB in the world, andID3D12PipelineLibrary::Serializehas 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).Serializeitself copies 600 MB, thenwrite_atomicallywrites 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 withadded > 0, and writes the early list only when it changed. The log line reportsshards = K, bytes = Binstead of one blob's size. A save that adds pipelines spread over K shards writesK/16of 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 carriesshardsandbytes- so the first run in the world gives the number directly: the old line reportedbytes тХд╨ТтХи╨йтХи╨и 600 MB, the new one reports the sum of the changed shards. Not measured: the wall time of a save in the world. It isSerialize+ one write per changed shard, so it scales with the same fraction. ## Correctness Rewritten ontomain940d32f, where this module gained the pre-build'sprebuiltlist. 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 theSAVElock insidewrite_atomically- the sharding only decides which of the sixteen libraries a name is looked up in.a_rejected_blob_gives_an_empty_librarystill passes, and the existing name test is unchanged. - One-time cost on upgrade: the old singlehost-pipelines.binis 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:
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 oneSAVINGlock 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
checkgreen, rebased onto today'smain(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.