Skip to content

Optimize property-path accessor invocation (first-use cost under evaluation) - #575

Draft
runceel wants to merge 1 commit into
mainfrom
runceel-property-path-performance
Draft

runceel wants to merge 1 commit into
mainfrom
runceel-property-path-performance

Conversation

@runceel

@runceel runceel commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up for #569 item 1: replace property-path DynamicInvoke with cached typed accessor adapters in Core and Legacy. Independent of #574; no R3 edits. Based on main including merged .NET 11 support (#573).

Draft: important unresolved trade-off

Warm calls improve, but compiling a fresh getter adapter significantly increases first-use cost and allocations. No application-level break-even has been established. Native AOT/trimming are unvalidated. This is a draft for evaluation, NOT a claim that all performance acceptance criteria are satisfied. #569 must remain open.

Reported measurements

Same-machine .NET 11 ARM64 Release BenchmarkDotNet in-process ShortRun, after dry run. Error is the 99.9% confidence-interval half-width; these microbenchmarks have wide uncertainty and do not predict whole-application speedups.

Scenario Before After Allocated before → after
Warm Core read 155.9 ± 38.72 ns 7.079 ± 14.49 ns 56 → 24 B
Warm Legacy read 144.1 ± 119.11 ns 5.309 ± 0.64 ns 56 → 24 B
Warm Core write 146.5 ± 83.80 ns 5.071 ± 0.74 ns 64 → 24 B
Warm Legacy write 128.8 ± 13.79 ns 6.974 ± 4.44 ns 64 → 24 B
Warm Core create/read/write/dispose 519.5 ± 59.45 ns 226.1 ± 58.05 ns 344 → 240 B
Warm Legacy create/read/write/dispose 585.4 ± 61.29 ns 208.4 ± 69.43 ns 344 → 240 B
Isolated fresh getter delegate first use 134.2 ± 39.34 ns 110.2 ± 198.4 µs 88 B → 10.14 KB

The last scenario includes candidate adapter compilation on every operation; it excludes full path creation and first-time property discovery, and is not a cold-process benchmark.

Verification reported by implementation session

  • Serialized full solution tests on .NET 10 and .NET 11 passed.
  • Full supported-target solution build passed, including netstandard2.0 and net472.
  • Regression cases cover conversions/null, boxed values, missing property, exception wrapping, source type changes, concurrency and allocation; baseline allocation tests failed before implementation.

See ADR 0009 for design and limitations. No packages published; no merge requested.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@runceel

runceel commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

Benchmark source, project settings, original result tables, and reproduction instructions: https://gist.github.com/runceel/0798793e06ba86c46bd347bfc1f0e202. This includes the substantial first-use compilation downside. A getter-only generic-reflection prototype measured fresh delegate use at 386 ± 90 ns / 392 B versus the compiled adapter at 142.7 ± 86.8 µs / 10,386 B in the same later ShortRun; its warm getter measured 3.43 ± 0.40 ns / 0 B. These are isolated microbenchmarks, not cold-process or application measurements. The prototype uses MakeGenericMethod; setter behavior, trimming and Native AOT have not been established. It is not in the PR and does not resolve its startup/compatibility trade-off. Keep this PR in draft.

This branch has not been deployed

No deployments
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