Skip to content
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

Fix tracing problems #9622

Draft
wants to merge 4 commits into
base: v2
Choose a base branch
from
Draft

Conversation

yamadapc
Copy link
Contributor

@yamadapc yamadapc commented Apr 4, 2024

This PR fixes issues with the tracing implementation

Namely:

  • Makes use of BEGIN and END events rather than COMPLETE events only; this improves the output on some cases
  • Adds more instrumentation

if (!loadConfig) {
return;
}
return measureAsyncFunction(
Copy link
Member

Choose a reason for hiding this comment

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

what's the goal of measuring internal functions like this? This would be captured by the normal v8 profiler already. I thought the goal of tracing is to capture high level timings for user-facing things like plugins. If we start tracing internal things in Parcel core this gets muddier and harder for end users to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The goal is to capture high-level timings, so lower resolution than what the profiler will spit out (& lower or close to none overhead).

We could trace more internal bits though. It should not be granular.

I don't really care about the measurements added in this diff. More about the fixes.

For the measureAsyncFunction / measureFunction helpers ; they prevent mistakes where .end isn't currently called.

That was the case on packages/core/core/src/Transformation.js, where you can see I added measurement.end() calls that were previously not there. For those branches we had missing traces. Ideally we'd replace all measurement.end() calls with function wrappers, since then we can't not call .end().

@yamadapc yamadapc requested a review from marcins April 9, 2024 03:15
@@ -66,6 +74,7 @@ export default (new Reporter({
case 'buildSuccess':
case 'buildFailure':
nullthrows(tracer).flush();
writeStream?.write(']');
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't hurt, but not really necessary for a trace - the format is designed to work when the writer died before it could cleanly finish.

@@ -1979,7 +1979,8 @@ export type ValidationEvent = {|
* @section reporter
*/
export type TraceEvent = {|
+type: 'trace',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a breaking change?

@@ -1979,7 +1979,8 @@ export type ValidationEvent = {|
* @section reporter
*/
export type TraceEvent = {|
+type: 'trace',
+type: 'trace.start' | 'trace.end',
+id: string,
+ts: number,
+duration: number,
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a flow error in your calls to .trace() because the trace event expects a duration which now won't be relevant with begin/end events.

@mattcompiles mattcompiles requested a review from a team April 9, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants