GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf(codegen): generate provider metadata at build time by ReubenBond · Pull Request #10493 · dotnet/orleans

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Problem

Configuration-driven providers are declared with RegisterProviderAttribute. Resolving them entirely from those attributes at runtime requires assembly enumeration and reflection, and the original implementation in #9731 predates the incremental source-generator architecture.

Solution

  • Collect provider registrations declared by each assembly in the incremental source-generator model while preserving structural equality and deterministic ordering for caching.
  • Emit a lightweight IProviderMetadataProvider implementation only when complete provider metadata can be represented safely in generated C#.
  • Resolve client and silo providers through a shared runtime resolver without executing the full generated serialization manifest.
  • Avoid activating custom type-manifest providers outside dependency injection and preserve generated provider constructors for trimming/AOT.
  • Preserve compatibility with assemblies built by older generators, and assemblies containing alias-only or file-local provider types, using a narrowly scoped RegisterProviderAttribute fallback.
  • Keep metadata per assembly so registrations are not duplicated across generated manifests and runtime precedence remains compatible with the existing assembly scan.
  • Cover generated metadata, client/silo target filtering, complete fallback behavior, custom-provider activation, and incremental invalidation behavior.

This PR moves provider attribute interpretation to build time and avoids full manifest configuration during provider discovery. It still enumerates relevant assemblies and reflects over TypeManifestProviderAttribute to locate generated metadata. #10504 tracks a generated module-initializer registry which will remove that remaining reflection from the normal path while retaining lazy compatibility fallback.

This supersedes #9731 and fixes #9730.

Microsoft Reviewers: Open in CodeFlow

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ReubenBond ReubenBond mentioned this pull request Aug 11, 2026
Generate RegisterProvider metadata at build time via source generator #9731
Closed
15 tasks done
@ReubenBond
ReubenBond force-pushed the rb-fix-pr-9731 branch 2 times, most recently from da5e334 to 0a50c96 Compare August 11, 2026 19:20
@ReubenBond

ReubenBond commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

I audited the incremental-generator impact and pushed 0a50c9698 to reduce avoidable provider scanning. Provider and application-part assembly attributes are now classified in one pass, without the filtered List/array allocations, and provider-specific incremental caching/invalidation tests were added.

A three-way BenchmarkDotNet comparison used main, the pre-optimization PR generator, and the final generator with 64 synthetic references (8 containing provider registrations). With 15 measurement iterations, both initial generation and an unrelated source edit were statistically Same as main at the 5% threshold. Final allocations were slightly below main (51.61 KB vs 52.35 KB initial; 30.03 KB vs 30.60 KB incremental). The VM timings were noisy, so the equivalence test and allocation results are more reliable than the raw means.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ReubenBond ReubenBond mentioned this pull request Aug 11, 2026
Avoid runtime provider scanning with generated module initializers #10504
Closed
Copilot AI lite review requested due to automatic review settings August 11, 2026 21:27
Copilot started reviewing on behalf of ReubenBond August 11, 2026 21:27
View session
Copilot AI reviewed Aug 11, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Pull request overview

This PR shifts RegisterProviderAttribute interpretation into the Orleans incremental source-generator pipeline, emitting lightweight build-time provider metadata and updating client/silo configuration to resolve providers via a shared runtime resolver.

Changes:

  • Introduces IProviderMetadataProvider and generates implementations only when provider metadata exists.
  • Adds ProviderRegistrationResolver and routes both client and silo provider resolution through it (with legacy attribute fallback for older assemblies).
  • Extends codegen models/tests to extract, normalize, and cache provider registration metadata deterministically.
Show a summary per file
File Description
test/Orleans.Core.Tests/ProviderRegistrationResolverTests.cs Adds coverage for generated metadata consumption, legacy fallback, and non-activation of custom manifest providers.
test/Orleans.CodeGenerator.Tests/ModelExtractorTests.cs Verifies provider registrations are extracted (and deterministically ordered) during reference extraction.
test/Orleans.CodeGenerator.Tests/IncrementalModelEqualityTests.cs Extends reference assembly model builder to include provider registrations.
test/Orleans.CodeGenerator.Tests/IncrementalCachingTests.cs Adds incremental caching tests to ensure provider changes invalidate the pipeline and unrelated changes do not.
src/Orleans.Serialization/Configuration/ITypeManifestProvider.cs Introduces the new public IProviderMetadataProvider contract in the serialization configuration namespace.
src/Orleans.Runtime/Hosting/DefaultSiloServices.cs Switches silo provider registration resolution to ProviderRegistrationResolver.
src/Orleans.Core/Core/ProviderRegistrationResolver.cs Adds shared runtime resolver for provider registrations (generated metadata + legacy fallback).
src/Orleans.Core/Core/DefaultClientServices.cs Switches client provider registration resolution to ProviderRegistrationResolver.
src/Orleans.CodeGenerator/ReferenceAssemblyDataProvider.cs Ensures empty reference model includes an empty provider-registration collection.
src/Orleans.CodeGenerator/Model/ReferenceAssemblyModelExtractor.cs Extracts RegisterProviderAttribute metadata and adds it to the reference model with deterministic ordering.
src/Orleans.CodeGenerator/Model/ReferenceAssemblyModel.cs Adds RegisteredProviderModel and stores it on ReferenceAssemblyModel.
src/Orleans.CodeGenerator/Model/MetadataAggregateModelBuilder.cs Normalizes/uniquifies provider registrations for stable incremental caching.
src/Orleans.CodeGenerator/MetadataGenerator.cs Emits IProviderMetadataProvider.ConfigureProviders(...) only when provider registrations exist.
src/Orleans.CodeGenerator/LibraryTypes.cs Adds RegisterProviderAttribute to known library types for extraction.
src/api/Orleans.Serialization/Orleans.Serialization.cs Updates public API surface to include IProviderMetadataProvider.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 15/15 changed files
  • Comments generated: 1
  • Review effort level: Lite

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Orleans.Core/Core/ProviderRegistrationResolver.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI review requested due to automatic review settings August 11, 2026 22:26
@ReubenBond
ReubenBond force-pushed the rb-fix-pr-9731 branch from ae7a554 to 9adc458 Compare August 11, 2026 22:26
Copilot started reviewing on behalf of ReubenBond August 11, 2026 22:27
View session
Copilot AI reviewed Aug 11, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Review details

Suppressed comments (2)

