perf(agc): keep a smaller staging pool on system-memory heaps #5893

Merged
ThatsLeo merged 1 commit from upstream-pr/5893 into main 2026-10-15 08:44:41 +00:00
ThatsLeo commented 2026-10-14 14:49:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-14T14:49:39Z.


What

The staging pool's device tier (BufferPool::DeviceBudget, #1147) retains up to max(512 MiB, heap / 8) of idle buffers, sized from the largest device-local heap as if it were video memory. On an integrated GPU that heap is system RAM: 1.4 GiB of idle buffers on an Arc iGPU whose heap is 11.5 GiB, taken from the title.

When every memory type of that heap is host-visible, which is how integrated GPUs report their memory and never true of a discrete GPU (it always has a device-only type), the tier now retains a sixty-fourth of the heap, at least 128 MiB: 180 MiB on that Arc. Discrete GPUs keep today's budget, and APS5_STAGING_POOL_MIB still overrides it.

The storage image cache has the same problem (max(2 GiB, heap / 4), 2.9 GiB there), but #5483 already changes that budget, so it is left to it.

Tested

Fedora 44, GCC 16.2.1, Release, Intel Arc (Meteor Lake iGPU, Mesa 26.2.3 ANV), 15 GiB RAM.

  • ctest on Arc and on lavapipe: 1158 of 1160 pass on both. agc_host_import_sparse fails on plain main here too. guest_kernel_fcntl, new on main, aborted once in each full parallel run and passes alone (5 of 5) and with the 366 guest_ tests in parallel, on this branch and on main. stagingPoolBudgetTests checks a heap of host-visible types (16 GiB gives 256 MiB, 4 GiB the 128 MiB floor) and that one device-only type keeps the old budget.
  • Stray (PPSA02101 EU). It needs more than main to get past its calibration on this iGPU (compute programs of 0.6 to 1.9 M SPIR-V words that ANV can't compile in time, see #4977 and #5405), so both runs use main 66f89476 with #5405, #5181 and a local change that lets #5405's spanned waves run without a required subgroup size, with this commit, and the old budget forced through APS5_STAGING_POOL_MIB=1437 for the comparison. The storage image cache is at its main size in both. Enter is held once at 90 s, which leads through the main menu into loading, in a cgroup of 12 GiB RAM plus 4 GiB swap:
    • old budget: killed by the cgroup's OOM at 255 s while loading; the device tier held 1431 of 1437 MiB;
    • this commit: still running at 330 s, peak RAM plus swap 15.3 GiB, the tier holding 162 of 179 MiB.
    • The cost: in those 330 s the tier misses 5327 times against 3620 in the 255 s of the old run, since the title's working set of staging buffers is larger than 180 MiB. Presents were limited by swapping in both runs, so this does not show in the frame rate.
  • Dreaming Sarah (PPSA02929), where the old budget is never reached: same scene, four runs each, alternated, APS5_TRACE_SECONDS=20:20. Frame p50 is 16.7 or 21.0 ms in both builds (one fast run each) and the cgroup peak is about 900 MiB in both. Summary lines (traces in evidence/unified-memory-budgets):
{"commit":"9a3e2ac4daf8","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:20"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 20:20","first_present":1125,"ms":20003.169},"presents":1190,"frame_ms":{"p50":16.683,"p90":17.586,"p99":19.886,"max":55.982},"gpu_busy_ms_per_present":8.298,"worker_busy_pct":{"queue worker 0x0":34.096},"top_phases_ms_per_frame":{"VideoOut.Flip":10.108,"Driver.Present":7.714,"VideoOut.Flip.present":7.711,"Driver.Packet":5.730,"Driver.Packet.draw":5.304,"Driver.Draw":5.296,"Driver.Draw.draw_and_resource_release":5.073,"Driver.Present.render_fence_wait":4.679},"trace_dropped":false,"trace":"aps5-trace-9a3e2ac4daf8-92548.json.gz"}
{"commit":"9a3e2ac4daf8","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:20"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 20:20","first_present":970,"ms":20007.991},"presents":943,"frame_ms":{"p50":20.995,"p90":23.802,"p99":26.318,"max":29.293},"gpu_busy_ms_per_present":13.019,"worker_busy_pct":{"queue worker 0x0":26.652},"top_phases_ms_per_frame":{"VideoOut.Flip":14.634,"Driver.Present":14.610,"VideoOut.Flip.present":14.594,"Driver.Present.render_fence_wait":11.791,"Vulkan.Retire":11.791,"Vulkan.Retire.wait":11.787,"Driver.Packet":5.654,"Driver.Packet.draw":5.331},"trace_dropped":false,"trace":"aps5-trace-9a3e2ac4daf8-95836.json.gz"}
{"commit":"0f58cb53b74e","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:20"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 20:20","first_present":1014,"ms":20005.118},"presents":982,"frame_ms":{"p50":20.074,"p90":22.910,"p99":25.465,"max":29.588},"gpu_busy_ms_per_present":12.228,"worker_busy_pct":{"queue worker 0x0":27.346},"top_phases_ms_per_frame":{"VideoOut.Flip":13.858,"Driver.Present":13.827,"VideoOut.Flip.present":13.818,"Driver.Present.render_fence_wait":11.007,"Vulkan.Retire":11.006,"Vulkan.Retire.wait":11.002,"Driver.Packet":5.570,"Driver.Packet.draw":5.251},"trace_dropped":false,"trace":"aps5-trace-0f58cb53b74e-94080.json.gz"}
{"commit":"0f58cb53b74e","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:20"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 20:20","first_present":1102,"ms":20003.429},"presents":1195,"frame_ms":{"p50":16.683,"p90":17.548,"p99":19.880,"max":25.269},"gpu_busy_ms_per_present":8.170,"worker_busy_pct":{"queue worker 0x0":34.042},"top_phases_ms_per_frame":{"VideoOut.Flip":10.115,"VideoOut.Flip.present":7.341,"Driver.Present":7.341,"Driver.Packet":5.697,"Driver.Packet.draw":5.324,"Driver.Draw":5.315,"Driver.Draw.draw_and_resource_release":5.090,"Graphics.Draw":4.496},"trace_dropped":false,"trace":"aps5-trace-0f58cb53b74e-99828.json.gz"}

The PR lines are from 0f58cb53b, the first form of this branch, which also shrank the storage image cache; Dreaming Sarah reaches neither budget.

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: none
  • Unblocks: none on its own
  • GPUs tested: Intel Arc (Meteor Lake iGPU), Mesa 26.2.3 ANV, Fedora 44; lavapipe (Mesa 26.2.3, LLVM 22)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4859734347 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5893). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-14T14:49:39Z. --- ### What The staging pool's device tier (`BufferPool::DeviceBudget`, #1147) retains up to `max(512 MiB, heap / 8)` of idle buffers, sized from the largest device-local heap as if it were video memory. On an integrated GPU that heap is system RAM: 1.4 GiB of idle buffers on an Arc iGPU whose heap is 11.5 GiB, taken from the title. When every memory type of that heap is host-visible, which is how integrated GPUs report their memory and never true of a discrete GPU (it always has a device-only type), the tier now retains a sixty-fourth of the heap, at least 128 MiB: 180 MiB on that Arc. Discrete GPUs keep today's budget, and `APS5_STAGING_POOL_MIB` still overrides it. The storage image cache has the same problem (`max(2 GiB, heap / 4)`, 2.9 GiB there), but #5483 already changes that budget, so it is left to it. ### Tested Fedora 44, GCC 16.2.1, Release, Intel Arc (Meteor Lake iGPU, Mesa 26.2.3 ANV), 15 GiB RAM. - `ctest` on Arc and on lavapipe: 1158 of 1160 pass on both. `agc_host_import_sparse` fails on plain `main` here too. `guest_kernel_fcntl`, new on `main`, aborted once in each full parallel run and passes alone (5 of 5) and with the 366 `guest_` tests in parallel, on this branch and on `main`. `stagingPoolBudgetTests` checks a heap of host-visible types (16 GiB gives 256 MiB, 4 GiB the 128 MiB floor) and that one device-only type keeps the old budget. - Stray (PPSA02101 EU). It needs more than `main` to get past its calibration on this iGPU (compute programs of 0.6 to 1.9 M SPIR-V words that ANV can't compile in time, see #4977 and #5405), so both runs use `main` 66f89476 with #5405, #5181 and a local change that lets #5405's spanned waves run without a required subgroup size, with this commit, and the old budget forced through `APS5_STAGING_POOL_MIB=1437` for the comparison. The storage image cache is at its `main` size in both. Enter is held once at 90 s, which leads through the main menu into loading, in a cgroup of 12 GiB RAM plus 4 GiB swap: - old budget: killed by the cgroup's OOM at 255 s while loading; the device tier held 1431 of 1437 MiB; - this commit: still running at 330 s, peak RAM plus swap 15.3 GiB, the tier holding 162 of 179 MiB. - The cost: in those 330 s the tier misses 5327 times against 3620 in the 255 s of the old run, since the title's working set of staging buffers is larger than 180 MiB. Presents were limited by swapping in both runs, so this does not show in the frame rate. - Dreaming Sarah (PPSA02929), where the old budget is never reached: same scene, four runs each, alternated, `APS5_TRACE_SECONDS=20:20`. Frame p50 is 16.7 or 21.0 ms in both builds (one fast run each) and the cgroup peak is about 900 MiB in both. Summary lines (traces in [`evidence/unified-memory-budgets`](https://github.com/ThatsLeo/AnyPS5/tree/evidence/unified-memory-budgets)): ``` {"commit":"9a3e2ac4daf8","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:20"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 20:20","first_present":1125,"ms":20003.169},"presents":1190,"frame_ms":{"p50":16.683,"p90":17.586,"p99":19.886,"max":55.982},"gpu_busy_ms_per_present":8.298,"worker_busy_pct":{"queue worker 0x0":34.096},"top_phases_ms_per_frame":{"VideoOut.Flip":10.108,"Driver.Present":7.714,"VideoOut.Flip.present":7.711,"Driver.Packet":5.730,"Driver.Packet.draw":5.304,"Driver.Draw":5.296,"Driver.Draw.draw_and_resource_release":5.073,"Driver.Present.render_fence_wait":4.679},"trace_dropped":false,"trace":"aps5-trace-9a3e2ac4daf8-92548.json.gz"} {"commit":"9a3e2ac4daf8","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:20"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 20:20","first_present":970,"ms":20007.991},"presents":943,"frame_ms":{"p50":20.995,"p90":23.802,"p99":26.318,"max":29.293},"gpu_busy_ms_per_present":13.019,"worker_busy_pct":{"queue worker 0x0":26.652},"top_phases_ms_per_frame":{"VideoOut.Flip":14.634,"Driver.Present":14.610,"VideoOut.Flip.present":14.594,"Driver.Present.render_fence_wait":11.791,"Vulkan.Retire":11.791,"Vulkan.Retire.wait":11.787,"Driver.Packet":5.654,"Driver.Packet.draw":5.331},"trace_dropped":false,"trace":"aps5-trace-9a3e2ac4daf8-95836.json.gz"} {"commit":"0f58cb53b74e","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:20"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 20:20","first_present":1014,"ms":20005.118},"presents":982,"frame_ms":{"p50":20.074,"p90":22.910,"p99":25.465,"max":29.588},"gpu_busy_ms_per_present":12.228,"worker_busy_pct":{"queue worker 0x0":27.346},"top_phases_ms_per_frame":{"VideoOut.Flip":13.858,"Driver.Present":13.827,"VideoOut.Flip.present":13.818,"Driver.Present.render_fence_wait":11.007,"Vulkan.Retire":11.006,"Vulkan.Retire.wait":11.002,"Driver.Packet":5.570,"Driver.Packet.draw":5.251},"trace_dropped":false,"trace":"aps5-trace-0f58cb53b74e-94080.json.gz"} {"commit":"0f58cb53b74e","dirty":false,"env":{"APS5_TRACE_SECONDS":"20:20"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 20:20","first_present":1102,"ms":20003.429},"presents":1195,"frame_ms":{"p50":16.683,"p90":17.548,"p99":19.880,"max":25.269},"gpu_busy_ms_per_present":8.170,"worker_busy_pct":{"queue worker 0x0":34.042},"top_phases_ms_per_frame":{"VideoOut.Flip":10.115,"VideoOut.Flip.present":7.341,"Driver.Present":7.341,"Driver.Packet":5.697,"Driver.Packet.draw":5.324,"Driver.Draw":5.315,"Driver.Draw.draw_and_resource_release":5.090,"Graphics.Draw":4.496},"trace_dropped":false,"trace":"aps5-trace-0f58cb53b74e-99828.json.gz"} ``` The PR lines are from `0f58cb53b`, the first form of this branch, which also shrank the storage image cache; Dreaming Sarah reaches neither budget. ### Checklist - [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: none - [x] Unblocks: none on its own - [x] GPUs tested: Intel Arc (Meteor Lake iGPU), Mesa 26.2.3 ANV, Fedora 44; lavapipe (Mesa 26.2.3, LLVM 22) - [x] AI-assisted: yes
ee6aba54 commented 2026-10-15 01:01:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-15T01:01:02Z.


#6174 changes BufferPool::DeviceBudget as well (it takes the reported memory budget into account). I will rebase it onto this one once merged; nothing to change here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6181939180 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5893#issuecomment-6181939180). Originally posted by [ee6aba54](https://github.com/ee6aba54) on 2026-10-15T01:01:02Z. --- #6174 changes `BufferPool::DeviceBudget` as well (it takes the reported memory budget into account). I will rebase it onto this one once merged; nothing to change here.
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!5893
No description provided.