fix(agc): keep the pipeline journal's newest pipelines when it is full #9440

Closed
00xDisaster wants to merge 3 commits from upstream-pr/9440 into main
00xDisaster commented 2026-10-21 22:09:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-21T22:09:40Z.


What

The pipeline journal could lose the pipelines a title needs most, in two ways.

  • The replay kept the first APS5_PIPELINE_JOURNAL_ENTRIES entries 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.
  • Once the file reached APS5_PIPELINE_JOURNAL_MAX_MIB the 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 replay keeps the last entries: the pipelines a title built last are the ones its current level needs.
  • The writer rewrites the file when it reaches its size cap. The newest pipelines and the modules they name are kept, the older records are dropped, and the file is replaced atomically. A pipeline whose module the file does not hold is dropped as well, since the replay would reject it. A record that is larger than the cap is not recorded and the file is left as it is.

The rewrite happens in the journal's writer thread, under the file lock it already holds, and the counters report what it dropped:

[pipeline-journal] <path> reached its size cap; 29 records (0.7 MiB) were dropped and the file was rewritten

APS5_PIPELINE_JOURNAL_MAX_MIB and APS5_PIPELINE_JOURNAL_ENTRIES keep their meaning (the size cap and the number of entries replayed); the debt entry and ENVIRONMENT.md describe the new behaviour.

Tested

Linux (Ubuntu 24.04), GCC 16.2.1, NVIDIA GTX 1660 SUPER, driver 590.48.01, Vulkan 1.4.313.

  • agc_driver_pipeline_journal gains four cases:
    • the replay of a journal with five entries and APS5_PIPELINE_JOURNAL_ENTRIES=2 builds 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. With main's replay code it fails: the replay did not build the two newest entries: built 3 compute and 1 graphics, 0 rejected, 0 present, 0 skipped.
    • a journal that reaches the cap is rewritten: the file stays under the cap, the newest pipeline survives the rewrite and the oldest does not. With main's writer the file keeps growing and the record is refused (the journal was not rewritten when it reached its cap).
    • the record that triggers the rewrite keeps the modules it shares with the records the rewrite drops: the journal is filled past its cap with records no pipeline needs, a second draw with the same shaders and a different blend state writes a record that shares the older record's modules, and the replay after the rewrite builds it. Without the fix the run reports the record written after the eviction was not replayed: 0 graphics built, 1 rejected and the load line reads loaded 1 pipelines and 0 modules.
    • a record that cannot fit under the cap leaves the journal alone: a compute program whose result carries 1.6 MB of user words is recorded into a journal that already holds a pipeline. Without the fix the journal shrinks to its 32-byte header (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.
  • agc_driver_pipeline_journal, agc_pipeline_journal and agc_pipeline_journal_long_paths pass (3 of 3), as do agc_driver_graphics and agc_driver_graphics_maps_fallback.
  • Khronos validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R 'agc_driver_pipeline_journal|agc_pipeline_journal' -V): 3 of 3 pass on main a6dcea9279 and on this branch. Neither log reports the layer missing, and neither has a VUID- error.
  • tools/check_conventions.py --base upstream/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #8213, #8365 (both change the journal's record reading; this branch touches the same parse)
  • Fixes: #8309
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce GTX 1660 SUPER, driver 590.48.01, Linux 24.04 (AGC, pipeline journal)
  • AI-assisted: no
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4959036433 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-21T22:09:40Z. --- ### What The pipeline journal could lose the pipelines a title needs most, in two ways. - The replay kept the **first** `APS5_PIPELINE_JOURNAL_ENTRIES` entries 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. - Once the file reached `APS5_PIPELINE_JOURNAL_MAX_MIB` the 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 replay keeps the **last** entries: the pipelines a title built last are the ones its current level needs. - The writer **rewrites the file** when it reaches its size cap. The newest pipelines and the modules they name are kept, the older records are dropped, and the file is replaced atomically. A pipeline whose module the file does not hold is dropped as well, since the replay would reject it. A record that is larger than the cap is not recorded and the file is left as it is. The rewrite happens in the journal's writer thread, under the file lock it already holds, and the counters report what it dropped: ``` [pipeline-journal] <path> reached its size cap; 29 records (0.7 MiB) were dropped and the file was rewritten ``` `APS5_PIPELINE_JOURNAL_MAX_MIB` and `APS5_PIPELINE_JOURNAL_ENTRIES` keep their meaning (the size cap and the number of entries replayed); the debt entry and `ENVIRONMENT.md` describe the new behaviour. ### Tested Linux (Ubuntu 24.04), GCC 16.2.1, NVIDIA GTX 1660 SUPER, driver 590.48.01, Vulkan 1.4.313. - `agc_driver_pipeline_journal` gains four cases: - the replay of a journal with five entries and `APS5_PIPELINE_JOURNAL_ENTRIES=2` builds 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. With `main`'s replay code it fails: `the replay did not build the two newest entries: built 3 compute and 1 graphics, 0 rejected, 0 present, 0 skipped`. - a journal that reaches the cap is rewritten: the file stays under the cap, the newest pipeline survives the rewrite and the oldest does not. With `main`'s writer the file keeps growing and the record is refused (`the journal was not rewritten when it reached its cap`). - the record that triggers the rewrite keeps the modules it shares with the records the rewrite drops: the journal is filled past its cap with records no pipeline needs, a second draw with the same shaders and a different blend state writes a record that shares the older record's modules, and the replay after the rewrite builds it. Without the fix the run reports `the record written after the eviction was not replayed: 0 graphics built, 1 rejected` and the load line reads `loaded 1 pipelines and 0 modules`. - a record that cannot fit under the cap leaves the journal alone: a compute program whose result carries 1.6 MB of user words is recorded into a journal that already holds a pipeline. Without the fix the journal shrinks to its 32-byte header (`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. - `agc_driver_pipeline_journal`, `agc_pipeline_journal` and `agc_pipeline_journal_long_paths` pass (3 of 3), as do `agc_driver_graphics` and `agc_driver_graphics_maps_fallback`. - Khronos validation layer (`VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R 'agc_driver_pipeline_journal|agc_pipeline_journal' -V`): 3 of 3 pass on `main` a6dcea9279b and on this branch. Neither log reports the layer missing, and neither has a `VUID-` error. - `tools/check_conventions.py --base upstream/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #8213, #8365 (both change the journal's record reading; this branch touches the same parse) - [x] Fixes: #8309 - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce GTX 1660 SUPER, driver 590.48.01, Linux 24.04 (AGC, pipeline journal) - [x] AI-assisted: no
00xDisaster commented 2026-10-22 00:06:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-22T00:06:59Z.


The overlap bot is right about #8542 and #9401: this branch changes the same lines that bound the replay, the same two rows of docs/dev/ENVIRONMENT.md and the same debt entry. Here is what each of them touches here and how the three reconcile.

  • PipelineJournal.cpp, the bound (L917-918 on main). #8542 counts graphics and compute entries against two bounds, #9401 raises the bound and grows the store. This branch keeps the last entries instead of the first, so the pipelines a title built last are the ones the replay builds. The three compose: take the entries this branch keeps, then apply whichever bound is in force.
  • PipelineJournal.cpp, the parse (L585 on main). This branch hands the record spans to the writer, which needs them to rewrite the file at the size cap. #8213 and #8365 rewrite the same function to read the modules from the file instead of holding it; the spans are a small addition on top of that, and this branch rebases onto it without a conflict.
  • docs/dev/ENVIRONMENT.md (L338-339) and docs/dev/debt/libSceAgcDriver.md (L100). The two bound rows and the journal's debt entry, one line each.

The branch is rebased onto the current main (a6dcea9279), and the focused tests pass on it and on main with the Khronos validation layer (3 of 3 each, no VUID- error on either side).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329373105 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#issuecomment-6329373105). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-22T00:06:59Z. --- The overlap bot is right about #8542 and #9401: this branch changes the same lines that bound the replay, the same two rows of `docs/dev/ENVIRONMENT.md` and the same debt entry. Here is what each of them touches here and how the three reconcile. - **`PipelineJournal.cpp`, the bound (L917-918 on `main`).** #8542 counts graphics and compute entries against two bounds, #9401 raises the bound and grows the store. This branch keeps the **last** entries instead of the first, so the pipelines a title built last are the ones the replay builds. The three compose: take the entries this branch keeps, then apply whichever bound is in force. - **`PipelineJournal.cpp`, the parse (L585 on `main`).** This branch hands the record spans to the writer, which needs them to rewrite the file at the size cap. #8213 and #8365 rewrite the same function to read the modules from the file instead of holding it; the spans are a small addition on top of that, and this branch rebases onto it without a conflict. - **`docs/dev/ENVIRONMENT.md` (L338-339) and `docs/dev/debt/libSceAgcDriver.md` (L100).** The two bound rows and the journal's debt entry, one line each. The branch is rebased onto the current `main` (a6dcea9279b), and the focused tests pass on it and on `main` with the Khronos validation layer (3 of 3 each, no `VUID-` error on either side).
00xDisaster commented 2026-10-22 00:20:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-22T00:20:15Z.


@milescoviello — this changes the journal's record reading and the bound that #8213, #8365 and #8542 also change, so it is probably yours to look at. It is two parts: the replay keeps the last entries instead of the first (a title's newest pipelines are the ones its current level needs), and the writer rewrites the file at APS5_PIPELINE_JOURNAL_MAX_MIB instead of refusing the record, which is the "later pipelines are never recorded" half of #8309.

The record spans the writer needs are a small addition to the parse that #8213 rewrites, and the branch is rebased onto the current main; what is left to reconcile with #8542 and #9401 is the bound line and the two documentation rows.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329558388 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#issuecomment-6329558388). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-22T00:20:15Z. --- @milescoviello — this changes the journal's record reading and the bound that #8213, #8365 and #8542 also change, so it is probably yours to look at. It is two parts: the replay keeps the **last** entries instead of the first (a title's newest pipelines are the ones its current level needs), and the writer rewrites the file at `APS5_PIPELINE_JOURNAL_MAX_MIB` instead of refusing the record, which is the "later pipelines are never recorded" half of #8309. The record spans the writer needs are a small addition to the parse that #8213 rewrites, and the branch is rebased onto the current `main`; what is left to reconcile with #8542 and #9401 is the bound line and the two documentation rows.
milescoviello commented 2026-10-22 00:25:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T00:25:06Z.

Review: COMMENTED


@00xDisaster thanks for the ping. I read the eviction against #8213, #8365 and #8542. One thing looks wrong to me, plus a note.

The record that triggers an eviction can lose its modules. In append, newModules and batch are built at the top, against writtenModules. A module that is already in the file isn't put in the batch. Then, when overCap, evictUnderLock(batch.size()) rebuilds the file around the records it keeps, and keeps only the modules those records need. The pending record isn't in the file yet, so any module it shares with an evicted older record is dropped, and writtenModules is reset to keptModules. append then writes the batch built before the eviction, which doesn't contain that module. So the newest record, the one the eviction is meant to make room for, is written without one of its modules. writtenRecords now holds its hash, so it is never written again, and at replay it can't be built.

A way to close it: after a successful evictUnderLock, return false, so the caller rebuilds the batch against the new writtenModules. That's the same path as when the file was cut. Or rebuild newModules and batch in place. A test case would be a record whose stage module was first written by an older record that the eviction drops; the test could check that the record replays after the rewrite.

A note on #8213: it keeps the journal open for the replay and reads module payloads by offset: an fd on Linux, a handle with FILE_SHARE_DELETE on Windows. On Linux the rename leaves that fd on the old inode, so a rewrite in the middle of a replay is safe. On Windows MoveFileExW over a file that's still open may fail; you already handle that by falling back to "not recorded". So the two compose. Whichever lands second only re-adds RecordSpan collection to the streaming parse.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607836308 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#pullrequestreview-5607836308). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-22T00:25:06Z. **Review:** COMMENTED --- @00xDisaster thanks for the ping. I read the eviction against #8213, #8365 and #8542. One thing looks wrong to me, plus a note. **The record that triggers an eviction can lose its modules.** In `append`, `newModules` and `batch` are built at the top, against `writtenModules`. A module that is already in the file isn't put in the batch. Then, when `overCap`, `evictUnderLock(batch.size())` rebuilds the file around the records it keeps, and keeps only the modules *those* records need. The pending record isn't in the file yet, so any module it shares with an evicted older record is dropped, and `writtenModules` is reset to `keptModules`. `append` then writes the batch built before the eviction, which doesn't contain that module. So the newest record, the one the eviction is meant to make room for, is written without one of its modules. `writtenRecords` now holds its hash, so it is never written again, and at replay it can't be built. A way to close it: after a successful `evictUnderLock`, `return false`, so the caller rebuilds the batch against the new `writtenModules`. That's the same path as when the file was cut. Or rebuild `newModules` and `batch` in place. A test case would be a record whose stage module was first written by an older record that the eviction drops; the test could check that the record replays after the rewrite. **A note on #8213:** it keeps the journal open for the replay and reads module payloads by offset: an fd on Linux, a handle with `FILE_SHARE_DELETE` on Windows. On Linux the rename leaves that fd on the old inode, so a rewrite in the middle of a replay is safe. On Windows `MoveFileExW` over a file that's still open may fail; you already handle that by falling back to "not recorded". So the two compose. Whichever lands second only re-adds `RecordSpan` collection to the streaming parse. AI-assisted: yes (Claude Code)
00xDisaster commented 2026-10-22 01:13:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-22T01:13:53Z.


You are right, and thank you for reading it that closely. The record that triggers the eviction did lose its modules: the batch was built before the eviction, so it held no module the file already had, while the file the eviction wrote had none either, and writtenModules was reset to the modules the kept records needed. The record was then written with its hash in writtenRecords and could never be replayed.

The fix follows the path you named, with one addition:

  • The writer reserves room for the whole record, the modules it names included, not only the modules the file lacks. Without that, the batch the eviction makes room for is the rebuilt one, which can be larger than the batch the eviction was asked to make room for, and the record would be lost a second time.
  • After a successful eviction the writer returns false, the same path as a file that was cut, so the caller rebuilds the batch against the file the eviction wrote. The modules the eviction dropped are in the batch again, and the record is written complete.

The test you asked for is in agc_driver_pipeline_journal: a record whose stage module was first written by an older record that the eviction drops. The journal is filled past its cap with records no pipeline needs, a second draw with the same shaders and a different blend state writes a record that shares the older record's modules, and the replay after the rewrite must build it. Without the fix the run reports the record written after the eviction was not replayed: 0 graphics built, 1 rejected and the load line shows loaded 1 pipelines and 0 modules; with the fix it loads 1 pipelines and 2 modules and the pipeline is built.

On #8213: the rewrite goes through MoveFileExW with MOVEFILE_REPLACE_EXISTING on Windows, so it replaces the file that #8213 keeps open with FILE_SHARE_DELETE, and the fd on Linux stays on the old inode. When the replacement fails, the eviction reports that the journal is full and the record is not recorded, as you described.

The branch is rebased onto the current main (a6dcea9279), the focused tests pass on it and on main with the validation layer (3 of 3 each, no VUID-), and tools/check_conventions.py --base upstream/main is clean.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330263603 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#issuecomment-6330263603). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-22T01:13:53Z. --- You are right, and thank you for reading it that closely. The record that triggers the eviction did lose its modules: the batch was built before the eviction, so it held no module the file already had, while the file the eviction wrote had none either, and `writtenModules` was reset to the modules the kept records needed. The record was then written with its hash in `writtenRecords` and could never be replayed. The fix follows the path you named, with one addition: - The writer reserves room for the **whole** record, the modules it names included, not only the modules the file lacks. Without that, the batch the eviction makes room for is the rebuilt one, which can be larger than the batch the eviction was asked to make room for, and the record would be lost a second time. - After a successful eviction the writer returns false, the same path as a file that was cut, so the caller rebuilds the batch against the file the eviction wrote. The modules the eviction dropped are in the batch again, and the record is written complete. The test you asked for is in `agc_driver_pipeline_journal`: a record whose stage module was first written by an older record that the eviction drops. The journal is filled past its cap with records no pipeline needs, a second draw with the same shaders and a different blend state writes a record that shares the older record's modules, and the replay after the rewrite must build it. Without the fix the run reports `the record written after the eviction was not replayed: 0 graphics built, 1 rejected` and the load line shows `loaded 1 pipelines and 0 modules`; with the fix it loads `1 pipelines and 2 modules` and the pipeline is built. On #8213: the rewrite goes through `MoveFileExW` with `MOVEFILE_REPLACE_EXISTING` on Windows, so it replaces the file that #8213 keeps open with `FILE_SHARE_DELETE`, and the fd on Linux stays on the old inode. When the replacement fails, the eviction reports that the journal is full and the record is not recorded, as you described. The branch is rebased onto the current `main` (a6dcea9279b), the focused tests pass on it and on `main` with the validation layer (3 of 3 each, no `VUID-`), and `tools/check_conventions.py --base upstream/main` is clean.
milescoviello commented 2026-10-22 01:24:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T01:24:18Z.


@00xDisaster thanks, I read 4472daa36a (not built or run here yet). Reserving the whole record and returning false after the eviction closes the loss I described: the rebuilt batch is taken against the rewritten file, so the dropped modules come back, and needed already covers them.

Two smaller points, neither blocking:

  • append now encodes every module of every record before the cap check, including the ones the file already holds. Before, only the missing ones were encoded. That's only needed to size an eviction. It's on the writer thread, so it's off the game's path, but the encode could happen only when overCap is true.
  • An eviction now uses one of write's two attempts. If the same write first cuts a torn tail (attempt 0 returns false), then needs an eviction (attempt 1 returns false), it throws "the journal keeps changing under this run" and drops the record. A third attempt, or not counting the eviction's retry, would cover that. It's rare: a torn tail and a full journal in the same write.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330402458 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#issuecomment-6330402458). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-22T01:24:18Z. --- @00xDisaster thanks, I read `4472daa36a` (not built or run here yet). Reserving the whole record and returning false after the eviction closes the loss I described: the rebuilt batch is taken against the rewritten file, so the dropped modules come back, and `needed` already covers them. Two smaller points, neither blocking: - `append` now encodes every module of every record before the cap check, including the ones the file already holds. Before, only the missing ones were encoded. That's only needed to size an eviction. It's on the writer thread, so it's off the game's path, but the encode could happen only when `overCap` is true. - An eviction now uses one of `write`'s two attempts. If the same write first cuts a torn tail (attempt 0 returns false), then needs an eviction (attempt 1 returns false), it throws "the journal keeps changing under this run" and drops the record. A third attempt, or not counting the eviction's retry, would cover that. It's rare: a torn tail and a full journal in the same write. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-10-22 01:33:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:33:54Z.

Code review location: core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp; line 802

@@ -729,37 +787,115 @@ class Journal {
         throw std::runtime_error("the journal keeps changing under this run");
     }
 
+    bool evictUnderLock(std::size_t reserve) {
+        std::vector<std::byte> file;
+        if (!ShaderRecompiler::ReadWholeFile(path, file)) return false;
+        LoadedJournal index;
+        std::vector<RecordSpan> spans;
+        parse(file, nullptr, index, false, &spans);
+        if (!index.headerValid) return false;
+        std::map<ShaderRecompiler::PipelineIdentity, std::size_t> moduleSpans;
+        for (std::size_t position = 0; position < spans.size(); ++position) {
+            if (spans[position].kind == ModuleRecord) moduleSpans[spans[position].identity] = position;
+        }
+        const auto headerBytes = padded(sizeof(FileHeader));
+        const auto budget = maxBytes > reserve ? maxBytes - reserve : std::uint64_t{0};

If one pending record and its modules require at least the configured cap, this budget is zero or below the header size. The loop then keeps no existing records, rewrites the journal to just its header, and returns for a retry; the same oversized record still cannot fit, so it is dropped after the retry. For example, with APS5_PIPELINE_JOURNAL_MAX_MIB=1, a record larger than 1 MiB can erase previously usable journal entries even though that incoming record is never saved. Please detect an intrinsically oversized batch before eviction, preserve the existing journal, count/report the skipped record, and add a regression that proves the previous records survive.

<!-- greyfinch-sync:boykopovar/AnyPS5:review-comment:4343702343 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#discussion_r4343702343). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:33:54Z. **Code review location:** `core/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cpp`; line 802 ~~~~diff @@ -729,37 +787,115 @@ class Journal { throw std::runtime_error("the journal keeps changing under this run"); } + bool evictUnderLock(std::size_t reserve) { + std::vector<std::byte> file; + if (!ShaderRecompiler::ReadWholeFile(path, file)) return false; + LoadedJournal index; + std::vector<RecordSpan> spans; + parse(file, nullptr, index, false, &spans); + if (!index.headerValid) return false; + std::map<ShaderRecompiler::PipelineIdentity, std::size_t> moduleSpans; + for (std::size_t position = 0; position < spans.size(); ++position) { + if (spans[position].kind == ModuleRecord) moduleSpans[spans[position].identity] = position; + } + const auto headerBytes = padded(sizeof(FileHeader)); + const auto budget = maxBytes > reserve ? maxBytes - reserve : std::uint64_t{0}; ~~~~ --- If one pending record and its modules require at least the configured cap, this budget is zero or below the header size. The loop then keeps no existing records, rewrites the journal to just its header, and returns for a retry; the same oversized record still cannot fit, so it is dropped after the retry. For example, with `APS5_PIPELINE_JOURNAL_MAX_MIB=1`, a record larger than 1 MiB can erase previously usable journal entries even though that incoming record is never saved. Please detect an intrinsically oversized batch before eviction, preserve the existing journal, count/report the skipped record, and add a regression that proves the previous records survive.
MarcZX10 commented 2026-10-22 01:33:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:33:55Z.

Code review location: core/libs/prx/libSceAgcDriver/tests/execution/PipelineJournal.cpp; line 547

@@ -395,6 +397,210 @@ void Benchmark(std::uint32_t count) {
     std::printf("  warm driver cache, journal:     %llu pipelines built by the replay in %.1f ms of replay work (%.1f ms from the device opening), then %llu built at their dispatches, %u dispatches in %.1f ms (%.2f ms each)\n", static_cast<unsigned long long>(replayed.journal.replayedCompute), replayed.journal.replayMs, replayed.openMs, static_cast<unsigned long long>(replayed.created), count, replayed.dispatchMs, replayed.dispatchMs / count);
 }
 
+struct JournalRecordHeader {
+    std::uint32_t kind;
+    std::uint32_t reserved;
+    std::uint64_t payloadBytes;
+    std::uint64_t payloadHash;
+};
+static_assert(sizeof(JournalRecordHeader) == 24);
+
+constexpr std::uint32_t JournalModuleRecord = 1u;
+constexpr std::uint32_t JournalComputeRecord = 3u;
+constexpr std::uint32_t JournalHeaderBytes = 32u;
+
+void AppendJournalRecord(std::vector<std::byte>& file, std::uint32_t kind, const std::vector<std::byte>& payload) {
+    const JournalRecordHeader header{kind, 0u, payload.size(), ShaderRecompiler::HashBytes(payload)};
+    const auto offset = file.size();
+    file.resize(offset + sizeof(header) + payload.size());
+    std::memcpy(file.data() + offset, &header, sizeof(header));
+    std::memcpy(file.data() + offset + sizeof(header), payload.data(), payload.size());
+    while ((file.size() - offset - sizeof(header)) % 8u != 0) file.push_back(std::byte{0});
+}
+
+std::vector<ShaderRecompiler::PipelineIdentity> ReadJournalComputeIdentities(const std::filesystem::path& path) {
+    std::vector<std::byte> file;
+    std::ifstream input(path, std::ios::binary);
+    const std::vector<char> bytes((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
+    file.reserve(bytes.size());
+    for (const auto byte : bytes) file.push_back(static_cast<std::byte>(byte));
+    std::vector<ShaderRecompiler::PipelineIdentity> identities;
+    std::size_t cursor = JournalHeaderBytes;
+    while (cursor + sizeof(JournalRecordHeader) <= file.size()) {
+        JournalRecordHeader header{};
+        std::memcpy(&header, file.data() + cursor, sizeof(header));
+        const auto payload = cursor + sizeof(header);
+        if (header.payloadBytes > file.size() - payload) break;
+        if (header.kind == JournalComputeRecord && header.payloadBytes >= 17u) {
+            ShaderRecompiler::PipelineIdentity identity;
+            std::memcpy(&identity.low, file.data() + payload, sizeof(identity.low));
+            std::memcpy(&identity.high, file.data() + payload + 8, sizeof(identity.high));
+            identities.push_back(identity);
+        }
+        cursor = payload + header.payloadBytes;
+        while (cursor % 8u != 0) ++cursor;
+    }
+    return identities;
+}
+
+void NewestEntriesTests() {
+    using namespace NarrowConstantStoreFixture;
+    Block compute(BlockBytes);
+    const auto words = AddressWords(compute);
+    const auto recorded = Snapshot();
+    {
+        const auto device = OpenVulkanTestDevice();
+        Require(device != nullptr, "the device for the newest entries test could not be opened");
+        device->WaitForPipelineJournalReplay();
+        for (std::uint32_t salt = 1; salt <= 3; ++salt) {
+            const auto code = ComputeCode(salt);
+            const auto result = CompileCompute(*device, code, words, 32);
+            device->Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data()));
+        }
+        device->WaitIdle();
+        AgcDriver::Graphics::FlushPipelineJournal();
+        const auto after = Snapshot();
+        Require(after.journal.recordedCompute == recorded.journal.recordedCompute + 3, "the three compute pipelines were not recorded");
+    }
+    SetEnvironment("APS5_PIPELINE_JOURNAL_ENTRIES", "2");
+    const auto before = Snapshot();
+    {
+        const auto device = OpenVulkanTestDevice();
+        Require(device != nullptr, "the device for the newest entries replay could not be opened");
+        device->WaitForPipelineJournalReplay();
+        const auto replayed = Snapshot();
+        Require(replayed.journal.replayedCompute == before.journal.replayedCompute + 2, "the replay did not build the two newest entries: built " + std::to_string(replayed.journal.replayedCompute - before.journal.replayedCompute) + " compute and " + std::to_string(replayed.journal.replayedGraphics - before.journal.replayedGraphics) + " graphics, " + std::to_string(replayed.journal.replayRejected - before.journal.replayRejected) + " rejected, " + std::to_string(replayed.journal.replayPresent - before.journal.replayPresent) + " present, " + std::to_string(replayed.journal.replaySkipped - before.journal.replaySkipped) + " skipped");
+        Require(replayed.journal.replayedGraphics == before.journal.replayedGraphics, "the replay built an entry that is not among the newest");
+        const auto created = device->ComputePipelinesCreated();
+        const auto newest = ComputeCode(3);
+        const auto result = CompileCompute(*device, newest, words, 32);
+        device->Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(newest.data()));
+        device->WaitIdle();
+        Require(device->ComputePipelinesCreated() == created, "the newest pipeline was not built by the replay");
+        const auto oldest = ComputeCode(0);
+        const auto old = CompileCompute(*device, oldest, words, 32);
+        device->Dispatch(old, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(oldest.data()));
+        device->WaitIdle();
+        Require(device->ComputePipelinesCreated() == created + 1, "the oldest pipeline was built by the replay");
+    }
+    SetEnvironment("APS5_PIPELINE_JOURNAL_ENTRIES", "1024");
+}
+
+void EvictionTests() {
+    using namespace NarrowConstantStoreFixture;
+    const auto path = AgcDriver::Graphics::PipelineJournalPath();
+    AgcDriver::Graphics::FlushPipelineJournal();
+    constexpr std::size_t Modules = 24;
+    constexpr std::size_t ModuleBytes = 64u * 1024u;
+    std::vector<std::byte> file;
+    for (std::size_t index = 0; index < Modules; ++index) {
+        std::vector<std::byte> module(20u + ModuleBytes, std::byte{0x5a});
+        const std::uint64_t low = index + 1u;
+        const std::uint64_t high = 0u;
+        std::memcpy(module.data(), &low, sizeof(low));
+        std::memcpy(module.data() + 8, &high, sizeof(high));
+        AppendJournalRecord(file, JournalModuleRecord, module);
+        std::vector<std::byte> compute(17u, std::byte{0});
+        std::memcpy(compute.data(), &low, sizeof(low));
+        std::memcpy(compute.data() + 8, &high, sizeof(high));
+        AppendJournalRecord(file, JournalComputeRecord, compute);
+    }
+    {
+        std::ofstream out(path, std::ios::binary | std::ios::app);
+        Require(static_cast<bool>(out), "the synthetic journal records could not be written");
+        out.write(reinterpret_cast<const char*>(file.data()), static_cast<std::streamsize>(file.size()));
+        out.flush();
+        Require(!out.fail(), "the synthetic journal records could not be written");
+    }
+    Require(std::filesystem::file_size(path) > 1024u * 1024u, "the journal is smaller than the cap");
+    const auto before = Snapshot();
+    {
+        const auto device = OpenVulkanTestDevice();
+        Require(device != nullptr, "the device for the eviction test could not be opened");
+        device->WaitForPipelineJournalReplay();
+        Block compute(BlockBytes);
+        Block target(ColorTargetLayout(Width, Height, ColorTileMode::Linear, 2).Bytes());
+        const auto words = AddressWords(compute);
+        const auto code = ComputeCode(7);
+        const auto result = CompileCompute(*device, code, words, 32);
+        device->Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data()));
+        device->WaitIdle();
+        std::memset(target.data, 0, target.bytes);
+        Draw(*device, DecodeTarget(target), Program(std::array<float, 4>{1.0f, 0.0f, 0.0f, 1.0f}));
+        device->WaitIdle();
+        AgcDriver::Graphics::FlushPipelineJournal();
+    }
+    const auto after = Snapshot();
+    Require(after.journal.evictedRecords > before.journal.evictedRecords, "the journal was not rewritten when it reached its cap: " + std::to_string(after.journal.evictedRecords) + " records evicted, " + std::to_string(after.journal.writeFailures - before.journal.writeFailures) + " write failures");
+    const auto size = std::filesystem::file_size(path);
+    Require(size <= 1024u * 1024u + 64u * 1024u, "the rewritten journal is larger than the cap");
+    const auto identities = ReadJournalComputeIdentities(path);
+    Require(!identities.empty(), "the rewritten journal holds no compute pipeline");
+    bool newest = false;
+    for (const auto& identity : identities) {
+        if (identity.low == Modules) newest = true;
+        Require(identity.low != 1u, "the oldest pipeline survived the rewrite");
+    }
+    Require(newest, "the newest pipeline did not survive the rewrite");
+}
+
+// The record that triggers an eviction must keep the modules it shares with the records the

This is a new C++ source comment, while the workspace review instructions prohibit code comments except #endif and namespace endings. The PR also changes technical debt, but the local AGENTS rule is stricter. Please move this rationale to the PR description or debt entry and remove the test-source comment.

<!-- greyfinch-sync:boykopovar/AnyPS5:review-comment:4343702401 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#discussion_r4343702401). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:33:55Z. **Code review location:** `core/libs/prx/libSceAgcDriver/tests/execution/PipelineJournal.cpp`; line 547 ~~~~diff @@ -395,6 +397,210 @@ void Benchmark(std::uint32_t count) { std::printf(" warm driver cache, journal: %llu pipelines built by the replay in %.1f ms of replay work (%.1f ms from the device opening), then %llu built at their dispatches, %u dispatches in %.1f ms (%.2f ms each)\n", static_cast<unsigned long long>(replayed.journal.replayedCompute), replayed.journal.replayMs, replayed.openMs, static_cast<unsigned long long>(replayed.created), count, replayed.dispatchMs, replayed.dispatchMs / count); } +struct JournalRecordHeader { + std::uint32_t kind; + std::uint32_t reserved; + std::uint64_t payloadBytes; + std::uint64_t payloadHash; +}; +static_assert(sizeof(JournalRecordHeader) == 24); + +constexpr std::uint32_t JournalModuleRecord = 1u; +constexpr std::uint32_t JournalComputeRecord = 3u; +constexpr std::uint32_t JournalHeaderBytes = 32u; + +void AppendJournalRecord(std::vector<std::byte>& file, std::uint32_t kind, const std::vector<std::byte>& payload) { + const JournalRecordHeader header{kind, 0u, payload.size(), ShaderRecompiler::HashBytes(payload)}; + const auto offset = file.size(); + file.resize(offset + sizeof(header) + payload.size()); + std::memcpy(file.data() + offset, &header, sizeof(header)); + std::memcpy(file.data() + offset + sizeof(header), payload.data(), payload.size()); + while ((file.size() - offset - sizeof(header)) % 8u != 0) file.push_back(std::byte{0}); +} + +std::vector<ShaderRecompiler::PipelineIdentity> ReadJournalComputeIdentities(const std::filesystem::path& path) { + std::vector<std::byte> file; + std::ifstream input(path, std::ios::binary); + const std::vector<char> bytes((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>()); + file.reserve(bytes.size()); + for (const auto byte : bytes) file.push_back(static_cast<std::byte>(byte)); + std::vector<ShaderRecompiler::PipelineIdentity> identities; + std::size_t cursor = JournalHeaderBytes; + while (cursor + sizeof(JournalRecordHeader) <= file.size()) { + JournalRecordHeader header{}; + std::memcpy(&header, file.data() + cursor, sizeof(header)); + const auto payload = cursor + sizeof(header); + if (header.payloadBytes > file.size() - payload) break; + if (header.kind == JournalComputeRecord && header.payloadBytes >= 17u) { + ShaderRecompiler::PipelineIdentity identity; + std::memcpy(&identity.low, file.data() + payload, sizeof(identity.low)); + std::memcpy(&identity.high, file.data() + payload + 8, sizeof(identity.high)); + identities.push_back(identity); + } + cursor = payload + header.payloadBytes; + while (cursor % 8u != 0) ++cursor; + } + return identities; +} + +void NewestEntriesTests() { + using namespace NarrowConstantStoreFixture; + Block compute(BlockBytes); + const auto words = AddressWords(compute); + const auto recorded = Snapshot(); + { + const auto device = OpenVulkanTestDevice(); + Require(device != nullptr, "the device for the newest entries test could not be opened"); + device->WaitForPipelineJournalReplay(); + for (std::uint32_t salt = 1; salt <= 3; ++salt) { + const auto code = ComputeCode(salt); + const auto result = CompileCompute(*device, code, words, 32); + device->Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data())); + } + device->WaitIdle(); + AgcDriver::Graphics::FlushPipelineJournal(); + const auto after = Snapshot(); + Require(after.journal.recordedCompute == recorded.journal.recordedCompute + 3, "the three compute pipelines were not recorded"); + } + SetEnvironment("APS5_PIPELINE_JOURNAL_ENTRIES", "2"); + const auto before = Snapshot(); + { + const auto device = OpenVulkanTestDevice(); + Require(device != nullptr, "the device for the newest entries replay could not be opened"); + device->WaitForPipelineJournalReplay(); + const auto replayed = Snapshot(); + Require(replayed.journal.replayedCompute == before.journal.replayedCompute + 2, "the replay did not build the two newest entries: built " + std::to_string(replayed.journal.replayedCompute - before.journal.replayedCompute) + " compute and " + std::to_string(replayed.journal.replayedGraphics - before.journal.replayedGraphics) + " graphics, " + std::to_string(replayed.journal.replayRejected - before.journal.replayRejected) + " rejected, " + std::to_string(replayed.journal.replayPresent - before.journal.replayPresent) + " present, " + std::to_string(replayed.journal.replaySkipped - before.journal.replaySkipped) + " skipped"); + Require(replayed.journal.replayedGraphics == before.journal.replayedGraphics, "the replay built an entry that is not among the newest"); + const auto created = device->ComputePipelinesCreated(); + const auto newest = ComputeCode(3); + const auto result = CompileCompute(*device, newest, words, 32); + device->Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(newest.data())); + device->WaitIdle(); + Require(device->ComputePipelinesCreated() == created, "the newest pipeline was not built by the replay"); + const auto oldest = ComputeCode(0); + const auto old = CompileCompute(*device, oldest, words, 32); + device->Dispatch(old, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(oldest.data())); + device->WaitIdle(); + Require(device->ComputePipelinesCreated() == created + 1, "the oldest pipeline was built by the replay"); + } + SetEnvironment("APS5_PIPELINE_JOURNAL_ENTRIES", "1024"); +} + +void EvictionTests() { + using namespace NarrowConstantStoreFixture; + const auto path = AgcDriver::Graphics::PipelineJournalPath(); + AgcDriver::Graphics::FlushPipelineJournal(); + constexpr std::size_t Modules = 24; + constexpr std::size_t ModuleBytes = 64u * 1024u; + std::vector<std::byte> file; + for (std::size_t index = 0; index < Modules; ++index) { + std::vector<std::byte> module(20u + ModuleBytes, std::byte{0x5a}); + const std::uint64_t low = index + 1u; + const std::uint64_t high = 0u; + std::memcpy(module.data(), &low, sizeof(low)); + std::memcpy(module.data() + 8, &high, sizeof(high)); + AppendJournalRecord(file, JournalModuleRecord, module); + std::vector<std::byte> compute(17u, std::byte{0}); + std::memcpy(compute.data(), &low, sizeof(low)); + std::memcpy(compute.data() + 8, &high, sizeof(high)); + AppendJournalRecord(file, JournalComputeRecord, compute); + } + { + std::ofstream out(path, std::ios::binary | std::ios::app); + Require(static_cast<bool>(out), "the synthetic journal records could not be written"); + out.write(reinterpret_cast<const char*>(file.data()), static_cast<std::streamsize>(file.size())); + out.flush(); + Require(!out.fail(), "the synthetic journal records could not be written"); + } + Require(std::filesystem::file_size(path) > 1024u * 1024u, "the journal is smaller than the cap"); + const auto before = Snapshot(); + { + const auto device = OpenVulkanTestDevice(); + Require(device != nullptr, "the device for the eviction test could not be opened"); + device->WaitForPipelineJournalReplay(); + Block compute(BlockBytes); + Block target(ColorTargetLayout(Width, Height, ColorTileMode::Linear, 2).Bytes()); + const auto words = AddressWords(compute); + const auto code = ComputeCode(7); + const auto result = CompileCompute(*device, code, words, 32); + device->Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data())); + device->WaitIdle(); + std::memset(target.data, 0, target.bytes); + Draw(*device, DecodeTarget(target), Program(std::array<float, 4>{1.0f, 0.0f, 0.0f, 1.0f})); + device->WaitIdle(); + AgcDriver::Graphics::FlushPipelineJournal(); + } + const auto after = Snapshot(); + Require(after.journal.evictedRecords > before.journal.evictedRecords, "the journal was not rewritten when it reached its cap: " + std::to_string(after.journal.evictedRecords) + " records evicted, " + std::to_string(after.journal.writeFailures - before.journal.writeFailures) + " write failures"); + const auto size = std::filesystem::file_size(path); + Require(size <= 1024u * 1024u + 64u * 1024u, "the rewritten journal is larger than the cap"); + const auto identities = ReadJournalComputeIdentities(path); + Require(!identities.empty(), "the rewritten journal holds no compute pipeline"); + bool newest = false; + for (const auto& identity : identities) { + if (identity.low == Modules) newest = true; + Require(identity.low != 1u, "the oldest pipeline survived the rewrite"); + } + Require(newest, "the newest pipeline did not survive the rewrite"); +} + +// The record that triggers an eviction must keep the modules it shares with the records the ~~~~ --- This is a new C++ source comment, while the workspace review instructions prohibit code comments except `#endif` and namespace endings. The PR also changes technical debt, but the local AGENTS rule is stricter. Please move this rationale to the PR description or debt entry and remove the test-source comment.
MarcZX10 commented 2026-10-22 01:33:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:33:56Z.

Review: CHANGES_REQUESTED


The reported validation-layer comparisons and focused tests are detailed, and the reviewer’s latest comment confirms the previously found pending-module loss is fixed. Hosted checks currently show conventions and labels passing; the full CI matrix is not present on this head, so I am relying on the reported same-GPU main/change runs rather than claiming additional tests here. I found one remaining data-loss case in the eviction path: if the incoming record plus its modules exceeds the configured journal cap, evictUnderLock reduces the budget below the header, rewrites away all existing records, then the retry still cannot fit the incoming record. With a valid small cap such as 1 MiB, a larger encoded record therefore wipes the useful journal and is still dropped. Please reject an intrinsically oversized batch before eviction, preserve existing entries, and add a regression for that case. Also remove the added test-source comment, which conflicts with the workspace AGENTS rule prohibiting code comments except #endif and namespace endings.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608253833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#pullrequestreview-5608253833). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:33:56Z. **Review:** CHANGES_REQUESTED --- The reported validation-layer comparisons and focused tests are detailed, and the reviewer’s latest comment confirms the previously found pending-module loss is fixed. Hosted checks currently show conventions and labels passing; the full CI matrix is not present on this head, so I am relying on the reported same-GPU main/change runs rather than claiming additional tests here. I found one remaining data-loss case in the eviction path: if the incoming record plus its modules exceeds the configured journal cap, `evictUnderLock` reduces the budget below the header, rewrites away all existing records, then the retry still cannot fit the incoming record. With a valid small cap such as 1 MiB, a larger encoded record therefore wipes the useful journal and is still dropped. Please reject an intrinsically oversized batch before eviction, preserve existing entries, and add a regression for that case. Also remove the added test-source comment, which conflicts with the workspace AGENTS rule prohibiting code comments except `#endif` and namespace endings.
MarcZX10 commented 2026-10-22 01:44:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:44:23Z.

Review: CHANGES_REQUESTED


I rechecked head 4472daa36a after the pending-module fix. That fix addresses the earlier record/module loss, but the oversized-record data-loss case from my prior review remains.

needed now reserves the entire incoming pipeline plus module records. In evictUnderLock, when headerBytes + reserve is greater than the configured cap, budget becomes zero and used starts at headerBytes; the reverse scan keeps no records, then replaces the existing journal with a header-only file. The retry cannot fit that incoming batch either, so the write is ultimately dropped after the existing valuable journal has already been erased. This can also happen when the batch is smaller than the cap but leaves less than headerBytes available. Please reject a batch that cannot fit alongside the header before calling eviction, preserve the existing journal in that case, and add a regression that verifies both the rejected batch and byte-for-byte preservation of the prior journal.

The new test also adds a C++ explanatory comment, which conflicts with the workspace review instruction prohibiting code comments except #endif and namespace endings; please remove it. Finally, this branch is based on a6dcea9279b53b3a39c13695eac66f7c8b5b503c, while current main is 94fbb8cea80af91db62ab6ee7e4da23341675c40; please update/rebase and rerun the relevant validation. The latest hosted checks show conventions and labels passing, but do not show the author-reported Vulkan validation or focused test suite for this new head; I did not run a local build.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608317164 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#pullrequestreview-5608317164). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:44:23Z. **Review:** CHANGES_REQUESTED --- I rechecked head `4472daa36a` after the pending-module fix. That fix addresses the earlier record/module loss, but the oversized-record data-loss case from my prior review remains. `needed` now reserves the entire incoming pipeline plus module records. In `evictUnderLock`, when `headerBytes + reserve` is greater than the configured cap, `budget` becomes zero and `used` starts at `headerBytes`; the reverse scan keeps no records, then replaces the existing journal with a header-only file. The retry cannot fit that incoming batch either, so the write is ultimately dropped after the existing valuable journal has already been erased. This can also happen when the batch is smaller than the cap but leaves less than `headerBytes` available. Please reject a batch that cannot fit alongside the header before calling eviction, preserve the existing journal in that case, and add a regression that verifies both the rejected batch and byte-for-byte preservation of the prior journal. The new test also adds a C++ explanatory comment, which conflicts with the workspace review instruction prohibiting code comments except `#endif` and namespace endings; please remove it. Finally, this branch is based on `a6dcea9279b53b3a39c13695eac66f7c8b5b503c`, while current `main` is `94fbb8cea80af91db62ab6ee7e4da23341675c40`; please update/rebase and rerun the relevant validation. The latest hosted checks show conventions and labels passing, but do not show the author-reported Vulkan validation or focused test suite for this new head; I did not run a local build.
MarcZX10 commented 2026-10-22 01:50:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:50:29Z.

Review: CHANGES_REQUESTED


I rechecked the new head a92fd3f824. The added budget < headerBytes guard returns before replacement, and OversizedRecordKeepsTheJournal checks the existing file size and replay after an oversized write; the prohibited test comment is also removed. That resolves the journal-erasure and comment findings from my prior review.

Two validation items remain. This head is still based on a6dcea9279b53b3a39c13695eac66f7c8b5b503c; current main is df2569d2c5fc6adb68f6eb8b56ad0d0ddf35686b, so it does not meet the current-main rule. Please rebase/update and rerun the focused journal tests. Also, the PR’s Tested section still lists only the prior three cases and does not report running the new oversized-record regression on this head. Since this changes AGC journal behavior, please include that test in the same-machine main/branch Vulkan-validation comparison and report the missing-layer/VUID result for the updated head. The current hosted checks show conventions and labels passing; product build jobs are not present. I have not run a local build.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608351303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#pullrequestreview-5608351303). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:50:29Z. **Review:** CHANGES_REQUESTED --- I rechecked the new head `a92fd3f824`. The added `budget < headerBytes` guard returns before replacement, and `OversizedRecordKeepsTheJournal` checks the existing file size and replay after an oversized write; the prohibited test comment is also removed. That resolves the journal-erasure and comment findings from my prior review. Two validation items remain. This head is still based on `a6dcea9279b53b3a39c13695eac66f7c8b5b503c`; current `main` is `df2569d2c5fc6adb68f6eb8b56ad0d0ddf35686b`, so it does not meet the current-main rule. Please rebase/update and rerun the focused journal tests. Also, the PR’s `Tested` section still lists only the prior three cases and does not report running the new oversized-record regression on this head. Since this changes AGC journal behavior, please include that test in the same-machine `main`/branch Vulkan-validation comparison and report the missing-layer/VUID result for the updated head. The current hosted checks show conventions and labels passing; product build jobs are not present. I have not run a local build.
00xDisaster commented 2026-10-22 01:51:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-22T01:51:08Z.


Both points are fixed in a92fd3f82.

The oversized record: the writer measures the whole record, the modules it names included, before it touches the file, and when the record cannot fit under the cap it leaves the journal as it is, counts the skipped record as a write failure and says so:

[pipeline-journal] <path> cannot hold a record of <n> bytes under APS5_PIPELINE_JOURNAL_MAX_MIB; it is not recorded

The eviction itself now refuses a budget below the header size, so the file can no longer be rewritten to nothing. The regression is in agc_driver_pipeline_journal: a compute program whose result carries 1.6 MB of user words is recorded into a journal that already holds a pipeline. Without the fix the journal shrinks to its 32-byte header (the oversized record emptied the journal: 39888 bytes became 32) and the record is lost with the journal keeps changing under this run; with the fix the file keeps its size, the write failure is counted, and the pipeline that was in the journal still replays.

The comment in the test source is gone; the rationale is in this pull request's description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330751088 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#issuecomment-6330751088). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-22T01:51:08Z. --- Both points are fixed in `a92fd3f82`. The oversized record: the writer measures the whole record, the modules it names included, before it touches the file, and when the record cannot fit under the cap it leaves the journal as it is, counts the skipped record as a write failure and says so: ``` [pipeline-journal] <path> cannot hold a record of <n> bytes under APS5_PIPELINE_JOURNAL_MAX_MIB; it is not recorded ``` The eviction itself now refuses a budget below the header size, so the file can no longer be rewritten to nothing. The regression is in `agc_driver_pipeline_journal`: a compute program whose result carries 1.6 MB of user words is recorded into a journal that already holds a pipeline. Without the fix the journal shrinks to its 32-byte header (`the oversized record emptied the journal: 39888 bytes became 32`) and the record is lost with `the journal keeps changing under this run`; with the fix the file keeps its size, the write failure is counted, and the pipeline that was in the journal still replays. The comment in the test source is gone; the rationale is in this pull request's description.
MarcZX10 commented 2026-10-22 04:39:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:39:59Z.


Thanks for adding the oversized-record regression and the paired Khronos validation run; the current report now covers the missing test and confirms the layer load and matching VUID results. Since that run, upstream main has advanced from a6dcea927 to 110a18ba01. Please update/rebase onto current main and rerun the focused journal/Vulkan comparison and conventions/overlap checks so the prior requested validation applies to the current base. The earlier #8542/#9401/#8213/#8365 merge coordination remains documented in your overlap explanation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6332857486 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9440#issuecomment-6332857486). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:39:59Z. --- Thanks for adding the oversized-record regression and the paired Khronos validation run; the current report now covers the missing test and confirms the layer load and matching VUID results. Since that run, upstream main has advanced from `a6dcea927` to `110a18ba01`. Please update/rebase onto current main and rerun the focused journal/Vulkan comparison and conventions/overlap checks so the prior requested validation applies to the current base. The earlier #8542/#9401/#8213/#8365 merge coordination remains documented in your overlap explanation.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
boykopovar/AnyPS5!9440
No description provided.