Repository navigation
perf(shader): replace linear scans with hash lookups in recompiler - #1610
Closed
silentone12725 wants to merge 1 commit into
Closed
silentone12725 wants to merge 1 commit into
silentone12725 wants to merge 1 commit into
Conversation
Capability and extension checks in the SPIR-V backend, SRT walker visited/visiting tracking, structurizer block ordering and embedded vertex fetch PC matching all used std::find over vectors on hot paths. Use unordered sets/maps instead; behavior is unchanged.
silentone12725
force-pushed
the
perf/shader-linear-scan-eliminations
branch
from
October 8, 2026 14:35
4191017 to
1feb879
Compare
silentone12725
marked this pull request as ready for review
October 8, 2026 14:47
9 tasks done
This was referenced Oct 8, 2026
Collaborator
|
Closing: perf changes need before/after numbers for the change itself (#218), and the capability and extension lists here hold a handful of entries, where a hash set isn't faster than a scan. If one of these scans shows up in a profile, please reopen with that measurement for it alone. |
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.
Summary
capabilitySet/extensionSettoSpirvEmitterStateand use them instead ofstd::findover the supported-capability/extension spans (module setup, descriptors, image emitter).SrtPlanBuilder/SrtEvaluator: track visited/visiting values in hash sets (the plan builder keeps the vector only for cycle-position lookup on an actual cycle).Structurizer: precompute block order in anunordered_mapinstead ofstd::findinsidestd::sortcomparators (was O(N^2 log N)).EmbeddedVertexFetch: use a set for the add-PC membership test in thesharedlambda.No behavior change intended.
Test plan
python3 tools/check_conventions.py --base origin/mainshader_recompiler_agc_driverand the shader testsagc_shader_control_flow_tests,agc_shader_memory_tests,agc_shader_fusion_tests,agc_shader_disk_cache_testsall passspirv-val --target-env vulkan1.31feb8793: passed for Linux and Windows (run 37833581660). It is not in the PR checks because the upstream run for this head is waiting for maintainer approval (CI: 38 open PR heads are queued at action_required, so their PRs show no checks #1631).Measured
Pattern benchmarks of the old and new loop shapes in isolation (
g++ -O2, best of 5), not a whole-shader measurement:SrtPlanBuildervisited tracking: 60.6 ms with a vector against 1.1 ms with a set at 20 000 values; 0.7 ms against 0.1 ms at 2 000.Structurizerblock order inside the sort: 3.0 ms against 0.16 ms at 5 000 blocks; no gain at 200 blocks.SpirvEmitterState.EmbeddedVertexFetchshared: slower with a set at 8addPcs(0.17 ms against 0.08 ms for 50 000 instructions), faster at 64 (0.18 ms against 0.47 ms).Changes since the first revision