Skip to content

Reduce allocations when matching composite globs - #15006

Draft
davkean wants to merge 1 commit into
dotnet:mainfrom
davkean:dev/davkean/reuse-glob-match-normalization
Draft

davkean wants to merge 1 commit into
dotnet:mainfrom
davkean:dev/davkean/reuse-glob-match-normalization

Conversation

@davkean

@davkean davkean commented Sep 11, 2026

Copy link
Copy Markdown
Member

Matching a filename against composite include/exclude globs repeatedly allocates normalized copies of the same path. Reuse normalization for consecutive globs with the same root during a single match, without retaining filenames between calls. Preserve matching order, short-circuiting, and custom IMSBuildGlob implementations.

Allocation-stack comparison for the Visual Studio OrchardCore build workload, using the original PR revision 0d7bea47 against baseline d257108c:

Allocation stacks Baseline (MB) Changed build (MB) Reduction
Glob path normalization 132.7 40.6 69%
Glob matching, including children 157.1 63.2 60%

Comment thread src/Build/Globbing/CompositeGlob.cs
Comment thread src/Build/Globbing/GlobMatchContext.cs Outdated
@davkean
davkean force-pushed the dev/davkean/reuse-glob-match-normalization branch from 0d7bea4 to b2dbe57 Compare September 12, 2026 00:21
Comment thread src/Build/Globbing/GlobMatchContext.cs
Comment thread src/Build/Globbing/MSBuildGlob.cs
Comment thread src/Build/Globbing/MSBuildGlobWithGaps.cs Outdated
Comment thread src/Build/Globbing/GlobMatchContext.cs
Comment thread src/Build/Globbing/GlobMatchContext.cs Outdated
@davkean
davkean force-pushed the dev/davkean/reuse-glob-match-normalization branch from b2dbe57 to 749b1aa Compare September 12, 2026 01:16
Comment thread src/Build/Globbing/CompositeGlob.cs
Comment thread src/Build/Globbing/CompositeGlob.cs Outdated
Reuse normalized input for consecutive include and exclude globs with
identical roots within one match. Keep custom matcher dispatch and
short-circuiting unchanged, without retaining paths between calls.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8013ed0f-9ede-4eb7-a35b-835c87d73e76
@davkean
davkean force-pushed the dev/davkean/reuse-glob-match-normalization branch from 749b1aa to bf8d993 Compare September 12, 2026 01:34
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.

1 participant