Skip to content

[release/11.0] Reduce configuration binder overhead for properties that cannot inherit attributes - #136899

Merged
svick merged 3 commits into
dotnet:release/11.0from
rosebyte:rosebyte-binder-regression-analysis
Nov 17, 2026
Merged

svick merged 3 commits into
dotnet:release/11.0from
rosebyte:rosebyte-binder-regression-analysis

Conversation

@rosebyte

@rosebyte rosebyte commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #136759

This is a targeted mitigation for release/11.0. Main already avoids this lookup following dotnet/runtime#135672, which also changes overridden-property handling. This PR preserves 11.0's binding behavior rather than backporting that broader change.

When an attribute is not declared directly, reflection retrieves attribute-usage metadata and prepares a parent-property lookup before discovering that the property cannot inherit. The binder therefore pays this cost for ordinary nonvirtual properties and virtual properties that introduce a new slot.

This change checks the getter and setter's virtual-slot flags first. If neither accessor can inherit, it uses direct attribute lookup. Potential overrides retain the existing inherited lookup. The shared helper covers both property binding and constructor/property matching. No caching is added.

An equivalent early rejection in reflection remains a possible future improvement, but requires a runtime update. The binder-local mitigation also benefits applications updating the package on an existing runtime.

Regression

The additional lookup was introduced with ConfigurationIgnoreAttribute in dotnet/runtime#126396. This change retains that feature while removing unnecessary inheritance work.

Measured on .NET 10.0.14, macOS arm64, with dependencies held constant. Mean time per operation:

Operation Binder 10.0 Affected 11.0 source Patched
Get<T>, 1 plain property 0.237 us 0.591 us 0.261 us
Get<T>, 10 plain properties 1.672 us 5.375 us 1.913 us
Get<T>, 50 plain properties 9.403 us 27.642 us 10.299 us
Repeated Bind, 50 plain properties 9.074 us 28.874 us 10.321 us
Fresh-scope snapshot, 50 plain properties 9.423 us 28.611 us 10.752 us

For 50-property plain Get<T>, allocation decreases from 27,611 bytes to 17,553 bytes, compared with 17,552 bytes for Binder 10.0. The displayed cases remain approximately 10–15% slower than Binder 10.0.

Risk

Expected compatibility risk is low: inherited lookup is bypassed only when neither accessor can inherit. Property discovery, constructor selection, and options lifetimes are unchanged.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-configuration
See info in area-owners.md if you want to be subscribed.

@rosebyte
rosebyte changed the base branch from main to release/11.0 November 4, 2026 07:55
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Nov 4, 2026
@rosebyte
rosebyte force-pushed the rosebyte-binder-regression-analysis branch 2 times, most recently from 9b9e29b to 77d650b Compare November 4, 2026 08:01
@ViveliDuCh

Copy link
Copy Markdown
Member

Hi,

the code complete date for 11.0.1 (the December 2026 release) is Monday 16 November. Make sure to merge this PR on that date at the latest, or it won't make it into that release.

As a reminder, if this is a product change, you also need Tactics approval before merging this PR (test-only or infra-only changes don't require Tactics approval).

Happy to help with the merge if needed!

@rosebyte
rosebyte marked this pull request as ready for review November 16, 2026 08:01
@rosebyte rosebyte changed the title Reduce configuration binder overhead for properties that cannot inherit attributes [release/11.0] Reduce configuration binder overhead for properties that cannot inherit attributes Nov 16, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@svick

svick commented Nov 16, 2026

Copy link
Copy Markdown
Member

An equivalent early rejection in reflection remains a possible future improvement, but requires a runtime update.

Do we have an issue open for this?

@rosebyte

rosebyte commented Nov 16, 2026 •

Copy link
Copy Markdown
Member Author

Do we have an issue open for this?

Not yet, it's a separate idea that needs to be discussed first.

@svick svick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, just one small potential test improvement.

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 are recorded, although builds, tests, and benchmarks were not run during this review.

No open issues 🎉

What changed in this PR

This PR mitigates configuration binder overhead in release/11.0 by skipping inherited attribute lookup for properties whose accessors cannot override a base member, while preserving inherited lookup for potential overrides.

Changes:

  • Check getter and setter virtual-slot flags before selecting the attribute lookup path.
  • Add regression coverage for inherited ignore attributes on getter-only collection overrides.
  • Add CoreCLR allocation checks for nonvirtual and new-slot virtual properties.

Builds, tests, and benchmarks were not run during this review.

File Description
src/​libraries/​Microsoft.Extensions.Configuration.Binder/​tests/​Common/​ConfigurationBinderTests.TestClasses.cs Adds ignored collection and getter-override test fixtures.
src/​libraries/​Microsoft.Extensions.Configuration.Binder/​tests/​Common/​ConfigurationBinderTests.cs Adds inheritance compatibility and allocation regression tests.
src/​libraries/​Microsoft.Extensions.Configuration.Binder/​src/​ConfigurationBinder.cs Avoids inherited attribute lookup when neither accessor can inherit.

Review effort: Balanced

@rosebyte rosebyte added the Servicing-approved Approved for servicing release label Nov 16, 2026
@rosebyte

Copy link
Copy Markdown
Member Author

Approved for December servicing, we can merge.

@svick

svick commented Nov 16, 2026

Copy link
Copy Markdown
Member

/ba-g Test failure seems unrelated.

@svick
svick enabled auto-merge (squash) November 16, 2026 19:03
@ViveliDuCh

Copy link
Copy Markdown
Member

/ba-g only known issues

@ViveliDuCh ViveliDuCh added Servicing-approved Approved for servicing release and removed Servicing-approved Approved for servicing release labels Nov 17, 2026
@svick
svick merged commit 18d98a5 into dotnet:release/11.0 Nov 17, 2026
89 of 92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Extensions-Configuration linkable-framework Issues associated with delivering a linker friendly framework Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ConfigurationBinder: 4x slower Get<T>/Bind in .NET 11 RC3 from IsDefined(inherit: true) per property per bind

4 participants