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

clients(lr): gather network timing numbers from headers #7888

Merged
merged 23 commits into from
Apr 8, 2019

Conversation

exterkamp
Copy link
Member

Summary
Add network request timing data from lightrider headers like FetchedSize. Add network-request tests.

lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
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.

exciting stuff! :D

lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved

this.timing.connectStart = 0;
this.timing.connectEnd = TCPTime;
this.timing.sslStart = TCPTime - SSLTime;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we check these assumptions too, not just total 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.

Hm, would we check that SSLTime !> TCPTime, thus making SSLStart negative? We can.

lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
Co-Authored-By: exterkamp <shaneexterkamp5@gmail.com>
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

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.

one issue is that you won't have any particular debugging/logging signal if any of those bail points are hit, just that the lrStatistics in the audit won't be set, right?

lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
@@ -223,6 +242,7 @@ module.exports = class NetworkRequest {

this._updateResponseReceivedTimeIfNecessary();
this._updateTransferSizeForLightrider();
this._updateTimingsForLightrider();
Copy link
Member

Choose a reason for hiding this comment

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

can we combine these two into one call (even if it then calls the two functions) so the control flow is clear. this._fixLightriderWithHeaders or whatever

Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the benefit of combining them here?

I actually like that it's explicitly calling out what will be touched and for what reason

Copy link
Member

Choose a reason for hiding this comment

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

what's the benefit of combining them here?

they're always called together, so making them rooted in a single call means it's not possible to separate them accidentally, and to keep this isolated, a clear branching point where some of the numbers from earlier are replaced by values from the headers.

I think it's totally fine to keep them as separate functions (called from that single function) with descriptive names.

Copy link
Member

Choose a reason for hiding this comment

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

I was also thinking we could add new method called _finalizeRequestDetails (or _finalizeRequestDetailsOnLoadingComplete) which onLoadingFailed and onLoadingFinished both call.

But i agree with keeping these two LR methods separate.

Copy link
Member

Choose a reason for hiding this comment

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

I was also thinking we could add new method called _finalizeRequestDetails

heaven forfend that we keep platform-specific workarounds grouped by platform, but this would at least be an improvement

lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
brendankenny and others added 3 commits April 4, 2019 10:03
Lets get more authors on this to confuse Googlebot.

Co-Authored-By: exterkamp <shaneexterkamp5@gmail.com>
@exterkamp exterkamp changed the title [WIP] core: add network request advanced timings core: gather advanced LR timing statistics Apr 4, 2019
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
@@ -223,6 +242,7 @@ module.exports = class NetworkRequest {

this._updateResponseReceivedTimeIfNecessary();
this._updateTransferSizeForLightrider();
this._updateTimingsForLightrider();
Copy link
Member

Choose a reason for hiding this comment

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

I was also thinking we could add new method called _finalizeRequestDetails

heaven forfend that we keep platform-specific workarounds grouped by platform, but this would at least be an improvement

lighthouse-core/audits/network-requests.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/test/lib/network-request-test.js Outdated Show resolved Hide resolved
global.isLightrider = false;

assert.equal(req.transferSize, 100);
req._updateTransferSizeForLightrider();
Copy link
Member

Choose a reason for hiding this comment

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

ideally we shouldn't be testing the internal implementation.

How do you feel about using network-records-to-devtools-log.js? It already supports headers, so should be pretty easy to change this code over to using that. It would create the devtools log from a minimal example network record with X-* response headers, run the log through NetworkRecorder.recordsFromLogs, and then assert on the record that comes out.

Copy link
Member

Choose a reason for hiding this comment

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

the change really should be pretty trivial. I can add it if you want, so we can get this in faster

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah can you get that. I'm not 100% on what it entails.

lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/test/lib/network-request-test.js Outdated Show resolved Hide resolved
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.

I think maybe the meat got removed because of the breaking changes comment? even without it, I think there are a few things to fix before landing, so IMO 4.3.0 should proceed without it

lighthouse-core/lib/network-request.js Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Show resolved Hide resolved
lighthouse-core/test/lib/network-request-test.js Outdated Show resolved Hide resolved
assert.equal(req.responseReceivedTime, 1);
});

it('does nothing if timing is not initialized', function() {
Copy link
Member

Choose a reason for hiding this comment

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

seems like this test doesn't do anything since the headers aren't set?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, it is confirming that the header timing isn't changed if no header is set. Like if we made a change that always messed this up and set the value no matter what the header said it would break this b/c we shouldn't be messing with the timing w/o a header.

lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/lib/network-request.js Outdated Show resolved Hide resolved
lighthouse-core/test/lib/network-request-test.js Outdated Show resolved Hide resolved
global.isLightrider = false;

assert.equal(req.transferSize, 100);
req._updateTransferSizeForLightrider();
Copy link
Member

Choose a reason for hiding this comment

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

the change really should be pretty trivial. I can add it if you want, so we can get this in faster

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.

my concerns are resolved

Co-Authored-By: exterkamp <shaneexterkamp5@gmail.com>
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.

my concerns are resolved too, excited for the followup that gives this teeth :)

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.

⏱ 📈 📜

@brendankenny brendankenny merged commit aca78af into master Apr 8, 2019
@brendankenny brendankenny deleted the lr-timings branch April 8, 2019 23:08
@brendankenny brendankenny changed the title core: gather advanced LR timing statistics clients(lr): gather network timing numbers from headers Apr 8, 2019
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.

None yet

6 participants