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(mainthread-work-breakdown): add TBT savings #15201

Merged
merged 9 commits into from
Sep 20, 2023
Merged

Conversation

adamraine
Copy link
Member

No description provided.

@adamraine adamraine requested a review from a team as a code owner June 26, 2023 15:52
@adamraine adamraine requested review from brendankenny and removed request for a team June 26, 2023 15:52
const tbtResult = await TotalBlockingTime.request(metricComputationData, context);
tbtSavings = tbtResult.timing;
} catch (err) {
if (!/Could not find any top level events/.test(err)) throw err;
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this case to pass the "no events are present" case for this audit. In practices we shouldn't ever hit this error, and if we do then there are probably bigger problems than this audit. I'm open to removing that test case if it cleans up the code here a bit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it work to make this computed artifact return null in this case, and having callers that would find that exceptional throw themselves?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's a lot of null handling for an error that generally shouldn't happen. Plus we would have to generalize it for all computed metrics not just TBT since the result type is shared.

TBH I think it would be more reasonable to remove this logic and surface the error in the audit if the main thread doesn't have any tasks. The only reason this exception is made is for one of our test cases that asserts this audit returns no data if there are no tasks.

@@ -91,47 +119,57 @@ Object {
expect(Math.round(output.numericValue)).toMatchInlineSnapshot(`979`);
assert.equal(output.details.items.length, 7);
assert.equal(output.score, 1);
});

it('should compute the correct values for the load trace (legacy)', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

@connorjclark is there a reason we need to keep this around since it wasn't removed in #15005?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, as long as we still have code handling TracingStartedInPage for back compat.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. I reintroduced this test case, however the old trace we have stored causes a NO_DCL error when we try and compute the TBT. For this reason, I've changed the error handling logic to bypass all errors when computing TBT and report to sentry.

}
`);
expect(Math.round(output.numericValue)).toMatchInlineSnapshot(`224`);
expect(Math.round(output.numericValue)).toMatchInlineSnapshot(`775`);
Copy link
Member Author

@adamraine adamraine Jun 26, 2023

Choose a reason for hiding this comment

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

Before this patch, throttlingMethod had a value of undefined so we didn't apply the 4x CPU multiplier to the timings.

In this patch we need to specify the same throttlingMethod that was used to collect the trace, otherwise we can't compute TBT. In this case it was simulate

@adamraine adamraine merged commit 7d46afa into main Sep 20, 2023
27 checks passed
@adamraine adamraine deleted the main-thread-bd-savings branch September 20, 2023 20:10
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.

4 participants