Skip to content

Reduce MEF cache construction allocations - #792

Merged
Andrew Arnott (AArnott) merged 1 commit into
mainfrom
dev/andrew.arnott/optimize-uncreatable-sharing-boundaries
Sep 10, 2026
Merged

Andrew Arnott (AArnott) merged 1 commit into
mainfrom
dev/andrew.arnott/optimize-uncreatable-sharing-boundaries

Conversation

@AArnott

Copy link
Copy Markdown
Member

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.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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 IsPartReachable with 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.

@AArnott
Andrew Arnott (AArnott) merged commit be17f20 into main Sep 10, 2026
10 checks passed
@AArnott
Andrew Arnott (AArnott) deleted the dev/andrew.arnott/optimize-uncreatable-sharing-boundaries branch September 10, 2026 22:30
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.

3 participants