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

perf: consolidate DBW pass into defaultPass #2160

Merged
merged 8 commits into from
May 10, 2017
Merged

Conversation

patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented May 5, 2017

in the name of Operation Yaquina Bay (#2146), closes #1737

shaves off ~40s on heavy sites like cnn.com (latest run when combined with other changes for me now completes in <1 minute 🎉 )

Changes:

  • Converts event-listeners, document.write, and permission requests on load to use the violation entries coming from the protocol instead of bespoke in-page execution
  • Deletes the corresponding gatherers associated with them
  • Moves all remaining audits into the performance pass since they all have afterPass entries only
  • Deletes no-console-time and no-datenow since they monkeypatch functions with capture callsites
  • Convert tags-blocking-first-paint's beforePass false positive detection into other checks using isLinkPreload flag and ensuring that the request actually finished before FCP.

Caveats:

  • Violations don't seem to be coming through for mutation event listeners yet, will follow up with @pavelfeldman
  • Fancier stuff that got removed could potentially be enabled during the perf pass depending on how heavy the callsite capturing is, but further testing is needed
  • smoke tests already pass, but unit tests will need to be updated if this gets cursory 👍 :)

@paulirish paulirish mentioned this pull request May 5, 2017
40 tasks
@paulirish paulirish added the OYB label May 5, 2017
@patrickhulce
Copy link
Collaborator Author

bueller...bueller...

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.

I went through the gatherers added to defaultPass and verified they only run in afterPass and audited their driver usage.

The speed improvement is real and I'm excited to see this happen. 👍

* @param {!RegExp} pattern
* @return {!Array}
*/
static getViolationResults(artifacts, pattern) {
Copy link
Member

Choose a reason for hiding this comment

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

technically this should be in a violation-audit.js file that others subclass, right?

kind of an abuse to put in on the general audit file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure

@@ -118,18 +118,16 @@ class EventListeners extends Gatherer {
})).then(nestedListeners => [].concat(...nestedListeners));
}

beforePass(options) {
Copy link
Member

Choose a reason for hiding this comment

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

this change fixes the 2nd half of #2163

and doing it this way means we don't need pavel's CL

\o/

patrick, you should followup with pavel separately if you'd rather migrate to violations vs this approach. but this can be post-IO

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have no strong opinions, are the mutation listeners bad enough that we should put them in everyone's console or just check for in LH? basically, is there a legitimate reason to still use them?

Copy link
Member

Choose a reason for hiding this comment

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

basically, is there a legitimate reason to still use them?

no. you can use mutation observers. but the events are from a dark time.
only really shitty legacy code should be using them. i hope.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

alright cool then violation sgtm

this._parsedScripts = new Map();
return Promise.resolve()
.then(() => this.listenForScriptParsedEvents())
.then(() => this.unlistenForScriptParsedEvents())
.then(_ => options.driver.querySelectorAll('body, body /deep/ *')) // drill into shadow trees
Copy link
Member

Choose a reason for hiding this comment

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

if you want to fix the 1st half of #2163
we're awfully close to it right now.

i'm also fine with it coming in separately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

+1 to separate there's already a lot going on here

@@ -104,6 +86,7 @@ function filteredAndIndexedByUrl(networkRecords) {
// Include 404 scripts/links generated by the parser because they are likely blocking.
if (isHtml || isParserScriptOrStyle || (isFailedRequest && isParserGenerated)) {
prev[record._url] = {
isLinkPreload: record.isLinkPreload,
Copy link
Member

Choose a reason for hiding this comment

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

this is a little new.

CL: https://codereview.chromium.org/2751023005
cr rev: 460094

it's not yet in stable chrome (58), but its in 59.

how do you want to handle stable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMO it's not the end of the world to have it fire false positives for a while since there's now a mitigation that won't fire if it didn't actually occur before the paint

Copy link
Member

Choose a reason for hiding this comment

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

k. sgtm

@@ -121,8 +109,6 @@ module.exports = {
"dobetterweb/external-anchors-use-rel-noopener",
"dobetterweb/geolocation-on-start",
"dobetterweb/link-blocking-first-paint",
"dobetterweb/no-console-time",
"dobetterweb/no-datenow",
"dobetterweb/no-document-write",
"dobetterweb/no-mutation-events",
Copy link
Member

Choose a reason for hiding this comment

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

im seeing this:
image

related to your change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

probably, we won't be getting the same level of detail now that we aren't listening the entire time. strange that it shows up when there are no entries though...

"gatherers": [
"chrome-console-messages",
// "styles",
// "css-usage",
Copy link
Member

Choose a reason for hiding this comment

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

lets keep the commented out css-usage? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ha, alright, it's more dangerous now though since uncommenting could really mess up everything in the perf pass

"dobetterweb/anchors-with-no-rel-noopener",
"dobetterweb/appcache",
"dobetterweb/domstats",
"dobetterweb/optimized-images",
Copy link
Member

Choose a reason for hiding this comment

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

in this gatherer, we flip Network domain on and off.

i'm not sure why though. I suppose its for the 'Network.getResponseBody' we do. there's a chance this method will work without network being enabled. lets doublecheck that? looking at response-compression.js, it appears to get response bodies while network is disabled:

image

(also driver.getRequestContent exists now which it should probably use?)

it could be a problem because we may allow more network events into the devtoolsLog than what we intended. but yeah... if we dont need to enable/disable in there then let's remove.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we don't need network here anymore after #2154

Copy link
Member

Choose a reason for hiding this comment

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

sg. do you want to remove the network.enable/disable stuff in that gatherer now, then?

}
}
},
// 'no-mutation-events': {
Copy link
Member

Choose a reason for hiding this comment

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

add a comment about why its excluded right now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

doesn't need to be anymore I removed

};
}

/**
* @param {!Artifacts} artifacts
* @param {string} tagFilter The tagName to filter on
* @param {number=} endedBefore The trace milisecond timestamp that offending tags must have ended
* before (typically first contentful paint).
* @param {number=} loadThreshold Filter to resources that took at least this
Copy link
Member

Choose a reason for hiding this comment

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

loadDurationThreshold

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

};
}

/**
* @param {!Artifacts} artifacts
* @param {string} tagFilter The tagName to filter on
* @param {number=} endedBefore The trace milisecond timestamp that offending tags must have ended
Copy link
Member

Choose a reason for hiding this comment

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

endTimeMax

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

Copy link
Member

Choose a reason for hiding this comment

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

need a push?

@paulirish paulirish merged commit d99778b into master May 10, 2017
@paulirish paulirish deleted the consolidate_dbw_pass branch May 10, 2017 00:24
/**
* @license
* Copyright 2016 Google Inc. All rights reserved.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

why were these audits removed!?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ebidel

They were the only audits left that had perf impact and would need their own pass. Somewhere there was also a thread with @brendankenny on the dangers of letting these run during the perf pass which is also why I recommended not enabling them until we proved they had minimal impact.

From the PR description:

Deletes no-console-time and no-datenow since they monkeypatch functions with capture callsites
Fancier stuff that got removed could potentially be enabled during the perf pass depending on how heavy the callsite capturing is, but further testing is needed

@ebidel
Copy link
Contributor

ebidel commented May 30, 2017 via email

@patrickhulce
Copy link
Collaborator Author

Right but can't we keep the code around for people to run themselves?

Oh sure I have no qualms with that 👍 I'll defer to @brendankenny who expressed disgruntlement at the time when I wanted to keep code around for unused audits :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate discouraged API use audits to protocol-based violation report
3 participants