feat(agc): store the pipeline journal's modules compressed #8365
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8365"
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-20T11:09:17Z.
What
Pipeline journal module records are SPIR-V, and they take almost all of a journal's bytes. #8309 shows that
APS5_PIPELINE_JOURNAL_MAX_MIB(1024 MiB) fills with them during a level load, after which later pipelines are never recorded. A module record now stores the module's identity, its stage and the size of its encodedRecompileResult, then a zstd frame (level 1) of that encoding. Loading expands each module once to check that it decodes, as it decoded the raw payload before. Replay expands a module when the entry that needs it is built, on the replay thread, through #8213's per-module reads. The held-module accounting counts expanded bytes, which is what replay holds in memory. The file format becomes 6 (#5656 took 5 onmainfor its recipe codec change), so an older journal starts over. Since the journal's source version already changes with every recompiler build, that costs no extra rebuilds.zstd is the vendored copy (
3rdparty/zstd, already built aslibzstd_staticfor ZArchive).libSceAgcDriverlinks it statically, and on Linux it's kept out of the library's exports with--exclude-libs,libzstd.a, ascmake/ZArchive.cmakedoes.nm -D --defined-only libSceAgcDriver.prx | grep -i zstdprints nothing.Why
The same cap then holds about 3.5 times as many modules:
zstd -1gives 27.4% (3.7 s on one thread), so everything that seed recorded would fit under the default cap. Records compressed one at a time can come out a little larger than the whole stream.zstd -1(0.39 s on one thread).Tested
Rebased onto
maind0e7fe7bebas9a343887faafter #9348 took journal format 10; that line was the only conflict, and 11 is nowmain+1 (journal tests 3 of 3 on #8542's rebased head, which carries this commit). Before that, rebased ontomainb607bfdc8b, which has #8213, as3ac931eff9. It is the patch tested asbc08106ac5on #8213's head6fc2ea58c0, except that it keepsmain's comment aboveFileFormatinstead of rewording it (the conventions check counts a reworded comment as new).mainnow has #9836, which keeps a full journal's newest pipelines and moved module encoding intoEncodeModule, so this commit now compresses insideEncodeModule(an empty payload skips the batch as before), and the size check of an over-cap batch measures the compressed records the file will hold. #9836'sOversizedRecordKeepsTheJournalmade its record too large with 400,000 zero words, which zstd shrinks under the 1 MiB cap. The test now fills those words with an LCG, so the record stays over the cap compressed. Without that change,agc_driver_pipeline_journalfails 3 of 3 here withthe oversized record was not counted as a write failure. On this head, Ubuntu 26.04.1, GCC 15.2, RTX 4070 Ti (615.71.09):agc_driver_pipeline_journal,agc_pipeline_journaland_long_pathspass 3 of 3 onbc08106ac5(on #8213's head6fc2ea58c0); they pass 3 of 3 on6fc2ea58c0itself and onmaind098eca3d6.pipeline_journal|pipeline_store|pipeline_library|pipeline_optimized_readback, on6fc2ea58c0and onbc08106ac5: 16 of 16 pass on each, with noVUID-message and no layer-missing line.cefe1d002f): the 4 pipeline journal tests pass 3 of 3, on the merge base and on the head.FileFormatis 11,main+1:mainis at 10 (8 for #6801's point lists, 9 for #8564's 4_4_4_4 targets, 10 for #9348's colour logic operation).Earlier results, on the heads named in them:
Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02.
agc_driver_pipeline_journal:HeldModuleTestsnow also encodes its 16 compute modules and requires the whole journal file to be smaller than those encodings. With #8213's uncompressed records it fails (the journal is 467,960 bytes with 16 of its modules alone encoding to 430,144 bytes), 3 of 3. With this PR both journal tests pass 3 of 3, the held-module bound among them.Khronos validation layer (LunarG SDK 1.4.363), NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04:
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R 'pipeline_journal' -Von #8213's head 5778288da7 and on this PR (f5504d2ec4). 2 of 2 pass on each. Neither log reports the layer missing, and neither has aVUID-error.tools/check_conventions.py --base upstream/mainpasses, apart from the existingdebt-lengthwarning on the pipeline journal entry. This PR doesn't change that entry, since nothing in it becomes false.PPSA11386, by @SleglJan (comment), RTX 3080 (NVIDIA 615.78.08), Linux, on a
main68323bae7integration with the title's open PRs, #8213 and this PR: with the default 1024 MiB cap, the first level's load now records completely, and the cap is reached about 455 s into gameplay. Before this, it was reached during that load. The journal records 628 graphics, 694 compute and 1,292 modules, against 330, 377 and 664. The warm level entry has no gap, against 280 s from Resume to the first gameplay frame: 4,107 draws built in 7.2 s, against 772 in 284.5 s.Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, by @TheSovietWaffle on
f5504d2ec:agc_driver_pipeline_journalandagc_pipeline_journalpass 3 of 3 on an NVIDIA RTX 3080 (617.42) and on an AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002).Checklist
main; no other open PR implements the same functionsFileFormatnow names record layouts among what bumps it)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 TheSovietWaffle on 2026-10-20T12:04:12Z.
Windows data point: RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (
1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, headf5504d2ec:agc_driver_pipeline_journalandagc_pipeline_journalpass 3 of 3 on both GPUs.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T12:05:59Z.
Thanks @TheSovietWaffle. That covers Windows, which I hadn't run, and adds an AMD GPU. I added both to the Tested section of the description.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-20T15:42:35Z.
@milescoviello PPSA11386 (007 First Light) with f5504d2ec4, compared with the runs in #8309:
Setup:
main68323bae7with the open PRs this title needs (#5799, #6868, #5372, #6918, #7643, #6679 at an earlier head; it has since merged), plus #8213 (5778288da7) and this PR (f5504d2ec4) as squashes. No conflicts.APS5_PROFILE_DRAW=1.Cold seed with the default cap (1024 MiB):
Warm run from that seed:
The 2 GiB seed in #8309 gave 2,505 builds taking 5.4 s and 0.70 FPS, so the default cap now does about what that seed did.
The entry limit now binds before the byte cap. The replay takes the first
APS5_PIPELINE_JOURNAL_ENTRIESentries (1024, documented in ARCHITECTURE.md as the pipeline store's bound;PipelineJournal.cpp:915onmain2ee20b4200):CachedPipeline,APS5_PIPELINE_STORE_ENTRIES), and only 628 of the 1,322 are graphics. So a separate entry bound for compute, or a log line when the replay truncates, might suit a follow-up rather than this PR.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T15:44:03Z.
Thanks @SleglJan, that's the result #8309 was after: the default cap now covers the level load that the 2 GiB seed needed.
Good catch on the entry limit. The replay cuts the loaded journal to its first
APS5_PIPELINE_JOURNAL_ENTRIESsilently, and compute entries count against a bound meant for the graphics pipeline store. I'll take that as a separate small PR: graphics entries bounded as now, compute entries bounded on their own, and a line when the replay leaves entries out. That keeps this one to the module encoding.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T15:53:09Z.
@SleglJan the entry-limit follow-up is #8542, stacked on this PR. Graphics entries keep the current bound, compute entries get
APS5_PIPELINE_JOURNAL_COMPUTE_ENTRIES(1024), and a line says how many of each a replay leaves out.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T19:40:00Z.
Rebased onto
main2185dbf92e. The stack is #8213's two commits (unchanged) plus this one, now 30c643b8ca. It conflicted inPipelineJournal.cppwith #5656, which also bumped the journal'sFileFormatfrom 4 to 5 for its recipe codec change. This PR's format is now 6, so a journal written bymainin format 5 (uncompressed modules) starts over instead of being read as compressed. The commit message and the description say so. On the rebased head, the journal tests (agc_driver_pipeline_journal,agc_driver_graphics,savedata_memory_journal) pass 3 of 3.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T04:58:59Z.
Windows results for this head (30c643b8ca, which carries #8213), since the description only has Linux. Setup: Windows 11 Enterprise (build 22631), NVIDIA GeForce GT 1030 (driver 582.66), WinLibs GCC 15.2.0 r7 (UCRT), Release,
BUILD_TESTING=ON.agc_driver_pipeline_journalandsavedata_memory_journalpass 3 of 3 at this head, which writes compressed modules and reads them back through #8213's overlappedReadFilepath.2185dbf92etoo.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T11:06:02Z.
Rebased onto
main275e896797. The new head isa2eb629939, same three commits. #7869 (polygon modes) took journal format 6, so this PR's format moves to 7, and the module-record commit's message says so. The one conflict was the comment aboveFileFormat, where this PR's wording is kept. The 4journaltests pass 2 of 2.#8542 is restacked on this head.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T01:42:19Z.
@milescoviello the rebase onto FileFormat 7 looks right. Full CI on a2eb629939 fails one Windows test, twice:
prx_thread_local_destructors(attempts 1 and 2 of run 39703474248, both ~48.5 s). Linux passes.The test's message names the cause:
That's the new
static thread_local ReadEvent completion;inJournalFile::Read(PipelineJournal.cpp, the_WIN32branch).ReadEventhas a destructor (CloseHandle), so the module registers a TLS destructor, which this check forbids on Windows.Moving it to
HostThreadLocal(prx/libc/include/HostThreadLocal.hpp) should fix it, the same wayPreciseWait.hppandSubmission.cppkeep their per-thread state. Something like:With that change,
prx_thread_local_destructorsshould pass on Windows CI.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T01:52:01Z.
@oneandonlydean thanks for tracking that down. Pushed
e867237953: the read event inJournalFile::Readnow comes fromHostThreadLocal<ReadEvent, ReadEvent>()instead of astatic thread_local, as you suggested. That followsPerformanceOverlay.cpp'sHostThreadLocal<PacketCounterLease, PacketCounterLease>(), with the event type as its own tag.#8213 has the same
static thread_local ReadEvent(that's where the overlapped read came from), so I pushed the same change there as0d34f90fab.My Windows 11 VM (WinLibs GCC 15.2.0) is building all modules for
prx_thread_local_destructorsonmainand one867237953. I'll post the result here when it finishes.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T02:08:06Z.
Windows 11 VM, WinLibs GCC 15.2.0, Release, every module built (
--target libs):prx_thread_local_destructorspasses one867237953and on its merge base275e896797. So theHostThreadLocalchange clears the module's thread_local destructor; the red side is your CI run ona2eb629939. #8213 carries the same change as0d34f90fab.AI-assisted: yes (Claude Code)