-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
fix(driver): wait for CPU idle #2473
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on a fix to this, @patrickhulce! So far I think this would make a sizable difference to at least one of the issues we were previously seeing 🎉
// networkQuietThresholdMs. | ||
const waitForNetworkIdle = this._waitForNetworkIdle(networkQuietThresholdMs, | ||
pauseAfterNetworkQuietMs); | ||
// Network listener. Resolves when the network has been idle for networkQuietThresholdMs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth expanding comment to Network and CPU listeners or adding a similar line above ...const waitForCPUIdle
for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, meant to do that thanks!
@@ -13,8 +13,8 @@ module.exports = { | |||
passName: 'defaultPass', | |||
recordTrace: true, | |||
pauseAfterLoadMs: 5250, | |||
networkQuietThresholdMs: 5000, | |||
pauseAfterNetworkQuietMs: 2500, | |||
networkQuietThresholdMs: 5250, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea here to realign networkQuietThresholdMs
and the new cpuQuietThresholdMs
with the pauseAfterLoadMs
delay instead of the lower pause thresholds previously being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the historical background to pauseAfterNetworkQuiet
was that we needed a way to account for CPU work after scripts have finished downloading, so it became the number for "what's the longest after network quiet we might reasonably expect a long task to occur"
now that this role has been subsumed by a bona fide CPU idle check, we don't need it anymore, however, we still want a little bit of slack in our cutoff thus 5250
instead of straight 5000
pauseAfterLoad
is probably still worth keeping around for now as there are cases like the ember + fastboot where "quiet" can be reached too quickly without really reaching the load state, and it's good to see the full timeline as we try to improve the other heuristics
lighthouse-core/gather/driver.js
Outdated
tryLater(); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite as close to this code as @brendankenny or @paulirish might be, but the general approach to using long-tasks here sgtm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, this is a great idea.
evaluateScriptOnLoad
will end up adding a performance observer on every pass with a non-0 cpuQuietThresholdMs
, so what about just adding it once in gatherRunner.setupDriver
in the style of driver.cacheNatives
? I believe that would also allow dropping markAsResolvable
, as it could just start checking as soon as network was done
Getting rid of markAsResolvable would be nice, but I'm not sure the trade-off of moving this specific functionality that's only for waitForCPUIdle into setupDriver is that much better? |
bump :) |
does it make sense to cache the native peformanceObserver as we do with Promise and Error? |
@wardpeet I think it's much less of a problem here since for Promise and Error we relied on them being the actual original classes for instanceof and protocol promise support. Here we just want the PerformanceObserver functionality without caring about the specific object it references. Much like we do with all the other browser APIs we use (Image, DOM APIs, setTimeout, etc) |
@patrickhulce 👍 sounds reasonable 😄 Can't wait to have this landed! |
🏏 🏏 |
1 similar comment
🏏 🏏 |
initialUrl: 'http://localhost:10200/tricky-ttci.html', | ||
url: 'http://localhost:10200/tricky-ttci.html', | ||
audits: { | ||
'first-interactive': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we assert the rawValue is over 9000 ?
😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love it, gotta check those power levels
@@ -460,27 +520,28 @@ class Driver { | |||
* See https://github.com/GoogleChrome/lighthouse/issues/627 for more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method description need an update. Can you flesh it out a bit so we won't have to look back up the PR when trying to read the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
should fix #2475 (the issue raised in tastejs/hacker-news-pwas#63), the large class of remaining sites in #2293, and the last 10% that were left after #2347
🎉 🎉 🎉 🎉 🎉
Best explained by the comment:
This change also makes the
pauseAfterNetworkQuiet
heuristic no longer necessary, so it's been removed as well to keep our number of config flags the same.