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(tracehouse): improve CPU profiler timing refinement #11608

Merged
merged 6 commits into from
Nov 18, 2020

Conversation

patrickhulce
Copy link
Collaborator

Summary
Step 3 of ?? in the innocuous issue #8526 turned multi-quarter effort :)

This step further improves the timing data from CPU profiler samples by moving our _findEffectiveTimestamp improvements to a second pass that can utilize the pair of sampler events (which is required to understand parent/child relationships).

Next 4 steps in this saga...

  • Proactively split continuous looking events
  • Correctly handle negative timeDeltas
  • Interpolate dropped samples
  • Integrate the results into main-thread-tasks computed artifact

Related Issues/PRs
ref #8526

Ultimately I'll want @paulirish to give this a final sign off but in the meantime I'd love for your eyes on this too @adamraine :)

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.

Overall LGTM, just a couple quick comments.

// The FunctionCall at the next level, should be a child of Foo execution
{startTime: 10, endTime: 25},
// The FunctionCall at the next level, should be a child of Foo execution
{startTime: 12, endTime: 22},
Copy link
Member

Choose a reason for hiding this comment

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

super nit: not sure if this timing is accurately represented in the artistic representation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh you're right they should be nested nice catch :)

when I first read the super nit I thought it was talking about the scale of and I was like oh boy talk about "super nit" 🤣 but nah this isn't even a nit, very good comment 💯

Comment on lines +213 to +220
// We may have overshot a little from last time, so back up to find the real starting index.
let startIndex = initialIndex;
while (startIndex > 0) {
const task = knownTasks[startIndex];
if (task && task[type] < earliestPossibleTimestamp) break;
startIndex--;
}

Copy link
Member

Choose a reason for hiding this comment

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

Is there a test case covering this situation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, if we were to comment this out the (root) and (program) timestamps would not align in "should create events while aware of other tasks"

which is actually how I caught this bug, tests ftw! :)

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

overall lgtm.

one thing below in the tests that didnt look right to me

@@ -44,7 +44,8 @@ describe('CPU Profiler Model', () => {
};
});

describe('#_findEffectiveTimestamp', () => {
// TODO: re-enable these before landing, if structure looks good
Copy link
Member

Choose a reason for hiding this comment

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

noting this todo

{ph: 'E', ts: ts(45e3), args: {data: {callFrame: {functionName: 'Foo'}}}},
{ph: 'B', ts: ts(55e3), args: {data: {callFrame: {functionName: 'Bar'}}}},
{ph: 'E', ts: ts(85e3), args: {data: {callFrame: {functionName: 'Bar'}}}},
{ph: 'E', ts: ts(103e3), args: {data: {callFrame: {functionName: '(root)'}}}},
Copy link
Member

Choose a reason for hiding this comment

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

(root) from the cpu sampler takes the full duration.

but then the tasks above indicate we had 3 toplevel RunTasks.

how does that work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

From some real traces that's how it appears to work in practice with (idle) filling in the time in between the toplevel tasks. I can add another test for multiple roots though 👍

Copy link
Member

Choose a reason for hiding this comment

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

yeah it seems like (root), (idle) and (program) are are basically unlike the rest of the nodes in a cpu profile, so it feels like they dont belong as trace events.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah the integration PR I have where I have been finding the other failure modes filters those out :)

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

step 4 involves handling this case ?

{ph: 'E', ts: ts(45e3), args: {data: {callFrame: {functionName: 'Foo'}}}},
{ph: 'B', ts: ts(55e3), args: {data: {callFrame: {functionName: 'Bar'}}}},
{ph: 'E', ts: ts(85e3), args: {data: {callFrame: {functionName: 'Bar'}}}},
{ph: 'E', ts: ts(103e3), args: {data: {callFrame: {functionName: '(root)'}}}},
Copy link
Member

Choose a reason for hiding this comment

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

yeah it seems like (root), (idle) and (program) are are basically unlike the rest of the nodes in a cpu profile, so it feels like they dont belong as trace events.

@patrickhulce
Copy link
Collaborator Author

step 4 involves handling this case ?

that's step 3 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants