fix(agc): read the pipeline journal's modules at replay instead of holding the file #8213
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8213"
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 milescoviello on 2026-10-20T03:32:33Z.
What
Before replaying, the pipeline journal is read whole into one buffer, and the decoded modules keep views into it. So until the last entry is built, a replay holds the entire file, which is up to
APS5_PIPELINE_JOURNAL_MAX_MIB(1024 MiB) by default. The debt entry lists this. A title that fills the journal pays that gigabyte at every boot, on top of the replay's own compiles. Ghost of Tsushima's journal is 1023 MiB: 940 pipelines and 979 modules.How
JournalFileopens the journal for positioned reads, so several threads can read from it at once. On Linux that'spread. On Windows it's an overlapped handle opened withFILE_SHARE_DELETElikeReadWholeFile; eachReadFilepasses its offset and waits on a per-thread event inGetOverlappedResult(5778288da7, after @MarcZX10's review: a handle withoutFILE_FLAG_OVERLAPPEDwould serialize the reads). The size is taken when the file is opened.parsereads one record at a time. Withdecode, a module is still decoded, and its identity checked, so that the index and the dropped-record count stay the same. The module then keeps only where its record lies (offset, size and payload hash). The index-only parse inindexLockeduses the same reader, so re-indexing also no longer reads the whole file.Loadkeeps the file open inLoadedJournal. A replay thread reads an entry's modules when it builds that entry, after the store-full check. It checks the payload hash, decodes the module with the read bytes as the SPIR-V's owner, and drops the bytes once the entry is built. If a record no longer reads back as it was loaded (another process started the file over, say), the entry is rejected instead of built from changed bytes.[pipeline-journal]replay report (APS5_PROFILE_DRAW=1) gains the peak module bytes held at once (replayHeldPeakBytes).A module that several entries name is now read and decoded once per entry. These are reads of bytes the load just put in the page cache, and they are small next to the pipeline build each one feeds.
Tested
Rebased onto
maind6e7ab42dfas8abecc13a0, with no conflicts;git range-diffshows the three commits unchanged. On that head, Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti (615.71.09):agc_driver_pipeline_journalandagc_pipeline_journalpass 3 of 3.Khronos validation 1.4.363, the same 16 tests (
pipeline_journal|pipeline_store|pipeline_library|pipeline_optimized_readback), onmaind6e7ab42dfand on this head: 16 of 16 pass on each, with noVUID-message and no layer-missing line on either side.Ghost of Tsushima Director's Cut (PPSA02225), again with a full 1 GiB journal (945 pipelines, 965 modules), now on @EagleBearerYS's
test/ghost-9742-9717with #8115 and #8121 merged, which gets the title to its brightness calibration screen. Four alternating 150 s warm runs under a 20 GiB cap (A without this PR's 0d34f90fab, B with it), on :0, release libs. Host heap (RssAnon):The heap is 1.3 to 2.5 GB lower through the load. Peak RSS moves less, because about 11 GB of it is the title's guest shared memory.
Earlier results, on the heads named in them:
Linux (Ubuntu 24.04, GCC 13.3), RTX 4070 Ti, NVIDIA 595.99.02.
agc_driver_pipeline_journalhas a new case. A device records 16 more compute programs beside the first two pipelines, then a device replays the journal on one thread. The test requires it to load 18 pipelines and 19 modules, to build all of them with nothing rejected or failed, and to hold under a quarter of the file's bytes at once. It passes 3 of 3. As a mutation check, counting the whole file as held makes it fail:the one-thread replay held 467960 bytes of modules at once from a 467960-byte journal.agc_driver_pipeline_journalandagc_pipeline_journalpass.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V -R 'pipeline_journal|pipeline_store|pipeline_library|pipeline_optimized_readback'): 15 of 15 pass onmain38d7e344b1and on this branch, with no VUIDs and no layer-missing lines on either side.main38d7e344b1, then rebased onto525e299fc0with no conflicts (no journal or pipeline file changed in between).agc_driver_pipeline_journalpasses 3 of 3 at this head 5778288da7 and 3 of 3 at its merge base525e299fc0. At the head, the new case reportsloaded 18 pipelines and 19 modules (0.5 MiB)from the journal, so the replay went through the overlappedReadFilepath. Earlier there was only a MinGW-fsyntax-onlybuild ofPipelineJournal.cpp.mallinfo2every 5 s, and the cgroup'smemory.statwas sampled alongside.APS5_PROFILE_DRAW=1reports that the replay built 432 graphics and 507 compute pipelines (1 more was already present), none rejected or failed, in 113.5 s,holding at most 35.3 MiB of modules.[pipeline-journal] loadedline reports it, takes 1158 to 1680 ms in four runs without the change and 576 to 819 ms in three runs with it, since there is no 1 GiB buffer to allocate and fault in.Checklist
main; no other open PR implements the same functionsLoadreworded so it still describes the code; the debt entry loses the sentence this fixes)NotImplemented_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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T10:42:03Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp; line 404On Windows this handle is opened without
FILE_FLAG_OVERLAPPED, so reads through it are synchronous and serialized even when eachReadFilecall supplies a distinctOVERLAPPEDoffset. The PR description says several replay threads can read from the file at once; with this handle mode, their module reads appear serialized. Did you measure replay on Windows, or should the Windows path use an overlapped handle and wait for each read to complete? The distinction may affect replay throughput on Windows.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T10:45:35Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp; line 404You're right, and I hadn't measured it on Windows. Only the Linux
preadpath was run. WithoutFILE_FLAG_OVERLAPPEDthe handle is a synchronous file object, so its reads are serialized even though each one passes its own offset. 5778288da7 opens the journal withFILE_FLAG_OVERLAPPED. Each read uses anOVERLAPPEDwith a per-thread manual-reset event, passes no byte count toReadFile, and waits inGetOverlappedResult(..., TRUE), which also covers a read that completes at once. The Linux path is unchanged. A MinGW (x86_64-w64-mingw32-g++-posix)-fsyntax-onlybuild ofPipelineJournal.cpppasses. I still haven't run it on Windows, so a replay timing from someone who can would be welcome.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T10:47:37Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp; line 404Thanks; I checked the updated path.
FILE_FLAG_OVERLAPPED, the per-thread manual-reset event, and waiting for completion before reusing the buffer address the serialized-read concern. I agree the remaining evidence gap is Windows runtime/replay timing, which you have not claimed.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T00:36:42Z.
Review: COMMENTED
Rechecked the current stack after #8365 rebased. #8213’s per-record positioned reads are sound on the Linux path by inspection (
preadretries EINTR and handles short reads), and the Windows path has since been revised to use overlapped I/O with a per-thread event and wait for completion before reusing the buffer. The review evidence on this PR reports Linux validation-layer runs and a full-journal Ghost of Tsushima memory comparison; the hosted Linux/Windows build jobs are skipped by path policy, and the description only claims a MinGW syntax-only check for Windows. #8365 now depends on this PR and reports its own post-rebase focused journal tests, plus separate title/GPU results. I found no remaining blocking issue in this diff. The follow-up #8542 also appears as a separate stack item for compute-entry capacity.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T01:28:02Z.
@MarcZX10 since the Windows side only had a syntax-only check, here's a run on a real Windows machine: Windows 11 Enterprise (build 22631), NVIDIA GeForce GT 1030 (driver 582.66), WinLibs GCC 15.2.0 r7 (UCRT), Release.
agc_driver_pipeline_journalpasses 3 of 3 at this head 5778288da7 and 3 of 3 at its merge base525e299fc0.loaded 18 pipelines and 19 modules (0.5 MiB), so the replay read the journal through the overlappedReadFilepath and built everything.I've put this in the description in place of the syntax-only note.
AI-assisted: yes (Claude Code)