src/Orleans.Serialization/Configuration/TypeManifestProviderAttribute.cs:37

  • Same trimming annotation issue as the constructor parameter: ProviderType is consumed for DI registration and should preserve all public constructors.
        [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
        public Type ProviderType { get; }

src/Orleans.Serialization/Configuration/TypeManifestProviderAttribute.cs:18

  • TypeManifestProviderAttribute.ProviderType is used as an implementation type for DI (SerializerBuilderExtensions.AddAssembly registers it with AddSingleton), so trimming needs to preserve all public constructors, not just a public parameterless ctor. Using PublicParameterlessConstructor here can lead to incorrect trimming annotations and ILLink warnings for custom providers with injected constructors.

This issue also appears on line 36 of the same file.

        public TypeManifestProviderAttribute(
            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
            Type providerType)
  • Files reviewed: 16/16 changed files
  • Comments generated: 1
  • Review effort level: Lite

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/Orleans.Core/Core/ProviderRegistrationResolver.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

ReubenBond and others added 7 commits August 11, 2026 15:34
@ReubenBond
perf(codegen): generate provider metadata at build time
c5e786e
Port provider registration discovery to the current incremental reference-assembly model and consume generated manifest metadata during client and silo configuration.

Co-authored-by: Copilot <[email protected]>
@ReubenBond
fix(codegen): preserve provider metadata behavior
f9a79ac
Retain constructed generic provider types in generated registrations and avoid executing non-OrleansCodeGen manifest providers while collecting provider metadata.

Co-authored-by: Copilot <[email protected]>
@ReubenBond
fix(codegen): preserve provider compatibility
468d244
Preserve closed generic provider types, avoid activating custom manifest providers outside DI, and retain a legacy fallback for packages built with older generators.

Co-authored-by: Copilot App <[email protected]>
@ReubenBond
perf(codegen): reduce provider metadata scanning
5e767f9
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: dd22afa0-8eac-4b78-bc16-d2f60bc3cb22
@ReubenBond
perf(codegen): separate provider metadata discovery
c5d9c92
Avoid executing full serialization manifests when resolving configuration-driven providers. Generate a lightweight provider metadata contract, preserve legacy attribute fallback, and cover client, silo, and custom-provider behavior.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 90ba28fa-3faa-4c32-a712-d8cb4b5fd3f0
@ReubenBond
fix(codegen): preserve provider metadata fallback
01a3cd1
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 90ba28fa-3faa-4c32-a712-d8cb4b5fd3f0
@ReubenBond
fix(core): avoid activating legacy manifests
1093681
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 90ba28fa-3faa-4c32-a712-d8cb4b5fd3f0
Copilot AI review requested due to automatic review settings August 11, 2026 22:35
@ReubenBond
ReubenBond force-pushed the rb-fix-pr-9731 branch from 9adc458 to 1093681 Compare August 11, 2026 22:35
Copilot started reviewing on behalf of ReubenBond August 11, 2026 22:36
View session
Copilot AI reviewed Aug 11, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 16/16 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ReubenBond
fix(serialization): guard trimming annotations
40d0806
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 90ba28fa-3faa-4c32-a712-d8cb4b5fd3f0
Copilot AI review requested due to automatic review settings August 12, 2026 00:08
Copilot started reviewing on behalf of ReubenBond August 12, 2026 00:09
View session
Copilot AI reviewed Aug 12, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 16/16 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Aug 12, 2026
Flaky test: SMS stream restart retains duplicate publisher #10503
Closed
Flaky test: ADO.NET multi-stream tests time out after 30 seconds #10458
Closed
@ReubenBond
ReubenBond merged commit 1dc0d29 into dotnet:main Aug 12, 2026
134 of 138 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Aug 31, 2026
chore: Bump Microsoft.Orleans.Serialization.Abstractions from 10.2.2 to 10.3.1 managedcode/Communication#154
Merged
chore: Bump Microsoft.Orleans.Persistence.Memory and 3 others managedcode/Communication#155
Closed
chore: Bump Microsoft.Orleans.TestingHost from 10.2.2 to 10.3.1 managedcode/Communication#156
Merged
Bump the orleans group with 1 update vgmello/momentum#341
Closed
Bump Microsoft.Orleans.BroadcastChannel and 5 others intochat/intochat#77
Closed
Bump the orleans group with 10 updates bartul/agave#86
Closed
Bump the orleans group with 3 updates microsoft/aspire-samples#1930
Closed
Bump the nuget-minor-patch group with 21 updates Systemorph/MeshWeaver#3519
Closed
chore(deps): Bump the nuget-patch-and-minor group with 13 updates petesramek/microservices-vs-virtual-actors#8
Closed
This was referenced Sep 7, 2026
Bump the orleans group with 3 updates microsoft/aspire-samples#1931
Merged
Bump the orleans group with 10 updates bartul/agave#87
Merged
Bump the dotnet group with 5 updates dotnet/docs#55908
Merged
Bump the dotnet group with 4 updates dotnet/docs#55909
Merged
Bump the dotnet group with 4 updates dotnet/docs#55910
Merged
Bump the dotnet group with 5 updates dotnet/docs#55911
Merged
Bump the dotnet group with 4 updates IvanMarkitan/dotnet-docs#838
Closed
Bump the dotnet group with 6 updates IvanMarkitan/dotnet-docs#839
Closed
Bump the dotnet group with 7 updates IvanMarkitan/dotnet-docs#840
Closed
Bump Microsoft.Orleans.Sdk and Microsoft.Orleans.Server IvanMarkitan/dotnet-docs#843
Open
Bump Microsoft.Orleans.Clustering.Redis and 4 others IvanMarkitan/dotnet-docs#845
Closed
Bump the dotnet group with 7 updates IvanMarkitan/dotnet-docs#846
Open
Bump the dotnet group with 5 updates BillWagner/docs#9804
Closed
Bump the dotnet group with 4 updates BillWagner/docs#9805
Closed
Bump the dotnet group with 4 updates BillWagner/docs#9806
Closed
Bump the dotnet group with 5 updates BillWagner/docs#9807
Closed
Bump the dotnet group with 7 updates zbalkan/docs#2339
Closed
Bump the dotnet group with 5 updates zbalkan/docs#2340
Closed
Bump the dotnet group with 6 updates zbalkan/docs#2341
Closed
Bump the dotnet group with 10 updates zbalkan/docs#2347
Open
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Source Generator should scan for RegisterProvider attributes at build time

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ReubenBond
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.