-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Blazor WebAssembly internal profiling infrastructure #23510
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
Conversation
if (IsCapturing) | ||
{ | ||
InternalCalls.InvokeJSUnmarshalled<string, object, object, object>( | ||
out _, "_blazorProfileStart", name!, null!, null!); |
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.
Why do we do null!
here?
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.
The nullability hints on InvokeJSUnmarshalled
say that the parameters have to be nonnull, but that's incorrect - they can be null (as they are here).
Thanks for pointing this out. I've (hopefully) fixed the underlying hints now and changed these to regular null
.
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.
Great!
Co-authored-by: campersau <[email protected]>
@@ -25,14 +28,17 @@ enum DiffAction { Match, Insert, Delete } | |||
ArrayRange<RenderTreeFrame> oldTree, | |||
ArrayRange<RenderTreeFrame> newTree) | |||
{ | |||
ComponentsProfiling.Instance.Start(); |
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.
Why not use ProfilingStart
/ProfilingEnd
here?
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.
Because I wanted to include this method in the coarse-grained timings.
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.
Aha! OK -- I see how this call is different now.
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.
Looks good!
I like the approach of setting the isCapturing
flag from the host's JavaScript. Should be easy to strip out once we support perf tracing in both hosting models.
Goals:
[Conditional]
, and (2) no-opping the remaining calls quickly based on astatic bool
flag indicating whether capturing is currently in progress.Microsoft.AspNetCore.Components
, even though it violates the normal layering. I consider this an acceptable layering violation because it's completely nonpublic and won't have any impact on any other code.ComponentsProfiling
abstract because, even though there is a runtime cost to that, it's actually too small to be problematic even when capturing very detailed traces, and is completely undetectable when not capturing or when capturing coarsely-grained traces.ComponentsProfiling
public and then movingWebAssemblyComponentsProfiling
(still internal) into theWebAssembly
project. We'd need someCircuitComponentsProfiling
equivalent, though presumably it wouldn't do any JS interop and would instead be forwarding the calls to .NET's EventSource or similar.