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(opportunities): take max of savings on TTI, load #5084

Merged
merged 3 commits into from
May 2, 2018

Conversation

patrickhulce
Copy link
Collaborator

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

@@ -314,6 +314,7 @@ declare global {

export interface LanternMetric {
timing: number;
timestamp?: never;
Copy link
Collaborator Author

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]
Copy link
Collaborator Author

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',
Copy link
Member

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 ?
Copy link
Member

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.

Copy link
Collaborator Author

@patrickhulce patrickhulce May 2, 2018

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

Copy link
Member

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.

Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

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?

Copy link
Collaborator Author

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
Copy link
Member

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?

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 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

Copy link
Member

@brendankenny brendankenny May 2, 2018

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...

Copy link
Collaborator Author

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 ?
Copy link
Member

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

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.

aside from the optionality thing, i'm lgtm on the rest.

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.

nits but LGTM!

Interactive.getLastLongTaskEndTime(simulationAfterChanges.nodeTimings),
0
);
const savingsOnLoad = options.includeLoad ?
Copy link
Member

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);
Copy link
Member

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;

?

Copy link
Collaborator Author

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
Copy link
Member

@brendankenny brendankenny May 2, 2018

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) {
Copy link
Member

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 :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@brendankenny brendankenny merged commit 27d4323 into master May 2, 2018
@brendankenny brendankenny deleted the lantern_opp_max_tti_load branch May 2, 2018 23:44
@paulirish paulirish mentioned this pull request May 3, 2018
82 tasks
kdzwinel pushed a commit to kdzwinel/lighthouse that referenced this pull request Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ByteEfficiency reports no savings in animated GIF->video cases
3 participants