Reduce MEF cache construction allocations - #792
Merged
Andrew Arnott (AArnott) merged 1 commit intoSep 10, 2026
Merged
Andrew Arnott (AArnott) merged 1 commit into
Andrew Arnott (AArnott) merged 1 commit into
Conversation
Sharing boundary reachability repeatedly traversed every part's satisfying exports for each target and candidate scope. Materialize viable export-factory edges once per analysis pass so large catalogs avoid the repeated enumeration and allocation cost. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change is a contained refactor that preserves the existing reachability/scope logic while reducing repeated scanning and allocations, and no correctness issues were found in the updated control flow.
Pull request overview
This PR optimizes the uncreatable sharing-boundary analysis during MEF cache construction by caching “viable export-factory edges” once per analysis pass, avoiding repeated full-catalog scans that can amplify allocations on large catalogs.
Changes:
- Precomputes a cached list of export-factory relationships (owner, fresh sharing boundaries, exported parts) for reuse during reachability analysis.
- Replaces repeated LINQ-based catalog scanning inside
IsPartReachablewith iterative loops over the cached export-factory list. - Removes some LINQ-heavy dominance checks in scope exploration in favor of explicit loops to reduce per-iteration overhead.
File summaries
| File | Description |
|---|---|
| src/Microsoft.VisualStudio.Composition/CompositionConfiguration.cs | Caches export-factory edges and reuses them in sharing-boundary reachability analysis to reduce allocations and repeated scanning. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Andrew Arnott (AArnott)
marked this pull request as ready for review
September 10, 2026 14:38
Andrew Arnott (AArnott)
enabled auto-merge
September 10, 2026 14:38
Andrew Arnott (AArnott)
disabled auto-merge
September 10, 2026 14:38
Andrew Arnott (AArnott)
enabled auto-merge
September 10, 2026 14:38
Oleg Tkachenko (olegtk)
approved these changes
Sep 10, 2026
Andrew Arnott (AArnott)
deleted the
dev/andrew.arnott/optimize-uncreatable-sharing-boundaries
branch
September 10, 2026 22:30
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.
Uncreatable sharing-boundary analysis repeatedly scans the entire catalog for every target part and candidate scope. Large catalogs amplify those scans into excessive allocation and can cause cache construction to exceed its cancellation window. Cache viable export-factory edges once per analysis pass while preserving the existing reachability and scope rules.