Repository navigation
perf(codegen): reuse prepared proxy declarations - #11641
Conversation
There was a problem hiding this comment.
🟢 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
Code coverage
Report-only conclusion: mixed. The current-main baseline is commit 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 |
8b49f26 to
b839af7
Compare
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
mainafter 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