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

Optimize Element.OnPropertyChanged #5656

Merged
merged 1 commit into from
Mar 30, 2022

Conversation

eerhardt
Copy link
Member

  • Don't foreach over the empty collection ChildrenNotDrawnByThisElement. The bulk of Element subclasses don't provide a value. Instead just return null.

This is a pretty minor, low-level optimization. But it shows to save 10% off setting simple properties.

Benchmark Results

Before

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
SetProperty 1.736 ms 0.0068 ms 0.0057 ms - - - 665 B

After

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
SetProperty 1.546 ms 0.0151 ms 0.0133 ms - - - 665 B

- Don't foreach over the empty collection ChildrenNotDrawnByThisElement. The bulk of Element subclasses don't provide a value. Instead just return null.
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

This one looks straightforward to me, a small improvement for everything that subclasses Element.

@jfversluis jfversluis added the legacy-area-perf Startup / Runtime performance label Mar 30, 2022
@rmarinho rmarinho merged commit a4d709b into dotnet:main Mar 30, 2022
@eerhardt eerhardt deleted the ElementOnPropertyChangedOptimization branch March 30, 2022 13:23
@mattleibow mattleibow added this to the 6.0.300-rc.1 milestone Mar 31, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
@Eilon Eilon added the t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) label May 10, 2024
@samhouts samhouts added the fixed-in-6.0.300-rc.1 Look for this fix in 6.0.300-rc.1! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-6.0.300-rc.1 Look for this fix in 6.0.300-rc.1! legacy-area-perf Startup / Runtime performance t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants