-
Notifications
You must be signed in to change notification settings - Fork 10k
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 render tree building via RenderTreeFrameArrayBuilder #24484
Conversation
5fb52e2
to
c2af97e
Compare
…e it more easily in a moment
…timings by only 1% at the most.
456b848
to
98a23ac
Compare
In the end I decided I was uncomfortable with exposing the new mutability of This is technically a binary-breaking change because what was a field before is now a property, but it's not a breaking change for anyone recompiling their code (you can still read the same set of values with the same names). Plus the whole |
@@ -48,153 +48,181 @@ namespace Microsoft.AspNetCore.Components.RenderTree | |||
// Common | |||
// -------------------------------------------------------------------------------- | |||
|
|||
[FieldOffset(0)] internal int SequenceField; | |||
[FieldOffset(4)] internal RenderTreeFrameType FrameTypeField; |
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.
Is the goal that we don't "break" the entire world with this change?
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.
Yes, this change won't be breaking for any code that either (a) is recompiled after this change goes in, or (b) doesn't use RenderTreeFrame
directly (like our analyzer tells people).
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.
I'm thinking of things like bUnit and so on, they'll likely ignore your warning :)
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.
Yes I strongly expect so. I was going to contact @egil about this directly.
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.
Changes are pretty mechanic.
Looks great! I don't have major concerns since most of the API is internal.
If you want to remove methods in the future, file a follow-up issue so that we don't loose track of it.
I'm not saying I definitely do want to remove them. They aren't harmful, and being internal/private, they aren't a liability. I'll leave it to future-us to make this determination. |
Implementation of #24464
I'm seeing a 20% improvement for wall clock times on the FastGrid benchmark with this. The gain comes down to (1) making
RenderTreeFrame
mutable so we no longer have to copy frames every time we close elements/regions/components etc., and (2) creating a specialised variant ofArrayBuilder
that knows how to append instances of that struct without going through the factory methods that have to copy on assignment.We could now also remove all the
With...
methods onRenderTreeFrame
, plus technically all its static factory methods and probably all its constructors too. They are allinternal
/private
. However that would cause quite a bit of noise across our test code, so I don't want to make this PR that much bigger, or make the tests more laborious to write. We can always clean these away any time in the future if we want.