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(byte-efficiency): compute FCP & LCP savings #15104

Merged
merged 21 commits into from
Jul 5, 2023

Conversation

adamraine
Copy link
Member

@adamraine adamraine commented May 23, 2023

First pass at computing FCP / LCP graph savings for byte efficiency audits. To gauge these estimates, I did a DT throttling run on cnn.com:

https://googlechrome.github.io/lighthouse/viewer/?gist=3101939dec6e6aa3c54ef73af500b86a
https://trace.cafe/t/QxCTNKUbin

offscreen-images { FCP: 0, LCP: 0 }
unminified-css { FCP: 0, LCP: 0 }
unminified-javascript { FCP: 0, LCP: 0 }
unused-css-rules { FCP: 0, LCP: 0 }
unused-javascript { FCP: 480, LCP: 2470 }
modern-image-formats { FCP: 0, LCP: 0 }
uses-optimized-images { FCP: 0, LCP: 0 }
uses-text-compression { FCP: 0, LCP: 0 }
uses-responsive-images { FCP: 0, LCP: 490 }
efficient-animated-content { FCP: 0, LCP: 0 }
duplicated-javascript { FCP: 0, LCP: 0 }
legacy-javascript { FCP: 0, LCP: 0 }

My initial read:

  • unused-javascript FCP/LCP estimates seem appropriate. All of the pre-FCP downloads and many of the pre-LCP downloads are JS.
  • uses-responsive-images and modern-image-formats are underestimating the impact on LCP
    • The LCP image resource is listed with potential savings in both audits
    • The LCP load time is 46% of LCP (5,180 ms)
    • Potential solution: When the LCP resource is listed in a BE audit, use the estimated savings of the LCP resource network node as a minimum value for the overall LCP savings.

@Alanesa Alanesa mentioned this pull request May 23, 2023
@adamraine
Copy link
Member Author

adamraine commented May 23, 2023

Run on cnn.com w/ simulated throttling. CNN changes content a lot so this isn't a mirror image of the analysis above.

https://googlechrome.github.io/lighthouse/viewer/?gist=7e431eebd16bc37944e9b1ceaff80c3b
https://trace.cafe/t/GKby7xbdFx

Using pessemistic graph

offscreen-images { FCP: 0, LCP: 1340 }
unminified-css { FCP: 0, LCP: 0 }
unminified-javascript { FCP: 0, LCP: 300 }
unused-css-rules { FCP: 0, LCP: 150 }
unused-javascript { FCP: 1200, LCP: 11250 }
modern-image-formats { FCP: 0, LCP: 1550 }
uses-optimized-images { FCP: 0, LCP: 0 }
uses-text-compression { FCP: 0, LCP: 150 }
uses-responsive-images { FCP: 0, LCP: 2000 }
efficient-animated-content { FCP: 0, LCP: 0 }
duplicated-javascript { FCP: 0, LCP: 160 }
legacy-javascript { FCP: 150, LCP: 150 }

Using optimistic graph:

offscreen-images { FCP: 0, LCP: 150 }
unminified-css { FCP: 0, LCP: 0 }
unminified-javascript { FCP: 0, LCP: 300 }
unused-css-rules { FCP: 0, LCP: 0 }
unused-javascript { FCP: 1350, LCP: 10650 }
modern-image-formats { FCP: 0, LCP: 150 }
uses-optimized-images { FCP: 0, LCP: 0 }
uses-text-compression { FCP: 0, LCP: 0 }
uses-responsive-images { FCP: 0, LCP: 150 }
efficient-animated-content { FCP: 0, LCP: 0 }
duplicated-javascript { FCP: 0, LCP: 130 }
legacy-javascript { FCP: 150, LCP: 0 }

Notes:

  • Most outrageous part is our estimated 50s LCP. I don't think the LCP would realistically be this big because it happened to be an image in an add that was displayed well into the page load.
  • LCP resource is listed in modern-image-formats, but the LCP load time was only 590ms. Unsure if this detail makes a difference for these estimates.
  • Using the pessimistic graph seems fine so far, but we do use the optimistic graph when doing a similar calculation in render blocking resources.

@adamraine adamraine changed the title WIP: compute FCP & LCP savings for byte efficiency audits core(byte-efficiency): compute FCP & LCP savings Jun 9, 2023
@adamraine adamraine marked this pull request as ready for review June 9, 2023 22:44
@adamraine adamraine requested a review from a team as a code owner June 9, 2023 22:44
@adamraine adamraine requested review from connorjclark and removed request for a team June 9, 2023 22:44
if (lcpRecord && lcpBreakdown.loadStart && lcpBreakdown.loadEnd) {
const lcpResult = results.find(result => result.url === lcpRecord.url);
if (lcpResult) {
const lcpLoadTime = lcpBreakdown.loadEnd - lcpBreakdown.loadStart;
Copy link
Member

Choose a reason for hiding this comment

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

the benefit is only to download time.. but this loadTime duration includes ttfb time

tbh looking at your original results I'd say that the image audits were not underestimating LCP savings

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean "includes ttfb time"? lcpLoadTime is supposed to represent the "Resource load time" phase of LCP so it's just the download time.

Copy link
Member Author

Choose a reason for hiding this comment

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

tbh looking at your original results I'd say that the image audits were not underestimating LCP savings

In the first set of results, modern-image-formats reports 0 savings on LCP when calculated using the LCP graph even though the LCP image is listed in that audit. This is definitely an underestimate IMO.

{providedWastedBytesByUrl: result.wastedBytesByUrl, label: 'lcp'}
);

// The LCP graph can underestimate the LCP savings if there is potential savings on the LCP record itself.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm having trouble understanding this. How is this the case? If the LCP node download time is reduced, why isn't the simulation taking that into account when returning LCP savings?

Copy link
Member Author

Choose a reason for hiding this comment

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

Graph timings are computed using the end time of the entire graph, the LCP request node is not necessarily the final node in the graph. Presumably, it's possible for the node that marks the end of the entire graph to have it's timing unaffected by changes to the LCP request node.

Copy link
Collaborator

@connorjclark connorjclark Jun 15, 2023

Choose a reason for hiding this comment

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

Can you provide a breakdown for a specific example where this is the case? I'd expect there to be some dependency between the final node (is it the CPU node that has the layout?) and the network request node whose bytes are being reduced.

Copy link
Member Author

Choose a reason for hiding this comment

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

The case in the PR comment is an example of this happening. LCP image is listed modern-image-formats but the LCP graph savings are 0. I did not save any artifacts other than the trace, so I'll try and get another example of such a case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Here is an example I captured with DT throttling. modern-image-formats shows the LCP record savings as larger than the LCP graph savings:

artifacts.json.zip
traceAndDtLog.zip
(had to split it up because it was too big for GH)

@adamraine adamraine merged commit 3b0950c into main Jul 5, 2023
@adamraine adamraine deleted the byte-efficiency-savings branch July 5, 2023 23:06
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