Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid calling GetInvocationList on hot paths #4736

Merged
merged 1 commit into from
Aug 17, 2021

Conversation

stephentoub
Copy link
Member

Description

GetInvocationList on one or more delegates is being called in response to most any input operation. We can instead call GetInvocationList only when the set of delegates changes, and use that list over and over.

Customer Impact

Reduced Delegate[] allocation leading to less pressure on the GC. You can see the impact of this with a simple sample WPF app; in this trace, I just open the app and interact with it for a few seconds. These are the top allocations:
image

Regression

No

Testing

Just CI

Risk

I'm making an assumption that it's much more common for these events to be invoked than it is for them to be changed (delegates added or removed from the events). If it were more common for them to be changed than for them to be invoked, this would be a deoptimization.

GetInvocationList on one or more delegates is being called in response to most any input operation.  We can instead call GetInvocationList only when the set of delegates changes, and use that list over and over.
@stephentoub stephentoub requested a review from a team as a code owner June 24, 2021 02:32
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Jun 24, 2021
@ghost ghost requested review from fabiant3, ryalanms and SamBent June 24, 2021 02:32
@ryalanms ryalanms merged commit ff8305c into dotnet:main Aug 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants