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

core(trace-processor): refactor processEvents and frameEvents #14287

Merged
merged 46 commits into from
Jan 26, 2023

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented Aug 12, 2022

As discovered in #14264 we were severely excluding events in our processEvents array. And also frameEvents, frameTreeEvents, and mainThreadEvents.

The primary changes here are in trace-processor and this pr contains mostly bug fixes. I envision a second PR which refactors the traceprocessor functions and flow a bit (and wouldn't adjust test results). I can do that here, too, but i'll leave that to the reviewer to opt-in to.

Observations & changes:

  • about:blank => website can undergo a process switch. the twitter.com repro makes this super obvious.
  • findMainFrameIds() returns the "starting" pid, but that will not be the pid of the primary navigation necessarily. that needs to be found afterwards.
  • frameIds are consistent across x-process navigations. (always have been, AFAIK)
  • the FrameCommittedInBrowser event is great and spells out the potentially-new processId of the renderer in the new navigation.
  • I tried to support the usecase of 'multiple navigations in one trace' (eg in timespans). I'm not convinced we support that well right now.
  • Trace events explicitly associated with a frame are generally tagged with either args.data.frame or args.frame. No consistency. Where I saw our code depending on one location, I expanded it to both.
  • Removed trace minification

Followup work:

edit: filed trace processor - cleanup and fixes ☂️ · #14708

@paulirish paulirish requested a review from a team as a code owner August 12, 2022 23:44
@paulirish paulirish requested review from adamraine and removed request for a team August 12, 2022 23:44
expect(frameTreeEventOutput).toMatchInlineSnapshot(`
Array [
"navigationStart - ROOT_FRAME",
"FrameCommittedInBrowser - ROOT_FRAME",
Copy link
Member Author

Choose a reason for hiding this comment

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

diff-wise: the two FrameCommittedInBrowser items here are the new rows.
I added the frame identifier to spell out the tree.

@@ -12,7 +12,6 @@ import {readJson} from '../../test-utils.js';

const pwaTrace = readJson('../../fixtures/traces/progressive-app.json', import.meta);
const badNavStartTrace = readJson('../../fixtures/traces/bad-nav-start-ts.json', import.meta);
const lateTracingStartedTrace = readJson('../../fixtures/traces/tracingstarted-after-navstart.json', import.meta);
Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out startedAfterNavstartTrace (which is already required in this test) is the same asset. I liked that name better.

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.

Really nice!

  • do we have a test trace that switches processes? I assume no but it would be good to have one
  • one thing that gets us still is if somehow a pid gets re-used (however unlikely that is while tracing). Having just a map of pid->tid says nothing about the timing. Seems like we might need a temporal aspect to the tracking as well? Or just step though the trace, subsetting in chunks between any FrameCommittedInBrowser events. That might be what you mean by "determine the "inspected" pids/frames in one pass before doing all the subsetting", though?

core/computed/metrics/responsiveness.js Show resolved Hide resolved
core/lib/minify-trace.js Outdated Show resolved Hide resolved
types/artifacts.d.ts Outdated Show resolved Hide resolved
core/test/create-test-trace.js Show resolved Hide resolved
core/lib/tracehouse/trace-processor.js Outdated Show resolved Hide resolved
let tid = threadNameEvt?.tid;

// Fallback as many test/fixture traces are missing metadata blocks
if (!tid) {
Copy link
Member

@brendankenny brendankenny Aug 16, 2022

Choose a reason for hiding this comment

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

Would there be an easy way to make sure we don't fall back to this in new traces? If somehow the thread_name event changed format it would be good if the change wasn't masked by the fallback still working.

On the other hand we don't want to throw for users if the fallback works fine still, so probably not a good idea to throw directly, but would there be a way to alert to changes to the event in our ToT tests?

core/lib/tracehouse/trace-processor.js Outdated Show resolved Hide resolved
core/lib/tracehouse/trace-processor.js Show resolved Hide resolved
core/lib/tracehouse/trace-processor.js Outdated Show resolved Hide resolved
core/test/lib/tracehouse/trace-processor-test.js Outdated Show resolved Hide resolved
core/lib/tracehouse/trace-processor.js Outdated Show resolved Hide resolved
core/lib/tracehouse/trace-processor.js Outdated Show resolved Hide resolved
core/lib/tracehouse/trace-processor.js Outdated Show resolved Hide resolved
core/lib/tracehouse/trace-processor.js Outdated Show resolved Hide resolved
@connorjclark
Copy link
Collaborator

Can you extract the followup work to a new issue?

Copy link
Member

@adamraine adamraine left a comment

Choose a reason for hiding this comment

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

LGTM

@paulirish
Copy link
Member Author

Still outstanding review comments:

That resolves the only remaining open threads on this PR.

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!

@paulirish paulirish changed the title core(trace-processor): fix subsetting of processEvents and frameEvents core(trace-processor): refactor processEvents and frameEvents Jan 26, 2023
@paulirish paulirish merged commit 421af38 into main Jan 26, 2023
@paulirish paulirish deleted the processEventsfix branch January 26, 2023 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants