perf(pipeline): reuse key storage and hash keys in blocks #1331

Merged
TibixDev merged 2 commits from upstream-pr/1331 into main 2026-10-10 01:00:47 +00:00
TibixDev commented 2026-10-07 23:43:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-07T23:43:12Z.


What

Reuse pipeline-key storage under the existing cache lock. Hash the serialized key in blocks and retain exact key comparison. Cache ownership and eviction rules stay the same.

Related: #1202 also reuses key storage through a separate last-pipeline cache. This smaller change applies to all lookups and also replaces the byte-at-a-time hash. It does not replace that PR's draw scheduling work.

Tested

Fedora 44, Release: graphics tests and RX 6600 pipeline tests with Vulkan validation. Checks key growth and shrinkage, changed state, unidentified shaders, cache clearing, and retained pipeline lifetime.

Earlier paired component tests on our combined branch measured 0.34/0.61/1.37 µs before and 0.16/0.26/0.45 µs after for 0/8/32 attributes. These are warm lookup timings, not game FPS. Windows was not tested.

Checklist

  • Current main; related #1202 checked and described above.
  • One topic.
  • No new code comments.
  • Unsupported paths still throw; UI stubs are documented.
  • No notes, logs, or images in the repository.
  • No new third-party code.
  • General behavior.
  • Depends on: none.
  • AI-assisted: yes.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779819808 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1331). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-07T23:43:12Z. --- ### What Reuse pipeline-key storage under the existing cache lock. Hash the serialized key in blocks and retain exact key comparison. Cache ownership and eviction rules stay the same. Related: #1202 also reuses key storage through a separate last-pipeline cache. This smaller change applies to all lookups and also replaces the byte-at-a-time hash. It does not replace that PR's draw scheduling work. ### Tested Fedora 44, Release: graphics tests and RX 6600 pipeline tests with Vulkan validation. Checks key growth and shrinkage, changed state, unidentified shaders, cache clearing, and retained pipeline lifetime. Earlier paired component tests on our combined branch measured 0.34/0.61/1.37 µs before and 0.16/0.26/0.45 µs after for 0/8/32 attributes. These are warm lookup timings, not game FPS. Windows was not tested. ### Checklist - [x] Current `main`; related #1202 checked and described above. - [x] One topic. - [x] No new code comments. - [x] Unsupported paths still throw; UI stubs are documented. - [x] No notes, logs, or images in the repository. - [x] No new third-party code. - [x] General behavior. - [x] Depends on: none. - [x] AI-assisted: yes.
TibixDev commented 2026-10-08 04:09:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T04:09:44Z.


Isolated measurements for the request in #1324. Baseline: upstream a9ba39c927713cf294b8e1b7877ddb365d3a1d6f. Comparison: that revision plus this PR alone. Both use the same test harness; the baseline has no production changes. Separate shared libraries were checked through the loader.

Linux, Ryzen 5 5600, Fedora 44, GCC 16 Release (-O3 -DNDEBUG), llvmpipe. Runs pinned to CPU 3, in four ABBA cycles: eight processes per version. Each process warms the key, then measures nine passes of 65,536 real CachedPipeline lookups per key size. Medians below are over the eight process medians.

Vertex attributes Main (us/lookup) Main + PR (us/lookup) Less time
0 0.363 0.178 51.0%
8 0.638 0.279 56.3%
32 1.437 0.493 65.7%

The ranges of process medians do not overlap in any case. The key-identity, changed-state, unidentified-shader and cache-lifetime checks pass. The proposed version also passes Vulkan core and synchronization validation without errors.

This measures warmed CPU cache lookups. It does not measure frame time, pipeline compilation or game FPS. Command: agc_driver_recorder_tests --benchmark-pipeline-cache.

AI-assisted measurement and reply.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6052014927 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1331#issuecomment-6052014927). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T04:09:44Z. --- Isolated measurements for the request in #1324. Baseline: upstream `a9ba39c927713cf294b8e1b7877ddb365d3a1d6f`. Comparison: that revision plus this PR alone. Both use the same test harness; the baseline has no production changes. Separate shared libraries were checked through the loader. Linux, Ryzen 5 5600, Fedora 44, GCC 16 Release (`-O3 -DNDEBUG`), llvmpipe. Runs pinned to CPU 3, in four ABBA cycles: eight processes per version. Each process warms the key, then measures nine passes of 65,536 real `CachedPipeline` lookups per key size. Medians below are over the eight process medians. | Vertex attributes | Main (us/lookup) | Main + PR (us/lookup) | Less time | |---|---:|---:|---:| | 0 | 0.363 | 0.178 | 51.0% | | 8 | 0.638 | 0.279 | 56.3% | | 32 | 1.437 | 0.493 | 65.7% | The ranges of process medians do not overlap in any case. The key-identity, changed-state, unidentified-shader and cache-lifetime checks pass. The proposed version also passes Vulkan core and synchronization validation without errors. This measures warmed CPU cache lookups. It does not measure frame time, pipeline compilation or game FPS. Command: `agc_driver_recorder_tests --benchmark-pipeline-cache`. AI-assisted measurement and reply.
oneandonlydean commented 2026-10-09 09:22:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:04Z.


Conflicts with main in Pipeline.cpp and CMakeLists.txt; please rebase. In pipelineKey, keep main's PipelineVariantId() (from #639) in the early return.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078117366 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1331#issuecomment-6078117366). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:04Z. --- Conflicts with main in `Pipeline.cpp` and `CMakeLists.txt`; please rebase. In `pipelineKey`, keep main's `PipelineVariantId()` (from #639) in the early return.
adriadam10 commented 2026-10-09 23:12:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:12:50Z.


Rebased on current main ourselves, keeping PipelineVariantId() in the early return as asked.

Added:

  • agc_pipeline_cache registered in ctest (agc_driver_recorder_tests --pipeline-cache-only). The test was only reachable through a manual flag and the target is EXCLUDE_FROM_ALL, so CI never ran it.

Checked: build and ctest for libSceAgcDriver/libSceAgc green; the new test passes on a local driver and on lavapipe, and fails if the key.clear() in pipelineKey is removed. The timings in the description are not reproduced here. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090843315 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1331#issuecomment-6090843315). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T23:12:50Z. --- Rebased on current `main` ourselves, keeping `PipelineVariantId()` in the early return as asked. Added: - `agc_pipeline_cache` registered in ctest (`agc_driver_recorder_tests --pipeline-cache-only`). The test was only reachable through a manual flag and the target is `EXCLUDE_FROM_ALL`, so CI never ran it. Checked: build and ctest for `libSceAgcDriver`/`libSceAgc` green; the new test passes on a local driver and on lavapipe, and fails if the `key.clear()` in `pipelineKey` is removed. The timings in the description are not reproduced here. Merging once CI is green.
github-actions[bot] commented 2026-10-09 23:14:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T23:14:51Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1547 core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp L382-383
#2469 core/libs/prx/libSceAgcDriver/CMakeLists.txt L493
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090864923 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1331#issuecomment-6090864923). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T23:14:51Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1547 | `core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp` [L382-383](https://github.com/boykopovar/AnyPS5/blob/0c0dc1e98ed295cbef2823a01081f29a2d929aea/core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp#L382-L383) | | | | #2469 | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` [L493](https://github.com/boykopovar/AnyPS5/blob/0c0dc1e98ed295cbef2823a01081f29a2d929aea/core/libs/prx/libSceAgcDriver/CMakeLists.txt#L493) | | |
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!1331
No description provided.