Skip to content

Commit

Permalink
core(network-analyzer): fix num of roundtrips for h3 estimates (#15102)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed May 24, 2023
1 parent e06430b commit d0233f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/computed/metrics/time-to-first-byte.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class TimeToFirstByte extends NavigationMetric {

// Estimate when the connection is not warm.
// TTFB = DNS + (SSL)? + TCP handshake + 1 RT for request + server response time
let roundTrips = 3;
let roundTrips = 2;
if (!mainResource.protocol.startsWith('h3')) roundTrips += 1; // TCP
if (mainResource.parsedURL.scheme === 'https') roundTrips += 1;
const estimatedTTFB = data.settings.throttling.rttMs * roundTrips + observedResponseTime;

Expand Down
5 changes: 3 additions & 2 deletions core/lib/dependency-graph/simulator/network-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ class NetworkAnalyzer {

// Assume everything before sendStart was just DNS + (SSL)? + TCP handshake
// 1 RT for DNS, 1 RT (maybe) for SSL, 1 RT for TCP
let roundTrips = 2;
let roundTrips = 1;
if (!record.protocol.startsWith('h3')) roundTrips += 1; // TCP
if (record.parsedURL.scheme === 'https') roundTrips += 1;
return timing.sendStart / roundTrips;
});
Expand Down Expand Up @@ -227,8 +228,8 @@ class NetworkAnalyzer {
// TTFB = DNS + (SSL)? + TCP handshake + 1 RT for request + server response time
if (!connectionReused) {
roundTrips += 1; // DNS
if (!record.protocol.startsWith('h3')) roundTrips += 1; // TCP
if (record.parsedURL.scheme === 'https') roundTrips += 1; // SSL
roundTrips += 1; // TCP handshake
}

// subtract out our estimated server response time
Expand Down

0 comments on commit d0233f5

Please sign in to comment.