Repository navigation
[MicroPerf] Cache IL method parameter attributes during overload resolution - #20353
Merged
Merged
Conversation
Contributor
|
T-Gro
marked this pull request as draft
August 26, 2026 08:00
T-Gro
force-pushed
the
t-gro-overload-meta-reimport-spike
branch
5 times, most recently
from
August 26, 2026 09:18
10c2c74 to
ad39ff9
Compare
MethInfo.GetParamAttribs rebuilt the full per-parameter attribute list (custom-attr decoding, well-known-attr probes, OptionalArgInfo) from IL metadata on every call and was never cached. On an overload-heavy compile it was called 2.17M times against only 137 distinct underlying methods. Memoize the decode with the existing MemoizationTable, held per compilation via WeakMap.getOrCreate keyed on the ImportMap. The key is the method's physical ILMethodDef plus extension-member use (the C#-style extension view drops the object argument from ParamMetadata, so the two views must not share an entry); canMemoize restricts caching to monomorphic declaring types (an optional arg's default can otherwise depend on the instantiation), matching InfoReader's monomorphic-only caches. Add a regression test covering an IL extension method used with both instance and static call syntax, which shares one ILMethodDef across both views. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
T-Gro
force-pushed
the
t-gro-overload-meta-reimport-spike
branch
from
August 26, 2026 09:23
ad39ff9 to
963aa38
Compare
T-Gro
marked this pull request as ready for review
August 26, 2026 09:54
T-Gro
enabled auto-merge (squash)
August 27, 2026 08:19
abonie
reviewed
Aug 28, 2026
abonie
reviewed
Aug 28, 2026
abonie
approved these changes
Aug 28, 2026
Member
|
I'm wondering if it also improves the time 🙂 |
… check executes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
@auduchinok The headline measured win here is allocation (ComputeILMethodParamAttribs 477 MB -> 0 on the overload-heavy workload), which is what I profiled deterministically. That much less GC pressure does help wall-clock in the same direction, but time on this workload is noisy enough that I didn't want to quote a hard delta as the primary number - the 99.75% hit ratio over 2.17M calls is the reliable signal. |
abonie
approved these changes
Sep 4, 2026
This was referenced Sep 4, 2026
bartelink
pushed a commit
to bartelink/fsharp
that referenced
this pull request
Oct 7, 2026
…et#20353) MethInfo.GetParamAttribs rebuilt the full per-parameter attribute list (custom-attr decoding, well-known-attr probes, OptionalArgInfo) from IL metadata on every call and was never cached. On an overload-heavy compile it was called 2.17M times against only 137 distinct underlying methods. Memoize the decode with the existing MemoizationTable, held per compilation via WeakMap.getOrCreate keyed on the ImportMap. The key is the method's physical ILMethodDef plus extension-member use (the C#-style extension view drops the object argument from ParamMetadata, so the two views must not share an entry); canMemoize restricts caching to monomorphic declaring types (an optional arg's default can otherwise depend on the instantiation), matching InfoReader's monomorphic-only caches. Add a regression test covering an IL extension method used with both instance and static call syntax, which shares one ILMethodDef across both views. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
MethInfo.GetParamAttribsdecoded a method's per-parameter attributes from IL metadata on every call and was never cached — on an overload-heavy compile that's 2.17M calls for 137 distinct methods.Memoized via the existing
MemoizationTable, held per compilation throughWeakMap.getOrCreate, keyed by the physicalILMethodDef(plus an extension-member flag, since the C#-style extension view drops the object argument). Cache stats fromfsc --times:Allocation on the workload:
ComputeILMethodParamAttribs477 MB → 0 (~810 MB total). Output byte-identical vs HEAD.