-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Reduce ThicknessConverter allocs to minimum and improve conversion performance #9363
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
Reduce ThicknessConverter allocs to minimum and improve conversion performance #9363
Conversation
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThicknessConverter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThicknessConverter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ThicknessConverter.cs
Outdated
Show resolved
Hide resolved
/azp run |
1 similar comment
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
…rge chunk of allocs
2dd4be2
to
72058ef
Compare
@harshit7962 I have fixed the merge conflicts and rebased. No other changes have been done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-Approving after a stale review. Thank you @h3xds1nz for resolving the conflicts
Thank you @h3xds1nz for your contributions. |
@harshit7962 Thank you for making this one happen, sent #9364 in and marked it as ready. That will clear out rest of the allocations. |
Description
Simplifies code in
CanConvertTo
/ConvertFrom
/ConvertTo
, removes additional type casts by usingis
checks/pattern match. Commits should be easy to review.Uses
DefaultInterpolatedStringHandler
instead ofStringBuilder
to handle conversion inToString
with a pre-allocated on-stack buffer (not using interpolated strings directly due to theNaN
->Auto
conversion which would box as Roslyn won't handle that one.Also stackallocs 4 doubles instead of allocating an array in
FromString
, this uses unsafe quotation due to how the current code-gen with Span looks like; additional perf improvement. I didn't include benchmark/tests in this one, they're together in the other PR forLengthConverter
#9364.Multiple decimals point (edge case but within original range)
Single decimal point, standard use-case
Conversion from
double.NaN
toAuto
Customer Impact
Improved performance, greatly decreased allocations.
Regression
No.
Testing
Local build, basic set of assert testing.
Risk
Low.
Microsoft Reviewers: Open in CodeFlow