Skip to content

perf: Experiment with different approach for DP storage - #18093

Draft
Youssef1313 wants to merge 3 commits into
unoplatform:masterfrom
Youssef1313:perf-dpdetailscollection
Draft

Youssef1313 wants to merge 3 commits into
unoplatform:masterfrom
Youssef1313:perf-dpdetailscollection

Conversation

@Youssef1313

@Youssef1313 Youssef1313 commented Aug 31, 2024 •

Copy link
Copy Markdown
Member

GitHub Issue (If applicable): closes #

PR Type

What kind of change does this PR introduce?

What is the current behavior?

Too much allocations happening inside DependencyPropertyDetailsCollection for offsets and entries arrays.

What is the new behavior?

This PR experiments an approach that's more memory friendly.

Here is a comparison during SamplesApp startup.

image

Most significant part of the diff:

image

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

@Youssef1313
Youssef1313 force-pushed the perf-dpdetailscollection branch from 4b1d4db to aee1c04 Compare August 31, 2024 20:15
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@ajpinedam ajpinedam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change looks good, as do the numbers you shared.


private readonly static ArrayPool<short> _offsetsPool = ArrayPool<short>.Shared;
private readonly static LinearArrayPool<DependencyPropertyDetails?> _pool = LinearArrayPool<DependencyPropertyDetails?>.CreateAutomaticallyManaged(BucketSize, 16);
private DependencyPropertyDetails[] _entries = Array.Empty<DependencyPropertyDetails>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change basically removes the pooling to allocate every time. This is curious that this leads to improvements.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Pooling doesn't seem very much beneficial in this case, I think. Those arrays are more commonly long living, while pooling is more useful for short living objects.

@Youssef1313
Youssef1313 force-pushed the perf-dpdetailscollection branch from 334ea2d to 841d49e Compare September 4, 2024 05:11
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@Youssef1313

Youssef1313 commented Sep 11, 2024 •

Copy link
Copy Markdown
Member Author

NOTES:

  • From my profiling, I don't see much of a regression with regards to CPU time, but the memory usage is a lot better with this PR. This can in fact impact app responsiveness as it can make it for faster GCs (due to less memory pressure, and potentially less Gen2 GCs)
  • If we think this approach has an impact on CPU time, we should consider one (or a combination) of these alternatives:
    • Adding a new DP option to specify the storage mode. The default (IMO) would be the new approach which is optimized more for memory, and an option "OptimizeForCPU" is added to use the old approach for REALLY very commonly accessed DPs.
    • Depending on device available memory, select the mode
    • Add a FeatureConfiguration for users to specify the (default) storage mode, based on their preferences.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days.

@github-actions github-actions Bot added the stale This item has been marked as stale and will be closed if there is no activity. label Feb 14, 2025
@MartinZikmund MartinZikmund removed the stale This item has been marked as stale and will be closed if there is no activity. label Mar 26, 2025
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days.

@github-actions github-actions Bot added the stale This item has been marked as stale and will be closed if there is no activity. label Jul 17, 2025
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions Bot closed this Jul 28, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 6, 2026
@MartinZikmund MartinZikmund removed the stale This item has been marked as stale and will be closed if there is no activity. label Jul 2, 2026
@MartinZikmund MartinZikmund reopened this Jul 2, 2026
@MartinZikmund
MartinZikmund marked this pull request as draft November 24, 2026 08:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants