graphics: pool the shader SRT evaluator memo storage #578
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!578
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/578/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@MehmetCambaz on GitHub · 2026-09-11 23:35 UTC · original
MehmetCambaz:perf/srt-evaluator-memo-pool→main· +812 −10 · 4 files · 1 commits · closed without mergingProblem
Each SRT evaluator builds a private
std::unordered_mapmemo for one evaluation and destroys it afterwards. In resource-heavy workloads this creates a large amount of allocator traffic.In a fixed Kena: Bridge of Spirits scene, evaluator memo storage was reaching the system allocator about 87,800 times per frame.
Change
Use a per-thread
std::pmr::unsynchronized_pool_resourcefor evaluator memo storage, while keeping one privatestd::pmr::unordered_mapperEvaluator.ReadFirstLanechild evaluators still have independent maps.Evaluatoris also made non-copyable so its polymorphic allocator cannot accidentally rebind to the default resource through a copy.Performance
Windows, fixed Kena scenes, alternating legacy/pooled blocks in the same process:
GetGraphicsProgramsGetGraphicsPrograms, second sceneAll pooled blocks improved mean frame time relative to their neighbouring legacy blocks.
These numbers are from one title on Windows; equivalent gains are not claimed for other games or platforms.
Validation
Added
srt_evaluator_memo_tests, which runs the evaluator with pooled and unpooled memo storage and compares return status, outputs and reader-call order.The tests cover, among other cases:
ReadFirstLanechild isolationReadFirstLaneThe focused suite passes 1,131 checks.
Full CTest result:
The only failure in both is the existing
kernel_file_systemWindows link failure.A Kena gameplay smoke test with the production patch also completed without visual corruption or a crash.
Portability
The implementation uses standard C++ PMR facilities:
std::pmr::unordered_mapstd::pmr::unsynchronized_pool_resourcestd::pmr::new_delete_resourceIt was built and tested with clang-cl and the MSVC standard library on Windows.
The project's current Linux/libstdc++ and macOS/libc++ toolchains support these facilities, but I did not build or benchmark this change on those platforms. Performance validation is Windows-only.
Frame-pacing note
During the Kena A/B runs, pooled blocks also showed a small repeatable increase in frames landing near the ~100 ms vsync band: about +2.0 percentage points in one heavier scene and +0.4 points in a lighter scene.
This did not correlate with allocator activity or evaluator cost: warm pooled frames made no evaluator-memo system allocations, long frames did not show additional pool requests or an evaluator-time spike, while mean frame time and
GetGraphicsProgramsconsistently improved and P99 / >110 ms behaviour did not materially worsen.I could not identify a causal mechanism in the pool for this observation.
AI assistance was used during investigation, implementation and testing. I reviewed the resulting change and validation before submitting it.
@MehmetCambaz on GitHub · 2026-09-16 00:14 UTC · original
Superseded by #628, which includes this optimization and builds the dense memo work on top of it. Closing this one to keep the review in one place.
Pull request closed