Skip to content

Fix perf regression: limit debug info to relevant subprograms (#8174) - #8177

Merged
Damyan Pepper (damyanp) merged 1 commit into
microsoft:mainfrom
damyanp:8174
Mar 28, 2026
Merged

Damyan Pepper (damyanp) merged 1 commit into
microsoft:mainfrom
damyanp:8174

Conversation

@damyanp

@damyanp Damyan Pepper (damyanp) commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

PR #7799 added debug info for global variables across all inlined subprograms, creating O(subprograms x globals) debug instructions. This caused 2-3x slower compilation for shaders with many globals and deeply-inlined functions.

Fix: Instead of collecting ALL subprograms for a function (walking every instruction), only collect subprograms from the alloca's actual users -- the instructions that reference the specific global variable. This preserves the debug info feature (globals visible in inlined scopes that use them) while eliminating work for unrelated scopes.

The 'Lower static global into Alloca' pass is 3.8x faster on a stress test (41ms -> 11ms), and overall debug compilation is ~10% faster.

Fixes #8174

…oft#8174)

PR microsoft#7799 added debug info for global variables across all inlined
subprograms, creating O(subprograms x globals) debug instructions.
This caused 2-3x slower compilation for shaders with many globals
and deeply-inlined functions.

Fix: Instead of collecting ALL subprograms for a function (walking
every instruction), only collect subprograms from the alloca's actual
users -- the instructions that reference the specific global variable.
This preserves the debug info feature (globals visible in inlined
scopes that use them) while eliminating work for unrelated scopes.

The 'Lower static global into Alloca' pass is 3.8x faster on the
stress test (41ms -> 11ms), and overall debug compilation is ~10%
faster.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@damyanp
Damyan Pepper (damyanp) marked this pull request as ready for review February 20, 2026 01:06

@alsepkow Alex Sepkowski (alsepkow) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

Should we consider a perf test of some sort to help prevent a regression like this in the future?

@damyanp
Damyan Pepper (damyanp) merged commit bb168c9 into microsoft:main Mar 28, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Perf Regression from #7799

3 participants