Skip to content

Reuse a guest pool's span without taking the pool lock - #310

Closed
SkippySteve wants to merge 1 commit into
NotRexed:mainfrom
SkippySteve:fix/pool-span-cache
Closed

SkippySteve wants to merge 1 commit into
NotRexed:mainfrom
SkippySteve:fix/pool-span-cache

Conversation

@SkippySteve

Copy link
Copy Markdown
Contributor

Summary

  • gpu_pool_end and gpu_pool_start took the pool lock on every call. Storage-buffer tables ask this once per entry, and the entries of one table sit in one pool. The same locked lookup, before buffer binds cached it, was about 8% of replay time.
  • A thread keeps the last guest-pool span and reuses it while guest_pools_gen is unchanged. memory_sync bumps that generation when it replaces the table, so a refreshed pool list is not served from the old span. RX_VK_POOL_END_IMPORTED still skips the game-pool span and takes the lock.

Test plan

  • python -I -B tests/test_pool_span.py passes: a span covers its interior only for the generation it was cached from, both queries check the cache before ParLock, and memory_sync bumps the generation at the swap
  • Dropping the generation bump fails the test, and moving the cache check to after the lock fails it
  • CI: "Check a pool span is reused without the lock"

Storage-buffer entries ask where their pool ends, and the entries of one table sit in one pool. That locked lookup was about 8% of replay time before buffer binds grew a cache.
@NotRexed

NotRexed commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Thanks! This one changes timing/locking on the replay's hot path, so I'll measure it (fps and frame times in Kokiri, plus a few boots) before merging. The two clock-gating PRs (#306, #308) are merged.

@NotRexed

NotRexed commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Thanks! Measured together with the other replay PRs (replay 27 -> 24-25 ms a frame, fps 23 -> 26 in Kokiri) and applied by hand (conflicts only in the CI workflow; #310 and #315 needed one declaration moved), pushed in 40c3f85.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants