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(lantern): extract main thread events w/o TraceProcessor #16049

Merged
merged 4 commits into from
Jun 10, 2024

Conversation

connorjclark
Copy link
Collaborator

Lantern needs just the main thread events (regardless of navigations), so it used lib/trace-processor. Now Lantern does that itself in createGraphFromTrace.

ref #15841

@connorjclark connorjclark requested a review from a team as a code owner June 7, 2024 21:02
@connorjclark connorjclark requested review from adamraine and removed request for a team June 7, 2024 21:02
}

return this._filteredTraceSort(trace.traceEvents, e => rendererPidToTid.get(e.pid) === e.tid);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

w/o _filteredTraceSort(instead of just array.filter) no tests fail ... so is it needed?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's needed. I looked at how we use main thread events in lantern and we just look for top level CPU tasks. Those should really never have the same timestamp which seems to be the purpose of that function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

seems convincing

*/
static _collectMainThreadEvents(trace, traceEngineResult) {
const Meta = traceEngineResult.data.Meta;
const rendererPidToTid = new Map();
Copy link
Collaborator Author

@connorjclark connorjclark Jun 7, 2024

Choose a reason for hiding this comment

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

rendererPidToTid here gets constructed with different results than TraceProcessor was doing ...

consider the first test in core/test/computed/metrics/speed-index-test.js (should compute a simulated value) as an example, TraceProcessor only has one renderer in this map, but this version has two. the extra one is the initial about:blank renderer. this seems like something to avoid ... it happens b/c the about:blank is in topLevelRendererIds. I'm not yet sure how TraceProcessor ends up excluding it.

the result is more events end up in mainThreadEvents

Copy link
Collaborator Author

@connorjclark connorjclark Jun 7, 2024

Choose a reason for hiding this comment

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

ok I think const mainFramePids = Meta.mainFrameNavigations.map(nav => nav.pid); instead of using topLevelRendererIds kinda resolves this. Not sure what would happen w/o any navigation though .... so I'll fall back to topLevelRendererIds in that case.

}

return this._filteredTraceSort(trace.traceEvents, e => rendererPidToTid.get(e.pid) === e.tid);
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's needed. I looked at how we use main thread events in lantern and we just look for top level CPU tasks. Those should really never have the same timestamp which seems to be the purpose of that function.

const Meta = traceEngineResult.data.Meta;
const mainFramePids = Meta.mainFrameNavigations.length
? new Set(Meta.mainFrameNavigations.map(nav => nav.pid))
: Meta.topLevelRendererIds;
Copy link
Member

Choose a reason for hiding this comment

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

Why not just use Meta.topLevelRendererIds all the time? Seems like it represents what we want?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Approving cuz I'm kinda just throwing ideas against the wall but I also saw rendererProcessesByFrame in the trace processor. It isn't fed by main frame navigations but it is fed by CommitLoad which seems similar.

@connorjclark connorjclark changed the title core(lantern): extract main thread events without LH TraceProcessor core(lantern): extract main thread events without TraceProcessor Jun 10, 2024
@connorjclark connorjclark changed the title core(lantern): extract main thread events without TraceProcessor core(lantern): extract main thread events w/o TraceProcessor Jun 10, 2024
@connorjclark connorjclark merged commit b242369 into main Jun 10, 2024
28 of 29 checks passed
@connorjclark connorjclark deleted the lantern-no-trace-processor branch June 10, 2024 19:03
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.

None yet

3 participants