Skip to content

perf(agc): keep the buffer pool's free slots by key and retain 4096 - #401

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:perf/buffer-pool-buckets
Oct 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MichonGoddijn231849:perf/buffer-pool-buckets

Conversation

@MichonGoddijn231849

Copy link
Copy Markdown
Contributor

What

BufferPool::Take scanned every retained slot of its tier for one with the same size, usage and memory properties. That kept the slot bound at 512 per tier.

  • In GTA V's Prologue the in-game builds keep more than 512 small buffers in use. The small tier overflowed with only about 27 of its 64 MiB used. Each draw then evicted and recreated buffers: about 5,900 vkAllocateMemory / vkFreeMemory pairs per second, all on the submission thread.
  • Sampling that thread's instruction pointer put most of its time in the driver's NtGdiDdDDICreateAllocation, DestroyAllocation2 and MapGpuVirtualAddress.
  • Free slots are now kept in lists per (size, usage, properties), oldest first. Take pops the newest slot of its key. Eviction takes the oldest front among the lists, so the least-recently-used order is unchanged.
  • The default bound is 4096 slots per tier, held to a sixth of maxMemoryAllocationCount so the three tiers keep half of it free on drivers with a low limit. APS5_BUFFER_POOL_SLOTS still overrides it. The byte budgets are unchanged.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none. feat(agc): host import windows, least-recent eviction under the budget #290 adds BufferPool::Trim, which walks the free slots; whichever of the two merges second needs that loop adapted to the per-key lists.
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

Take scanned every retained slot of its tier for one with the same size,
usage and memory properties, so the slot bound stayed at 512. With 512
slots GTA V's in-game builds overflowed the small tier: each draw evicted
and recreated buffers, and the submission thread spent most of its time
in the driver's allocation and free calls. The slots are now kept in
lists per key, oldest first: Take pops the newest of its key, eviction
takes the oldest front. The bound is 4096 slots per tier, held to a sixth
of maxMemoryAllocationCount.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the agc libSceAgc* label Oct 2, 2026
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 4, 2026
…nd, superseded by upstream boykopovar#401

This reverts commits 421fdc1 (keep the buffer pool's free slots by size
class, usage and memory properties, a port of boykopovar#401 without its slot bound)
and 718c0f6 (retain up to 4096 pooled buffers per tier). Upstream PR
boykopovar#401 (ccb6697) carries both and follows. bufferPoolTests from 421fdc1
stays: it checks the keyed lookup boykopovar#401 implements.
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 4, 2026
boykopovar#401 holds the pool's slot bound to a sixth of maxMemoryAllocationCount.
The mock context left it 0, so the pool kept one slot and astrobot's
bufferPoolTests (two retained buffers of one key) could not pass.
@oneandonlydean
oneandonlydean merged commit 2cf901b into boykopovar:main Oct 4, 2026
3 checks passed
SP4C3B4R-8 pushed a commit to SP4C3B4R-8/AnyPS5 that referenced this pull request Oct 6, 2026
… memory properties

BufferPool::Take scanned every retained slot of its tier for one of the
requested size class, usage and memory properties. With about 1,700 small
slots in circulation that scan was about 2% of the queue-0 worker on
PPSA21564's hub, mostly for the data and fault buffers of address-based
draw builds.

The free slots are now kept per key, oldest first: Take pops the most recently
returned slot of its key, eviction takes the oldest front across the keys, so
the least recently used slot is still the one evicted. This is the keyed free
list of upstream PR boykopovar#401 without its change to the slot bound.
SP4C3B4R-8 pushed a commit to SP4C3B4R-8/AnyPS5 that referenced this pull request Oct 6, 2026
Takes the 13 gate-batch PRs that merged upstream (boykopovar#319 boykopovar#329 boykopovar#330 boykopovar#331 boykopovar#325
boykopovar#435 boykopovar#471 boykopovar#294 boykopovar#376 boykopovar#404 boykopovar#394 boykopovar#401 boykopovar#446) in place of astrobot's local
versions, as integ/gate-batch cab0eab had them: boykopovar#294 and boykopovar#376 in
astrobot's depth model (DepthTarget, state.depth), boykopovar#394 with the thick mip
tails, boykopovar#401 over astrobot's slab pool, boykopovar#471 keeping the settled single-lane
path. Also takes the rest of main since a818bee (boykopovar#532 boykopovar#340 boykopovar#486 boykopovar#484 boykopovar#316
boykopovar#243 boykopovar#334 boykopovar#434 boykopovar#437 boykopovar#470 boykopovar#373 boykopovar#452 boykopovar#455 and our upstreamed PRs, where
astrobot keeps its later revisions and env switches).

Resolution notes: relinker converter/matcher/tests are upstream's (boykopovar#432
decoder covers VEX RIP-relative followers); RecompileResult gains boykopovar#316's
hostSubgroupSize (set from request.target.subgroupSize); shader disk cache
format 9; boykopovar#452's scissor message; upstream's later live-stack and
memory-copy decode tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mgp3oZvembQziVNE2xARQK
@MichonGoddijn231849
MichonGoddijn231849 deleted the perf/buffer-pool-buckets branch October 9, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants