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

Ignoring other extension assets in request compression audit #2733

Merged
merged 3 commits into from
Jul 25, 2017
Merged

Ignoring other extension assets in request compression audit #2733

merged 3 commits into from
Jul 25, 2017

Conversation

arturmiz
Copy link
Contributor

Fixes #2696

* @return {string}
*/
URL.getProtocol = function(url) {
return new URL(url).protocol;
Copy link
Member

Choose a reason for hiding this comment

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

generally we've only been adding these methods to this shim if it needs a built-in try/catch. Otherwise maybe just use new URL(url).protocol directly in uses-request-compression.js

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

thanks so much for tackling this!

@@ -40,8 +41,12 @@ class ResponsesAreCompressed extends ByteEfficiencyAudit {
static audit_(artifacts) {
const uncompressedResponses = artifacts.ResponseCompression;

function skipUnrelatedResponses(record) {
return URL.getProtocol(record.url) !== CHROME_EXTENSION_PROTOCOL;
Copy link
Collaborator

Choose a reason for hiding this comment

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

we recently discovered that calling new URL in a loop on the network records can be crazy slow due to data URIs (see #2701 for discussion), how about checking record.protocol/record.scheme or doing a simple url.startsWith if there's still some strong opinions about avoiding the network records

cc: @brendankenny

Copy link
Member

Choose a reason for hiding this comment

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

we recently discovered that calling new URL in a loop on the network records can be crazy slow due to data URIs

gah, oh yeah. I wonder if we can automate testing for audits that will run into this.

We could at least generate a network records fixture (or devtoolsLog now, I guess), that would make it easy to test an audit with many data URIs (and add it to a "writing an audit protips" section in CONTRIBUTING). With @paulirish's desire to individually annotate tests with timeouts, it would be a red flag if an individual test was taking more than two seconds to parse the test fixture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@patrickhulce That was my initial plan for that but then I discovered that url-shim and thought it may be better approach to put it in there :) As I recall there is only record.url no record.protocol so I'll go with record.url.startsWith

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah awesome :) you should have access to protocol if you end up moving it to the gatherer ;) #2733 (comment)

const results = [];
uncompressedResponses.forEach(record => {
uncompressedResponses.filter(skipUnrelatedResponses).forEach(record => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that I'm reading the audit I realize this actually just processes what's already been compressed over in the gatherer.

Let's filter it there instead so we don't waste cycles re-compressing something we don't care about. Sorry for the bad tip in the issue!

@@ -10,9 +10,9 @@ const ResponsesAreCompressedAudit =
require('../../../audits/byte-efficiency/uses-request-compression.js');
const assert = require('assert');

function generateResponse(filename, type, originalSize, gzipSize) {
function generateResponse(filename, type, originalSize, gzipSize, schema = 'http:') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can probably revert this change too now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I must have skipped that :)

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

awesome thanks again!!

@patrickhulce patrickhulce merged commit 428f637 into GoogleChrome:master Jul 25, 2017
@patrickhulce
Copy link
Collaborator

🎉 nice job @arturmiz!

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.

3 participants