Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve performance on virtual method processing#100897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jtschuster merged 8 commits intodotnet:mainfromjtschuster:TrimmerRegression
Apr 12, 2024

Conversation

@jtschuster
Copy link
Member

@jtschusterjtschuster commentedApr 11, 2024
edited
Loading

Fixesdotnet/sdk#40060.

The _virtual_methods cache had duplicates due to theScope item in the tuple, which made ProcessVirtualMethods do significantly more work. This PR makes the cache a dictionary, with TryAdd's instead of Add to only add each method once.It also exits early when possible in the IsInterfaceImplementationMarkedRecursively method. These changes made caused theoverrides cache in TypeMapInfo to be modified during iteration, so afor loop is used instead of a foreach loop. This should be find since the list will always be append-only. I noticed we copy _typesWithInterfaces to an array for the same reason, though since that's also append-only we can iterate with afor loop there, too.

On my machine, this reduces the trim time of the aspnetcore benchmarks from ~80 seconds to ~35 seconds.

sbomer reacted with heart emojiPaulusParssinen reacted with rocket emoji
- Make _virtual_methods a dictionary to prevent duplicates due to the  Scope object in the tuple- Exit early when possible in IsInterfaceImplementationMarkedRecursively- Return a list from TypeMapInfo.GetRecursiveInterfaces and iterate over  with a regular for loop- Iterate over _typesWithInterfaces with a for loop instead of copying  to an array
@ghostghost added the area-Tools-ILLink.NET linker development as well as trimming analyzers labelApr 11, 2024
@dotnet-policy-servicedotnet-policy-servicebot added the linkable-frameworkIssues associated with delivering a linker friendly framework labelApr 11, 2024
@jtschusterjtschuster requested a review fromagockeApril 11, 2024 21:59
@jtschusterjtschuster removed the linkable-frameworkIssues associated with delivering a linker friendly framework labelApr 11, 2024
@dotnet-policy-servicedotnet-policy-servicebot added the linkable-frameworkIssues associated with delivering a linker friendly framework labelApr 11, 2024
Copy link
Member

@sbomersbomer left a comment

Choose a reason for hiding this comment

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

It also exits early when possible in the IsInterfaceImplementationMarkedRecursively method.

Looks like you reverted that change, but there are still some left-over related diffs.

@sbomer
Copy link
Member

I'm good with the changes to how we iterate over overrides. I haven't thought of a case where we would modify the set while iterating over it, but the for loop doesn't hurt.

Copy link
Member

@sbomersbomer left a comment

Choose a reason for hiding this comment

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

Good find, thank you!

{
_methods=newQueue<(MethodDefinition,DependencyInfo,MessageOrigin)>();
_virtual_methods=newHashSet<(MethodDefinition,MarkScopeStack.Scope)>();
_virtual_methods=newDictionary<MethodDefinition,MarkScopeStack.Scope>();
Copy link
Member

Choose a reason for hiding this comment

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

Is the perf improvement due to the change of key? If so isMethodDefinition actually a good option for lookups? It doesn't implementIEquatable and doesn't have a customGetHashcode. Would a custom record using what makes aMethodDefinition identity better then?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The trimmer only creates a singleMethodDefinition object for each method definition in metadata, soobject's implementation ofGetHashCode andEquals are fine here.

@jtschusterjtschuster merged commit7b18be5 intodotnet:mainApr 12, 2024
matouskozak pushed a commit to matouskozak/runtime that referenced this pull requestApr 30, 2024
The _virtual_methods cache had duplicates due to the Scope item in the tuple, which made ProcessVirtualMethods do significantly more work. This PR makes the cache a dictionary, with TryAdd's instead of Add to only add each method once. These changes made caused the overrides cache in TypeMapInfo to be modified during iteration, so a for loop is used instead of a foreach loop. This should be find since the list will always be append-only. I noticed we copy _typesWithInterfaces to an array for the same reason, though since that's also append-only we can iterate with a for loop there, too.Fixesdotnet/sdk#40060.
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMay 13, 2024
@sebastienros
Copy link
Member

Quick update on this PR, this definitely fixed the regression

image

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@sebastienrossebastienrossebastienros left review comments

@sbomersbomersbomer approved these changes

@vitek-karasvitek-karasAwaiting requested review from vitek-karas

@marek-safarmarek-safarAwaiting requested review from marek-safarmarek-safar is a code owner

@agockeagockeAwaiting requested review from agocke

Assignees

@jtschusterjtschuster

Labels

area-Tools-ILLink.NET linker development as well as trimming analyzerslinkable-frameworkIssues associated with delivering a linker friendly framework

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PublishTrimmed build time regression.

3 participants

@jtschuster@sbomer@sebastienros

[8]ページ先頭

©2009-2025 Movatter.jp