From d0233f5cb39c25fe0327631d7764c9ef97726938 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Wed, 24 May 2023 10:41:27 -0700 Subject: [PATCH] core(network-analyzer): fix num of roundtrips for h3 estimates (#15102) --- core/computed/metrics/time-to-first-byte.js | 3 ++- core/lib/dependency-graph/simulator/network-analyzer.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/computed/metrics/time-to-first-byte.js b/core/computed/metrics/time-to-first-byte.js index f42c06d0c50e..74ac7ff5b172 100644 --- a/core/computed/metrics/time-to-first-byte.js +++ b/core/computed/metrics/time-to-first-byte.js @@ -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; diff --git a/core/lib/dependency-graph/simulator/network-analyzer.js b/core/lib/dependency-graph/simulator/network-analyzer.js index 949e513986bd..d0c2f273f5d9 100644 --- a/core/lib/dependency-graph/simulator/network-analyzer.js +++ b/core/lib/dependency-graph/simulator/network-analyzer.js @@ -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; }); @@ -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