Skip to content

perf(codegen): reuse prepared proxy declarations - #11641

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-incremental-proxy-emission
Oct 31, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-incremental-proxy-emission

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Proxy preparation already constructs proxy and inherited invokable declarations while coordinating ownership. Emission now reuses those declarations. Compatibility invokers use the same prepared context, with per-interface declaration ownership, replacing repeated per-owner context construction. Prepared proxy diagnostic equality also preserves current syntax-tree locations when messages and spans match.

The generator continues semantic preparation and source formatting against each changed Compilation. Fully incremental symbol-free proxy/invokable/codec/copier plans remain a separate architectural follow-up.

The branch is rebased onto main after prerequisite #11633 merged; the diff contains only prepared-proxy declaration reuse and its regressions.

Measured against the original validated parent ebbef1dc011781ba3e266352f3ea4fed4fd62c7f, a 48-owner generic-diamond workload preserves complete generated-source bytes in both compatibility modes. Actual proxy-generation calls fall from 96 to 48 normally and from 144 to 48 with compatibility enabled; compatibility invokable-generation calls fall from 264 to 96. Three-sample median whole-driver allocations fall from 36.27 MB to 33.75 MB normally and from 70.59 MB to 51.68 MB with compatibility enabled for fresh drivers over warmed compilation state. Corresponding body-edit allocations fall from 32.67 MB to 30.16 MB and from 65.79 MB to 46.91 MB. Unchanged retained drivers execute zero generators in both versions. These are workload-specific allocation results, rather than elapsed-time or solution-build speedup claims.

Regression cases cover generic diamonds, shared invokable ownership, wire aliases/parameter IDs, inheritance and substitution edits, same-identity reference replacement, custom return mappings, and current diagnostic locations. After rebasing, the complete generator module passes all 618 cases on net8 and all 619 cases on net10.

Microsoft Reviewers: Open in CodeFlow

Copilot AI balanced review requested due to automatic review settings October 30, 2026 02:38

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the prepared-declaration reuse and on-demand metadata type-name formatting changes.

No open issues 🎉

What changed in this PR

This PR reduces repeated work in Orleans code generation by reusing prepared proxy and invokable declarations, including compatibility invokers, while preserving generated output and current diagnostic locations.

Changes:

  • Reuse prepared declarations with per-interface compatibility ownership instead of rebuilding generation contexts.
  • Preserve current syntax-tree locations in diagnostic equality and include the prerequisite on-demand metadata type-name formatting.
  • Add regression coverage for inheritance, reference replacement, diagnostics, metadata parity, and allocation savings.
File Description
test/​Orleans.CodeGenerator.Tests/​ReferenceAssemblyModelExtractorTests.cs Tests metadata parity, shared type names, and reduced formatting allocations.
test/​Orleans.CodeGenerator.Tests/​IncrementalCachingTests.cs Adds proxy reuse, inheritance, reference replacement, and diagnostic-location regressions.
src/​Orleans.CodeGenerator/​SourceGeneratorResults.cs Makes prepared-output diagnostic equality sensitive to source-tree locations.
src/​Orleans.CodeGenerator/​ProxySourceOutputGenerator.cs Emits prepared declarations through a shared generation context.
src/​Orleans.CodeGenerator/​ProxyGenerationContext.cs Retains prepared proxies and per-interface compatibility declarations.
src/​Orleans.CodeGenerator/​Model/​ReferenceAssemblyModelExtractor.cs Formats metadata type names on demand and shares them across registrations.

Review effort: Balanced

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 84.02% (121,316 / 144,383) 84.08% (121,465 / 144,469) -0.0531 pp
Branches 74.01% (36,408 / 49,192) 74.00% (36,419 / 49,216) +0.0137 pp

Report-only conclusion: mixed.

The current-main baseline is commit 13660fd5e5 and uses the same reviewed coverage matrix.

Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.

The comparison remains report-only while normal line and branch variance is calibrated.

Coverage details

@ReubenBond
ReubenBond force-pushed the rb-incremental-proxy-emission branch from 8b49f26 to b839af7 Compare October 31, 2026 04:11
Copilot AI balanced review requested due to automatic review settings October 31, 2026 04:11

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the source-generation declaration reuse changes.

No open issues 🎉

Review effort: Balanced

@ReubenBond
ReubenBond merged commit 973f6da into dotnet:main Oct 31, 2026
95 checks passed
@ReubenBond
ReubenBond deleted the rb-incremental-proxy-emission branch October 31, 2026 05:19
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.

2 participants