Repository navigation
perf(agc): cut per-draw heap allocations - #6312
Merged
adriadam10 merged 2 commits intoOct 19, 2026
Merged
Conversation
Merged
11 tasks done
|
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.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
This was referenced Oct 15, 2026
Merged
This was referenced Oct 15, 2026
11 tasks done
9 tasks done
This was referenced Oct 15, 2026
9 tasks done
11 tasks done
11 tasks done
meh7an
force-pushed
the
perf/agc-cut-draw-allocations
branch
2 times, most recently
from
October 16, 2026 20:12
144cca6 to
ecda2b1
Compare
This was referenced Oct 16, 2026
12 tasks done
adriadam10
force-pushed
the
perf/agc-cut-draw-allocations
branch
from
October 19, 2026 01:01
ecda2b1 to
941b158
Compare
|
This pull request is labeled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A draw allocated several short-lived lists and copies on the heap. On the S2 page of Sonic Origins Plus's main menu,
operator newcost the queue worker 5.56 samples per frame (APS5 sampler, 15 s). Among its callers:Driver::draw: a copy of the decode's programs, and lists grown one push at a time;MovedReadOnlyBuffers: the moved words, copied per entry;CachedFragmentOutputsandKnownValidationFailure: a fresh validation key each, and the output set copied out of the memo;DecodeVertexStageInfo: a vector per guest read;ShaderMemory: a map node per initial region;This change removes or reuses those allocations:
Driver::drawreads the decode's programs in place. Only a draw that patches user words works on a copy: a mesh draw, an indirect draw, or a cached draw found across moved user-data pointers (perf(agc): find cached draws across moved user-data pointers #4943). The region, link and snapshot lists are reserved once.std::set, in the memo, the recipe and the draw's inputs.ThreadOwned), shared byKnownValidationFailureandCachedFragmentOutputs.MovedBuffer::wordsis a span into the compiled stage's guest descriptor instead of a copy. That descriptor outlivesPrepareDrawBindings, the only reader. The moved-word cache copies the words it keeps.DecodeReadkeeps its 4 or 16 bytes inline.ShaderMemorykeeps its initial regions in a sorted vector instead of a map.MovedReadOnlyBuffersandPrepareDrawBindingsreserve their lists with the first entry.HostThreadLocal) and refills them.drawDescriptorWriteTestsanddescriptorSnapshotTests.With this change, per frame:
operator new5.56 to 4.77,malloc6.40 to 5.51;KnownValidationFailure0.23 to 0.06,CachedFragmentOutputs0.38 to 0.27;MovedReadOnlyBuffers1.05 to 0.72, and the program decode 1.09 to 0.88.Tested
Windows 11 (10.0.26300), WinLibs GCC 15.2.0 (UCRT), Release, NVIDIA GeForce RTX 2080 Ti, driver 617.14.
agc_driver_gpu_indirect_arguments_misaligned_writer_ahead, which main itself does not compile with MinGW.select_testsfails in its setup on Windows without the symlink privilege (WinError 1314fromsymlink_to), as on main.agc_driver_recorder_tests's unregistered default path,resourceReadTestsandmisalignedRegionTests, failed on main itself, with or without this change.APS5_TRACE_SECONDS=200:15on the same machine in one session, caches warm. Traces attached.The p90 gap mostly comes from slower frames in the baseline's window. The median and
Driver.Draware the steadier numbers.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Traces and summary lines (baseline 824084e, this change 96f4f98):
alloc-traces.zip