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

Gatherer for critical request chains #300

Closed
wants to merge 15 commits into from

Conversation

deepanjanroy
Copy link
Contributor

@deepanjanroy deepanjanroy commented May 7, 2016

Edit (may 11, paulirish): This is PR is mostly superseded by #310, but it's being retained for the moment to confirm that we have matching data on both sides.


Progress on #292

We're using the clovis network dependency graph. The new gatherer is hidden behind --use-net-dep-graph flag, so the extension still builds and runs fine.

Example execution: lighthouse http://theverge.com --use-net-dep-graph. Since we do not yet have an auditor or anything to consume the gather data, chains with at least two requests are logged to console so you can see the results.

The gatherer returns all critical requests chains, and all the requests in a critical request chain has to be critical (as opposed to only the beginning and end of the chain.) As a quick example, this request pattern:

      B --- C
A --/
      \ D --- E ---F

A, B, C, D, F: Critical
E: Non-critical

will return [A, B, C] and [A, D] as critical chains.

const log = require('../lib/log.js');

const flatten = arr => arr.reduce((a, b) => a.concat(b), []);
const contains = (arr, elm) => arr.indexOf(elm) > -1;
Copy link
Member

Choose a reason for hiding this comment

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

arr.includes(elm)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doesn't work in node :(

Copy link
Contributor

Choose a reason for hiding this comment

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

It's in 6.1.0, it would appear. I guess at this point since most people are bypassing 5 for 6 we could specify it as a minimum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It works on 6.0 too. Once we drop support for node 5.0 we can change this.

Copy link
Member

Choose a reason for hiding this comment

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

I'm +1 on supporting 5.

Copy link
Member

Choose a reason for hiding this comment

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

just FYI for the future: v8 syntax changes only ever happen in the major node version bumps.

As much as I want destructuring and rest parameters, I'd also like to hold off on requiring 6 for a bit longer.

@paullewis
Copy link
Contributor

One minor nit / query but LGTM otherwise. Terrific work as usual.

@paullewis paullewis added the +1 label May 9, 2016

class CriticalNetworkChains extends Gather {

get criticalPriorities() {
Copy link
Member

@paulirish paulirish May 9, 2016

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@paulirish
Copy link
Member

@deepanjanroy a few sites that should have decent chains:

imore.com
cnet.com
sfgate.com

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