-
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
core(opportunities): take max of savings on TTI, load #5084
Conversation
@@ -314,6 +314,7 @@ declare global { | |||
|
|||
export interface LanternMetric { | |||
timing: number; | |||
timestamp?: never; |
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.
allows you to check existence of timestamp to see if it's Metric
or LanternMetric
@@ -122,7 +122,7 @@ class Node { | |||
* Clones the entire graph connected to this node filtered by the optional predicate. If a node is | |||
* included by the predicate, all nodes along the paths between the two will be included. If the | |||
* node that was called clone is not included in the resulting filtered graph, the method will throw. | |||
* @param {function(Node):boolean=} predicate | |||
* @param {function(Node):boolean} [predicate] |
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.
typechecker was always expecting at least one argument otherwise
@@ -26,12 +26,12 @@ class OffscreenImages extends ByteEfficiencyAudit { | |||
static get meta() { | |||
return { | |||
name: 'offscreen-images', | |||
description: 'Offscreen images', | |||
description: 'Defer offscreen images', |
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.
👏
Interactive.getLastLongTaskEndTime(simulationAfterChanges.nodeTimings), | ||
0 | ||
); | ||
const savingsOnLoad = options.includeLoad ? |
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.
how about we just default to this? no option needed.
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.
well that's effectively what's happening with the default options above
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.
sure, just pitching the idea of removing this condition entirely. always use savingsOnload
.
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.
maybe agree with the above. It's not clear why offscreen-images
is different and would be the only one to opt out
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.
because this function takes how many bytes that can be removed from each resource and simulates the graph if they were removed.
in offscreen images, we can't actually remove the bytes from being loaded at all. i.e. the result of this function with includeLoad
is no longer "defer offscreen images", but "delete all offscreen images". restricting the computation to savings on TTI preserves the contract of "defer offscreen images" because it's saying how much earlier could you push TTI if you loaded all this junk after TTI
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.
ok, makes sense. Maybe savingsOnOverallLoad
or something for the variable name to make it clear it's our handwavey overall load numbers and not onload
?
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
@@ -117,11 +132,13 @@ class OffscreenImages extends ByteEfficiencyAudit { | |||
return results; | |||
}, new Map()); | |||
|
|||
// TODO(phulce): move this to always use lantern |
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.
why not move this to lantern like the other ones?
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.
oh this is moving it to be lantern-based 👍
the extra check and comment below is clarifying that the timestamp dance is just an extra check in the non-lantern case, the graph should cover us for the most part
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.
got it. Comment + code (lantern artifact doesn't have timestamp
) was a little confusing, I guess.
Maybe add something about timestamp
like // If we're in the Lantern case and `timestamp` isn't available, we just have to rely...
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.
good call 👍
Interactive.getLastLongTaskEndTime(simulationAfterChanges.nodeTimings), | ||
0 | ||
); | ||
const savingsOnLoad = options.includeLoad ? |
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.
maybe agree with the above. It's not clear why offscreen-images
is different and would be the only one to opt out
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.
aside from the optionality thing, i'm lgtm on the rest.
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.
nits but LGTM!
Interactive.getLastLongTaskEndTime(simulationAfterChanges.nodeTimings), | ||
0 | ||
); | ||
const savingsOnLoad = options.includeLoad ? |
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.
ok, makes sense. Maybe savingsOnOverallLoad
or something for the variable name to make it clear it's our handwavey overall load numbers and not onload
?
simulationBeforeChanges.timeInMs - simulationAfterChanges.timeInMs : | ||
Number.MIN_VALUE; | ||
const savingsOnTTI = Interactive.getLastLongTaskEndTime(simulationBeforeChanges.nodeTimings) - | ||
Interactive.getLastLongTaskEndTime(simulationAfterChanges.nodeTimings); |
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.
rather than this Number.MIN_VALUE
thing, what about
const savingsOnOverallLoad = simulationBeforeChanges.timeInMs - simulationAfterChanges.timeInMs;
const savingsOnTTI = ...;
const savings = options.includeLoad ? Math.max(savingsOnOverallLoad, savingsOnTTI) : savingsOnTTI;
return Math.round(savings / 10) * 10;
?
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.
sg done
@@ -117,11 +132,13 @@ class OffscreenImages extends ByteEfficiencyAudit { | |||
return results; | |||
}, new Map()); | |||
|
|||
// TODO(phulce): move this to always use lantern |
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.
got it. Comment + code (lantern artifact doesn't have timestamp
) was a little confusing, I guess.
Maybe add something about timestamp
like // If we're in the Lantern case and `timestamp` isn't available, we just have to rely...
* @return {number} | ||
*/ | ||
static computeWasteWithTTIGraph(results, graph, simulator) { | ||
static computeWasteWithTTIGraph(results, graph, simulator, options) { |
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.
add docstring for includeLoad
option :)
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
closes #5017
byte efficiency audits will now take max savings on TTI/load
I had to address offscreen images at the same time otherwise they'd start way over-reporting
also contains some drive-by consistency text changes I noticed while testing, opportunity audits are actions for the user to take