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

misc(timing): move timing-trace to async events #6440

Merged
merged 5 commits into from
Nov 5, 2018

Conversation

paulirish
Copy link
Member

Motivated by #6410

I was avoiding async events for .. mysterious reasons before. But really these will be overlapping, so it makes more sense to be async.

Overlapping happens in promise.all()s often:
image

Here's how a few timing traces look now:
image
image

const startEvt = {
// 1) Remove 'lh:' for readability
// 2) Colons in user_timing names get special handling in traceviewer we don't want. https://goo.gl/m23Vz7
// Replace with a 'Modifier letter colon' ;)
Copy link
Collaborator

Choose a reason for hiding this comment

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

😆

pid: 0,
tid: trackName === 'measures' ? 50 : 75,
ph: 'X',
tid: threadId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like I'm missing something.

I only see one call to this method changed with a threadId isn't this basically the same as what was happening before then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah totally the same as before. trackName => threadId has no functional changes, really. with these new events we can't label the track.
not a huge deal anyway.

expect(consoleError.mock.calls[0][0]).toContain('measures overlap');
it('generates a pair of trace event', () => {
const events = generateTraceEvents(mockEntries[0]);
expect(events).toMatchSnapshot();
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

]
`;

exports[`generateTraceEvents generates a pair of trace event 1`] = `Array []`;

This comment was marked as resolved.

@paulirish
Copy link
Member Author

thoughts?


I've added support for DevTools Perf panel (via adding a TracingStartedInBrowser evt):
image

Though note: -G/-A traces are shown in two diff tracks in chrome:tracing but that's not supported in DevTools:
image

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

code seems fine to me other than test Q!

expect(consoleError.mock.calls[0][0]).toContain('measures overlap');
it('generates a pair of trace events', () => {
const events = generateTraceEvents([mockEntries[0]]);
expect(events.slice(0, 1)).toMatchSnapshot();

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

lol thx

Copy link
Member

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

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

nit: zero duration test cov not hit.

expect(consoleError.mock.calls[0][0]).toContain('measures overlap');
it('generates a pair of trace events', () => {
const events = generateTraceEvents([mockEntries[0]]);
expect(events.slice(0, 1)).toMatchSnapshot();
});
});

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

good call. actually we dont need the ph:'n' now that we're on async events.
problem solved. :)

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM!

}
}
}

/**
* Generates a chromium trace file from user timing measures
* Adapted from https://github.com/tdresser/performance-observer-tracing
Copy link
Member

Choose a reason for hiding this comment

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

maybe add a note about how threadId is used?

// 1) Remove 'lh:' for readability
// 2) Colons in user_timing names get special handling in traceviewer we don't want. https://goo.gl/m23Vz7
// Replace with a 'Modifier letter colon' ;)
name: entry.name.replace('lh:', '').replace(/:/g, '꞉'),
Copy link
Member

Choose a reason for hiding this comment

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

😆

maybe do an explicit .replace(/:/g, '\ua789'), just to make it doubly clear that the character is different?

// 2) Colons in user_timing names get special handling in traceviewer we don't want. https://goo.gl/m23Vz7
// Replace with a 'Modifier letter colon' ;)
name: entry.name.replace('lh:', '').replace(/:/g, '꞉'),
cat: 'blink.user_timing',
Copy link
Member

Choose a reason for hiding this comment

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

it feels like doing this should be possible without faking out a browser trace but w/e traceviewer :)

Copy link
Member Author

Choose a reason for hiding this comment

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

traceviewer wont group these but give each measure its own track otherwise
and devtools needs it to view them.

@@ -50,7 +50,7 @@ function saveTraceFromCLI() {
// eslint-disable-next-line no-console
console.log(`
> Timing trace file saved to: ${traceFilePath}
> Open this file in chrome://tracing
> Open this file in DevTools perf panel (or if it's a -G/A run, use chrome://tracing)
Copy link
Member

Choose a reason for hiding this comment

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

does -G/A run refer to a "-G or an -A run", or a -GA run or a regular run (that did both gathering and auditing)?

@brendankenny
Copy link
Member

(with nits :)

@paulirish paulirish merged commit f4aa2c6 into master Nov 5, 2018
@paulirish paulirish deleted the timing-trace-async-events branch May 2, 2019 21:56
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.

5 participants