fix(agc): keep the pipeline journal's newest pipelines when it is full #9836
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9836"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-22T16:53:52Z.
What
The pipeline journal could lose the pipelines a title needs most, in two ways.
APS5_PIPELINE_JOURNAL_ENTRIESentries of the file, so a title with more pipelines than the bound never replayed the ones it built last: the pipelines of the level the save was in were compiled again at every level entry, under the GPU mutex.APS5_PIPELINE_JOURNAL_MAX_MIBthe writer refused every later record, so a level that loaded after the cap was reached was never recorded at all and paid its builds on every boot (#8309).This change:
The rewrite happens in the journal's writer thread, under the file lock it already holds, and the counters report what it dropped:
APS5_PIPELINE_JOURNAL_MAX_MIBandAPS5_PIPELINE_JOURNAL_ENTRIESkeep their meaning (the size cap and the number of entries replayed); the debt entry andENVIRONMENT.mddescribe the new behaviour.The branch is rebased on
main(a701f9f788) and changes no.github/workflowsfile. It has no required dependencies: #8213 and #8365 are not in this branch and are not listed underDepends on. Intended merge order is this PR first; if either of those lands first, this PR will rebase. #8542's live head98efc1f040still keeps the first entries per kind; @milescoviello and I agreed in the #8542 thread that the changes compose and that #8542 will rebase onto this PR, applying its per-kind graphics/compute bounds to the newest entries this PR keeps (agreement, confirmation); the confirmation was on the closed #9440, which carries the same journal change as this PR. After rebasing onto this PR, #8542's per-kind selection should count from the end of the newest-entry list (keep the last N of each kind); no code change is needed in this PR.Tested
Linux (CachyOS, kernel 7.3.0-2-cachyos), GCC 16.2.1, NVIDIA GeForce GTX 1660 SUPER (driver 615.78.08, Vulkan 1.4.351), base
upstream/maina701f9f788e18f083c353691634f9aa1a04afa76; final head62827a5ca0a6c2520e524563b8e3761212e629ce. AGC runs useANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.agc_driver_pipeline_journalgains five cases:APS5_PIPELINE_JOURNAL_ENTRIES=2builds the two newest entries and not the graphics entry of the first level; the newest program is then found in the store at its dispatch and the oldest is built there. Withmain'sPipelineJournal.cppand this PR's test kept, it fails:AGC graphics: the replay did not build the two newest entries: built 1 compute and 1 graphics, 0 rejected, 0 present, 0 skipped. With this change the binary printspipeline journal record and replay passed.main's writer the file keeps growing and the record is refused (the journal was not rewritten when it reached its cap).evictedRecordsdid not move. Withmain's writer it fails:AGC graphics: three consecutive records after a rewrite triggered another rewrite.the record written after the eviction was not replayed: 0 graphics built, 1 rejectedand the load line readsloaded 1 pipelines and 0 modules.the oversized record emptied the journal: 39888 bytes became 32) and the record is lost; with the fix the file keeps its size, the skipped record is counted as a write failure and the pipeline that was in the journal still replays.Peak RSS at the default 1 GiB cap, measured with a temporary benchmark (not committed; the writer code is unchanged by the rebase) that filled a journal to 1,025 MiB (
1,074,817,224bytes) and then recorded one more compute pipeline. Both runs loaded the same journal, so the difference is the eviction copy:ru_maxrss)2,267,164 KiB(2.16 GiB)1,073,701,480bytes (1,024.0 MiB)1,221,052 KiB(1.16 GiB)805,266,600bytes (767.9 MiB)That is
1,046,112 KiB(about 1.00 GiB) less peak RSS. The old writer stopped 39 KiB under the cap, so the next record rewrote again; the new writer leaves 256.0 MiB of headroom at the 75% watermark.ctest --test-dir build -R '^agc_driver_(pipeline_journal|graphics)$' --output-on-failureon the final head: 2/2 passed in 16.28 s.On the final head
62827a5ca0(basea701f9f788),agc_driver_pipeline_journalpasses (pipeline journal record and replay passed) andagc_driver_graphicspasses (Graphics validation tests passed; it holds the journal parse tests).Khronos validation layer on
62827a5ca0: the final-head logs contain nowas not found but was requested by env var VK_INSTANCE_LAYERSline and noVUID-line.tools/check_conventions.py --base upstream/mainpasses;git diff --checkpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T17:15:47Z.
Review: DISMISSED
The current diff removes every workflow under
.github/workflows/, including the build/test, conventions, PR intake/overlap, labels and release workflows. Those deletions are unrelated to the pipeline-journal change and are not described in the PR body; merging them would remove the repository’s CI and contribution gates. Please restore the workflow files and keep this change scoped to the journal. The current conventions/intake/label checks pass, but the hosted build/test jobs are not present in the current check run, so those checks do not validate this deletion.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T17:54:54Z.
Review: DISMISSED
The committed head removes 17 repository workflows, including
.github/workflows/build.yml,pr-intake.yml,conventions.yml, release, labels, overlap, and Windows test workflows (706 lines frombuild.ymlalone). These deletions are in the PR file diff but are not described in the summary or checklist and are unrelated to pipeline-journal behavior; they would disable repository automation if merged. Please restore those workflow files and rebase onto currentmainbefore this change is considered. The branch parent is8499ea52; current base/main has moved past it, and the PR currently reports the workflow removals. I have not run the AGC tests locally; the host's CPU/Vulkan limitations prevent a reliable runtime check. Existing PR checks are conventions/intake/labels; product jobs are skipped.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-22T19:07:36Z.
Review: CHANGES_REQUESTED
Thanks, the workflows are restored and the diff is scoped to the journal now. The four new tests fail without the change and pin what they say. Remaining points:
PipelineJournal.cpp:802(evictUnderLock): the rewrite keeps records up tomaxBytes - reserve, wherereserveis only the pending record's size. The file is left almost exactly at the cap, so the next record of a different size is over the cap again and rewrites the whole file (up to 1 GiB) for a few records dropped. Under a level load that is a full rewrite per pipeline, under the file lock. Rewrite down to a lower watermark (e.g. keep the newest 3/4 of the cap) so rewrites are rare, and add a test that several consecutive records after a rewrite cause one rewrite, not one each.PipelineJournal.cpp:792-839: the rewrite reads the whole file into memory and builds a second copy, so peak memory is up to about 2x the cap in the writer thread (docs/rules/memory.md). Copy the kept spans with positioned reads/streamed writes into the temporary file, and give the peak RSS before/after on a journal at the default cap.mainand changes the same parse they change, so whichever lands first conflicts with this one. Either stack the branch on them or drop them from Depends on and say which merges first. #8542 changes the same replay truncation (PipelineJournal.cpp:1093) to keep the first entries per kind, while this PR keeps the last ones; those two need one agreed behaviour (this PR's, if the newest pipelines are what a level needs, then #8542's split bound has to follow it).Happy to re-review once these are addressed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T20:28:45Z.
Review: COMMENTED
I re-reviewed the updated head
63bb981a71bea44a63773ba87d6b661972600feband the current diff. The prior blockers are addressed in the diff: the workflow deletions are gone, the writer now streams kept spans and rewrites to a 75% watermark, the pending batch is retried against the rewritten index, and the branch documents the overlap/merge order. The added tests cover newest-entry replay, watermark behavior, module retention for the triggering record, and oversized records. The reported Vulkan validation and RSS runs are author-provided; I did not run those locally. The current hosted checks I can see are conventions and labels only, so I am not treating them as product build/test results. I found no new actionable issue in this pass. Please keep the interaction with #8542 coordinated because its current per-kind/first-entry policy conflicts with this PR’s global newest-entry policy.