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(tbt): Clean up total blocking time code #9409

Merged
merged 5 commits into from
Jul 23, 2019

Conversation

deepanjanroy
Copy link
Contributor

@deepanjanroy deepanjanroy commented Jul 18, 2019

This PR cleans up Total Blocking Time code in lighthouse. It

  • changes the name from CLQD -> TBT as decided by the bikeshedding doc.
  • Changes the definition of blocking time to be anything after first 50ms of a task, as opposed to anything before last 50ms. People found the previous definition confusing, and this detail would change the value of the metric only by a maximum of 50ms, so the simplicity is worth it.
  • Has properly i18n-ed UI strings.

@deepanjanroy deepanjanroy changed the title core(TBT): Clean up total blocking time code core(tbt): Clean up total blocking time code Jul 18, 2019
yarn.lock Outdated Show resolved Hide resolved
lighthouse-core/lib/i18n/locales/en-XL.json Outdated Show resolved Hide resolved
@brendankenny
Copy link
Member

brendankenny commented Jul 18, 2019

I'd like to get this into 5.2 5.3 so the next http archive run (starting August 1st) will have the up-to-date version of TBT

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.

thanks @deepanjanroy, I'm really excited about this metric! 😃

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.

some comment nits but otherwise LGTM!

lighthouse-core/audits/metrics/total-blocking-time.js Outdated Show resolved Hide resolved
lighthouse-core/computed/metrics/total-blocking-time.js Outdated Show resolved Hide resolved
lighthouse-core/computed/metrics/total-blocking-time.js Outdated Show resolved Hide resolved
lighthouse-core/audits/metrics/total-blocking-time.js Outdated Show resolved Hide resolved
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.

Just a few testing questions, but impl looks good to me!

@@ -35,5 +34,6 @@ Object {
"observedTraceEndTs": 225426711887,
"speedIndex": 1657,
"speedIndexTs": undefined,
"totalBlockingTime": 726,
Copy link
Collaborator

Choose a reason for hiding this comment

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

now that the clipping order has moved back to the original, the fact that this changes is unexpected to me.

could we perhaps add a new unit test case that would be different between the two versions to capture this more explicitly?

from my reading it should only be different in cases that I thought to be impossible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm very good point - thanks for flagging this. I looked into it, and looks like the impossible is happening - TTI is in the middle of a task for the lantern test case (and it's not at FMP or DCL). Right now I'm trying to understand why that is the case.

Side note: It looks like lantern TTI does not consider DCL. I see this at line 70 of lantern-interactive.js. Is this expected?

    const lastTaskAt = LanternInteractive.getLastLongTaskEndTime(simulationResult.nodeTimings);
    const minimumTime = extras.optimistic
      ? extras.fmpResult.optimisticEstimate.timeInMs
      : extras.fmpResult.pessimisticEstimate.timeInMs;
    return {
      timeInMs: Math.max(minimumTime, lastTaskAt),
      nodeTimings: simulationResult.nodeTimings,
    };

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, right because we are using the TTI estimate timeInMs of a potentially different graph so it is possible.

Re: DCL, Yeah there's not a reliable way we have to predict when DCL will occur under a hypothetical connection type so it's not considered.

AI from my perspective: we add a test case just exercising the TTI clipping behavior with a comment about why this can happen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right. That sgtm: added test case just for TTI clipping.

{start: 1000, end: 1110, duration: 110}, // Contributes 10ms.
{start: 2000, end: 2200, duration: 200}, // Contributes 50ms.
// The clipping is done first, so the task becomes [150, 200] after clipping and contributes
// 0ms of blocking time. This is in contrast to first calculating the blocking region ([100,
Copy link
Collaborator

Choose a reason for hiding this comment

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

would you mind adding a few other edge cases?

The fact that I can't figure out why this new version is different from before is my primary motivation :)

I'm thinking...

          FCP at 1000 ms
          |
        =====  Task >50ms ends before 1050 ms
        ======  Task >50ms ends at 1050 ms
        =======  Task >50ms starts before 1000 ms and ends after 1050 ms

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added these cases.

@brendankenny brendankenny added 5.3 and removed 5.2 labels Jul 23, 2019
Copy link
Contributor Author

@deepanjanroy deepanjanroy left a comment

Choose a reason for hiding this comment

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

Added some more tests. All comments should be addressed now.

@@ -35,5 +34,6 @@ Object {
"observedTraceEndTs": 225426711887,
"speedIndex": 1657,
"speedIndexTs": undefined,
"totalBlockingTime": 726,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right. That sgtm: added test case just for TTI clipping.

{start: 1000, end: 1110, duration: 110}, // Contributes 10ms.
{start: 2000, end: 2200, duration: 200}, // Contributes 50ms.
// The clipping is done first, so the task becomes [150, 200] after clipping and contributes
// 0ms of blocking time. This is in contrast to first calculating the blocking region ([100,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added these cases.

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.

LGTM, thanks for working through those test issues!

@patrickhulce
Copy link
Collaborator

@brendankenny did you explicitly not want it to land for 5.2?

@brendankenny
Copy link
Member

@brendankenny did you explicitly not want it to land for 5.2?

It depends on how @paulirish wants to do the branch? Presumably it could branch from any commit...

@patrickhulce
Copy link
Collaborator

patrickhulce commented Jul 23, 2019

Yeah I got that part :) (via chat) I'm asking why you wouldn't want it to be included in 5.2 so we don't have to rush out a 5.3 before August 1?

@brendankenny
Copy link
Member

lol oh I see, yeah that makes sense. Let's land :)

@patrickhulce patrickhulce merged commit 85429f9 into GoogleChrome:master Jul 23, 2019
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.

4 participants