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

misc: document where network timings come from #14227

Merged
merged 11 commits into from
Aug 20, 2022
43 changes: 43 additions & 0 deletions core/lib/network-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,48 @@
* @fileoverview Fills most of the role of NetworkManager and NetworkRequest classes from DevTools.
* @see https://cs.chromium.org/chromium/src/third_party/blink/renderer/devtools/front_end/sdk/NetworkRequest.js
* @see https://cs.chromium.org/chromium/src/third_party/blink/renderer/devtools/front_end/sdk/NetworkManager.js

A detailed overview of the Chromium networking layer can be found here:
https://github.com/raw/GoogleChrome/lighthouse/master/docs/Network-Timing.svg

Below is a simplified model.

DevTools box-whisker

|-------[xxxxxXXXXXX]-|
(1) (2) (3) (4)

(1) leading whisker

Covers various stages:

- Queuing (delta between renderer knowing about request and network manager knowing about it)
- DNS
- Connection setup cost (TCP, TLS, SSL, etc.)

CDP: left whisker edge is Network.requestWillBeSent timestamp

(2) light shaded region

browser network manager has initiated the request, hasn't recieved any bytes back yet
Note: even with early-hint response, only the "real" response is considered here

CDP: Network.requestWillBeSentExtraInfo timing.requestTime + timing.sendStart

(3) dark shaded region

browser network manager has recieved the very first header byte

CDP: Network.requestWillBeSentExtraInfo timing.requestTime + timing.recievedHeadersEnd
CDP: (right edge of box) Network.finished/Network.failed timestamp
Trace: ResourceFinish.finishedTime

(4) trailing whisker

Marks time when render process main thread is available to use the resource. Could be long
if main thread is busy. Currently don't use this anywhere.

Trace: ResourceFinish.ts
*/

import URL from './url-shim.js';
Expand Down Expand Up @@ -322,6 +364,7 @@ class NetworkRequest {
if (timing.requestTime === 0 || timing.receiveHeadersEnd === -1) return;
// Take startTime and responseReceivedTime from timing data for better accuracy.
// Timing's requestTime is a baseline in seconds, rest of the numbers there are ticks in millis.
// TODO: This skips the "queuing time" before the netstack has taken over ... is this a mistake?
this.startTime = timing.requestTime;
const headersReceivedTime = timing.requestTime + timing.receiveHeadersEnd / 1000;
if (!this.responseReceivedTime || this.responseReceivedTime < 0) {
Expand Down
1 change: 1 addition & 0 deletions docs/Network-Timings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.