Skip to content

Using ArrayPool in RenderData#5392

Merged
dipeshmsft merged 2 commits intodotnet:mainfrom
dotnet-campus:t/lindexi/RenderDataArrayPool
Jan 3, 2022
Merged

Using ArrayPool in RenderData#5392
dipeshmsft merged 2 commits intodotnet:mainfrom
dotnet-campus:t/lindexi/RenderDataArrayPool

Conversation

@lindexi
Copy link
Member

@lindexi lindexi commented Sep 26, 2021

Description

Using ArrayPool in RenderData. The max length is 72, see MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE

[StructLayout(LayoutKind.Explicit)]
internal struct MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE
{
public MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE (
UInt32 hBrush,
UInt32 hPen,
Rect rectangle,
UInt32 hRectangleAnimations,
double radiusX,
UInt32 hRadiusXAnimations,
double radiusY,
UInt32 hRadiusYAnimations
)
{
this.hBrush = hBrush;
this.hPen = hPen;
this.rectangle = rectangle;
this.hRectangleAnimations = hRectangleAnimations;
this.radiusX = radiusX;
this.hRadiusXAnimations = hRadiusXAnimations;
this.radiusY = radiusY;
this.hRadiusYAnimations = hRadiusYAnimations;
this.QuadWordPad0 = 0;
}
[FieldOffset(0)] public Rect rectangle;
[FieldOffset(32)] public double radiusX;
[FieldOffset(40)] public double radiusY;
[FieldOffset(48)] public UInt32 hBrush;
[FieldOffset(52)] public UInt32 hPen;
[FieldOffset(56)] public UInt32 hRectangleAnimations;
[FieldOffset(60)] public UInt32 hRadiusXAnimations;
[FieldOffset(64)] public UInt32 hRadiusYAnimations;
[FieldOffset(68)] private UInt32 QuadWordPad0;
}

Customer Impact

None. But it will affect the rendering of all DrawingVisual and UIElement

Regression

dotnet 7

Testing

Just CI and my demo

Risk

Low

The max length is 72, see MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE
@lindexi lindexi requested a review from a team as a code owner September 26, 2021 00:51
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Sep 26, 2021
@ghost ghost requested review from SamBent, fabiant3 and ryalanms September 26, 2021 00:51
lindexi added a commit to lindexi/lindexi_gd that referenced this pull request Sep 26, 2021

~RenderData()
{
ArrayPool<byte>.Shared.Return(_buffer);
Copy link
Member

Choose a reason for hiding this comment

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

Can this just be "disposed" normally? Using a finalizer is quite heavy and puts pressure on the GC's finalizer queue. Especially with

The max length is 72

in mind, maybe it's just cheaper to allocate and let the GC clean up.
Or as there is unsafe code already involved use a struct with fixed sized buffer of that size, and wrap by a span for access outside that class?

Copy link
Member Author

Choose a reason for hiding this comment

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

@gfoidl Thank you and I update the PR

@kronic
Copy link

kronic commented Sep 29, 2021

@lindexi maybe you should delete the field altogether _buffer

@lindexi
Copy link
Member Author

lindexi commented Sep 29, 2021

@kronic Thank you. But I find it hard to delete the _buffer field

@dipeshmsft dipeshmsft merged commit b3fee31 into dotnet:main Jan 3, 2022
@omariom
Copy link
Contributor

omariom commented Jan 3, 2022

@dipeshmsft
What does the team use for perf benchmarks?

@dipeshmsft
Copy link
Member

@omariom We mainly use sample applications to review the performance benefits and we rely on our regression suite to check any performance regressions.

@lindexi
Copy link
Member Author

lindexi commented Jan 5, 2022

@dipeshmsft Thank you.

@lindexi lindexi deleted the t/lindexi/RenderDataArrayPool branch January 5, 2022 00:36
@omariom
Copy link
Contributor

omariom commented Jan 16, 2022

@dipeshmsft
Can their source be opened so we could use them in our PRs?

@dipeshmsft
Copy link
Member

@omariom , we are working on open-sourcing the complete test-suite. You can check the repo dotnet/wpf-test , but the task is still in progress. @gurpreet-wpf

@lindexi
Copy link
Member Author

lindexi commented Jan 18, 2022

@dipeshmsft Can I publish my private WPF framework version?

@dipeshmsft
Copy link
Member

@vishalmsft @gurpreet-wpf Could you take a look at this ??

@vishalmsft
Copy link
Contributor

@lindexi do you mean tests written and available in your private repo?

@lindexi
Copy link
Member Author

lindexi commented Jan 20, 2022

@vishalmsft I mean that can I publish my nuget package which include my private WPF framework version? Some of my friends can't wait for the official WPF release. I expect to provide a private version for them to use. Thank you.

@lindexi
Copy link
Member Author

lindexi commented Jan 20, 2022

And this version wpf framework may used in the business application.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 6, 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.

6 participants