lighthouse 12.0.0 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/run.js +5 -38
- package/cli/test/smokehouse/lighthouse-runners/bundle.js +1 -1
- package/cli/test/smokehouse/smokehouse.js +11 -1
- package/core/audits/accessibility/aria-allowed-role.js +7 -9
- package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +2 -2
- package/core/audits/byte-efficiency/byte-efficiency-audit.js +3 -3
- package/core/audits/byte-efficiency/offscreen-images.js +1 -1
- package/core/audits/byte-efficiency/render-blocking-resources.d.ts +3 -3
- package/core/audits/byte-efficiency/render-blocking-resources.js +10 -10
- package/core/audits/dobetterweb/uses-http2.d.ts +2 -2
- package/core/audits/dobetterweb/uses-http2.js +5 -5
- package/core/audits/long-tasks.d.ts +7 -6
- package/core/audits/long-tasks.js +5 -4
- package/core/audits/metrics/first-meaningful-paint.d.ts +1 -17
- package/core/audits/metrics/first-meaningful-paint.js +5 -47
- package/core/audits/metrics/interactive.d.ts +1 -1
- package/core/audits/metrics/interactive.js +1 -1
- package/core/audits/predictive-perf.js +0 -6
- package/core/audits/prioritize-lcp-image.d.ts +1 -1
- package/core/audits/prioritize-lcp-image.js +2 -2
- package/core/audits/redirects.js +2 -3
- package/core/audits/third-party-facades.js +1 -1
- package/core/audits/third-party-summary.js +1 -1
- package/core/audits/uses-rel-preconnect.js +2 -2
- package/core/audits/uses-rel-preload.js +9 -9
- package/core/computed/critical-request-chains.js +3 -3
- package/core/computed/document-urls.js +3 -2
- package/core/computed/load-simulator.d.ts +4 -4
- package/core/computed/load-simulator.js +3 -54
- package/core/computed/main-resource.js +3 -2
- package/core/computed/metrics/interactive.d.ts +6 -0
- package/core/computed/metrics/interactive.js +2 -2
- package/core/computed/metrics/lantern-first-contentful-paint.d.ts +4 -4
- package/core/computed/metrics/lantern-first-contentful-paint.js +3 -3
- package/core/computed/metrics/lantern-interactive.d.ts +4 -4
- package/core/computed/metrics/lantern-interactive.js +6 -6
- package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +4 -4
- package/core/computed/metrics/lantern-largest-contentful-paint.js +3 -3
- package/core/computed/metrics/lantern-max-potential-fid.d.ts +4 -4
- package/core/computed/metrics/lantern-max-potential-fid.js +3 -3
- package/core/computed/metrics/lantern-metric.d.ts +21 -2
- package/core/computed/metrics/lantern-metric.js +39 -4
- package/core/computed/metrics/lantern-speed-index.d.ts +4 -4
- package/core/computed/metrics/lantern-speed-index.js +4 -4
- package/core/computed/metrics/lantern-total-blocking-time.d.ts +4 -4
- package/core/computed/metrics/lantern-total-blocking-time.js +3 -3
- package/core/computed/metrics/timing-summary.js +0 -6
- package/core/computed/metrics/total-blocking-time.js +3 -1
- package/core/computed/navigation-insights.d.ts +2 -20
- package/core/computed/network-analysis.d.ts +0 -5
- package/core/computed/network-analysis.js +2 -42
- package/core/computed/page-dependency-graph.d.ts +5 -3
- package/core/computed/page-dependency-graph.js +17 -7
- package/core/computed/processed-navigation.d.ts +1 -1
- package/core/computed/tbt-impact-tasks.js +4 -2
- package/core/computed/trace-engine-result.d.ts +0 -11
- package/core/computed/trace-engine-result.js +5 -19
- package/core/config/constants.d.ts +28 -53
- package/core/config/constants.js +2 -43
- package/core/gather/driver/navigation.js +1 -1
- package/core/gather/driver/network-monitor.d.ts +2 -1
- package/core/gather/driver/network-monitor.js +4 -4
- package/core/gather/driver/target-manager.d.ts +1 -1
- package/core/gather/driver.d.ts +0 -12
- package/core/gather/driver.js +1 -26
- package/core/gather/gatherers/inspector-issues.js +1 -0
- package/core/gather/gatherers/root-causes.js +0 -1
- package/core/gather/session.d.ts +5 -3
- package/core/gather/session.js +22 -1
- package/core/lib/asset-saver.d.ts +13 -9
- package/core/lib/asset-saver.js +77 -30
- package/core/lib/bf-cache-strings.js +2 -2
- package/core/lib/lantern/{base-node.d.ts → BaseNode.d.ts} +7 -9
- package/core/lib/lantern/{base-node.js → BaseNode.js} +6 -6
- package/core/lib/lantern/BaseNode.test.js +385 -0
- package/core/lib/lantern/CpuNode.d.ts +43 -0
- package/core/lib/lantern/{cpu-node.js → CpuNode.js} +8 -9
- package/core/lib/lantern/{lantern-error.d.ts → LanternError.d.ts} +1 -1
- package/core/lib/lantern/{metric.d.ts → Metric.d.ts} +23 -25
- package/core/lib/lantern/{metric.js → Metric.js} +14 -16
- package/core/lib/lantern/{network-node.d.ts → NetworkNode.d.ts} +6 -7
- package/core/lib/lantern/{network-node.js → NetworkNode.js} +7 -9
- package/core/lib/lantern/PageDependencyGraph.d.ts +82 -0
- package/core/lib/lantern/{page-dependency-graph.js → PageDependencyGraph.js} +185 -50
- package/core/lib/lantern/PageDependencyGraph.test.js +654 -0
- package/core/{computed/metrics/tbt-utils.d.ts → lib/lantern/TBTUtils.d.ts} +1 -1
- package/core/lib/lantern/TBTUtils.test.d.ts +2 -0
- package/core/lib/lantern/TBTUtils.test.js +130 -0
- package/core/lib/lantern/TraceEngineComputationData.d.ts +25 -0
- package/core/lib/lantern/TraceEngineComputationData.js +466 -0
- package/core/lib/lantern/lantern.d.ts +19 -7
- package/core/lib/lantern/lantern.js +21 -1
- package/core/lib/lantern/metrics/{first-contentful-paint.d.ts → FirstContentfulPaint.d.ts} +11 -11
- package/core/lib/lantern/metrics/{first-contentful-paint.js → FirstContentfulPaint.js} +11 -13
- package/core/lib/lantern/metrics/FirstContentfulPaint.test.js +54 -0
- package/core/lib/lantern/metrics/Interactive.d.ts +20 -0
- package/core/lib/lantern/metrics/{interactive.js → Interactive.js} +23 -26
- package/core/lib/lantern/metrics/Interactive.test.js +56 -0
- package/core/lib/lantern/metrics/LargestContentfulPaint.d.ts +19 -0
- package/core/lib/lantern/metrics/{largest-contentful-paint.js → LargestContentfulPaint.js} +16 -19
- package/core/lib/lantern/metrics/LargestContentfulPaint.test.js +42 -0
- package/core/lib/lantern/metrics/MaxPotentialFID.d.ts +24 -0
- package/core/lib/lantern/metrics/{max-potential-fid.js → MaxPotentialFID.js} +12 -13
- package/core/lib/lantern/metrics/MetricTestUtils.d.ts +19 -0
- package/core/lib/lantern/metrics/MetricTestUtils.js +48 -0
- package/core/lib/lantern/metrics/{speed-index.d.ts → SpeedIndex.d.ts} +7 -13
- package/core/lib/lantern/metrics/{speed-index.js → SpeedIndex.js} +14 -16
- package/core/lib/lantern/metrics/SpeedIndex.test.js +83 -0
- package/core/lib/lantern/metrics/TotalBlockingTime.d.ts +25 -0
- package/core/lib/lantern/metrics/{total-blocking-time.js → TotalBlockingTime.js} +13 -16
- package/core/lib/lantern/metrics/__snapshots__/FirstContentfulPaint.test.js.snap +11 -0
- package/core/lib/lantern/metrics/__snapshots__/Interactive.test.js.snap +17 -0
- package/core/lib/lantern/metrics/metrics.d.ts +9 -0
- package/core/lib/lantern/metrics/metrics.js +16 -0
- package/core/lib/lantern/{simulator/connection-pool.d.ts → simulation/ConnectionPool.d.ts} +15 -15
- package/core/lib/lantern/{simulator/connection-pool.js → simulation/ConnectionPool.js} +25 -25
- package/core/lib/lantern/simulation/ConnectionPool.test.js +195 -0
- package/core/lib/lantern/simulation/Constants.d.ts +52 -0
- package/core/lib/lantern/simulation/Constants.js +48 -0
- package/core/lib/lantern/{simulator/dns-cache.d.ts → simulation/DNSCache.d.ts} +3 -3
- package/core/lib/lantern/{simulator/dns-cache.js → simulation/DNSCache.js} +2 -2
- package/core/lib/lantern/simulation/DNSCache.test.js +72 -0
- package/core/lib/lantern/{simulator/network-analyzer.d.ts → simulation/NetworkAnalyzer.d.ts} +34 -21
- package/core/lib/lantern/{simulator/network-analyzer.js → simulation/NetworkAnalyzer.js} +106 -57
- package/core/lib/lantern/simulation/NetworkAnalyzer.test.js +475 -0
- package/core/lib/lantern/{simulator/simulator-timing-map.d.ts → simulation/SimulationTimingMap.d.ts} +7 -7
- package/core/lib/lantern/{simulator/simulator-timing-map.js → simulation/SimulationTimingMap.js} +5 -6
- package/core/lib/lantern/{simulator/simulator.d.ts → simulation/Simulator.d.ts} +21 -19
- package/core/lib/lantern/{simulator/simulator.js → simulation/Simulator.js} +100 -45
- package/core/lib/lantern/simulation/Simulator.test.js +434 -0
- package/core/lib/lantern/simulation/TCPConnection.test.d.ts +2 -0
- package/core/lib/lantern/simulation/TCPConnection.test.js +374 -0
- package/core/lib/lantern/{simulator/tcp-connection.d.ts → simulation/TcpConnection.d.ts} +2 -2
- package/core/lib/lantern/{simulator/tcp-connection.js → simulation/TcpConnection.js} +1 -1
- package/core/lib/lantern/simulation/simulation.d.ts +21 -0
- package/core/lib/lantern/simulation/simulation.js +28 -0
- package/core/lib/lantern/types/lantern.d.ts +145 -20
- package/core/lib/lantern-trace-saver.d.ts +4 -4
- package/core/lib/lantern-trace-saver.js +4 -4
- package/core/lib/navigation-error.js +3 -3
- package/core/lib/network-recorder.js +2 -2
- package/core/lib/network-request.d.ts +29 -3
- package/core/lib/network-request.js +20 -13
- package/core/lib/tracehouse/trace-processor.d.ts +0 -2
- package/core/lib/tracehouse/trace-processor.js +1 -31
- package/core/lib/traces/metric-trace-events.js +0 -5
- package/dist/report/bundle.esm.js +1 -1
- package/dist/report/flow.js +1 -1
- package/dist/report/standalone.js +1 -1
- package/package.json +14 -13
- package/report/renderer/performance-category-renderer.js +1 -1
- package/shared/localization/locales/ar-XB.json +43 -4
- package/shared/localization/locales/ar.json +43 -4
- package/shared/localization/locales/bg.json +43 -4
- package/shared/localization/locales/ca.json +44 -5
- package/shared/localization/locales/cs.json +43 -4
- package/shared/localization/locales/da.json +43 -4
- package/shared/localization/locales/de.json +43 -4
- package/shared/localization/locales/el.json +43 -4
- package/shared/localization/locales/en-GB.json +42 -3
- package/shared/localization/locales/en-US.json +4 -4
- package/shared/localization/locales/en-XA.json +43 -4
- package/shared/localization/locales/en-XL.json +4 -4
- package/shared/localization/locales/es-419.json +43 -4
- package/shared/localization/locales/es.json +42 -3
- package/shared/localization/locales/fi.json +43 -4
- package/shared/localization/locales/fil.json +42 -3
- package/shared/localization/locales/fr.json +42 -3
- package/shared/localization/locales/he.json +48 -9
- package/shared/localization/locales/hi.json +43 -4
- package/shared/localization/locales/hr.json +43 -4
- package/shared/localization/locales/hu.json +42 -3
- package/shared/localization/locales/id.json +42 -3
- package/shared/localization/locales/it.json +43 -4
- package/shared/localization/locales/ja.json +42 -3
- package/shared/localization/locales/ko.json +43 -4
- package/shared/localization/locales/lt.json +42 -3
- package/shared/localization/locales/lv.json +43 -4
- package/shared/localization/locales/nl.json +44 -5
- package/shared/localization/locales/no.json +42 -3
- package/shared/localization/locales/pl.json +43 -4
- package/shared/localization/locales/pt-PT.json +43 -4
- package/shared/localization/locales/pt.json +43 -4
- package/shared/localization/locales/ro.json +43 -4
- package/shared/localization/locales/ru.json +43 -4
- package/shared/localization/locales/sk.json +43 -4
- package/shared/localization/locales/sl.json +42 -3
- package/shared/localization/locales/sr-Latn.json +43 -4
- package/shared/localization/locales/sr.json +43 -4
- package/shared/localization/locales/sv.json +42 -3
- package/shared/localization/locales/ta.json +42 -3
- package/shared/localization/locales/te.json +43 -4
- package/shared/localization/locales/th.json +44 -5
- package/shared/localization/locales/tr.json +43 -4
- package/shared/localization/locales/uk.json +43 -4
- package/shared/localization/locales/vi.json +43 -4
- package/shared/localization/locales/zh-HK.json +43 -4
- package/shared/localization/locales/zh-TW.json +43 -4
- package/shared/localization/locales/zh.json +43 -4
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +1 -0
- package/tsconfig-all.json +1 -0
- package/tsconfig.json +11 -7
- package/types/artifacts.d.ts +23 -25
- package/types/gatherer.d.ts +2 -3
- package/types/lhr/lhr.d.ts +2 -0
- package/core/computed/metrics/first-meaningful-paint.d.ts +0 -21
- package/core/computed/metrics/first-meaningful-paint.js +0 -44
- package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +0 -25
- package/core/computed/metrics/lantern-first-meaningful-paint.js +0 -43
- package/core/lib/lantern/cpu-node.d.ts +0 -44
- package/core/lib/lantern/metrics/first-meaningful-paint.d.ts +0 -6
- package/core/lib/lantern/metrics/first-meaningful-paint.js +0 -64
- package/core/lib/lantern/metrics/interactive.d.ts +0 -26
- package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +0 -19
- package/core/lib/lantern/metrics/max-potential-fid.d.ts +0 -30
- package/core/lib/lantern/metrics/total-blocking-time.d.ts +0 -31
- package/core/lib/lantern/page-dependency-graph.d.ts +0 -58
- /package/core/lib/lantern/{lantern-error.js → LanternError.js} +0 -0
- /package/core/{computed/metrics/tbt-utils.js → lib/lantern/TBTUtils.js} +0 -0
|
@@ -4,21 +4,20 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as Lantern from '../
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** @typedef {import('../
|
|
18
|
-
/** @typedef {import('../
|
|
19
|
-
/** @typedef {import('
|
|
20
|
-
/** @typedef {import('./
|
|
21
|
-
/** @typedef {import('./simulator-timing-map.js').ConnectionTiming} ConnectionTiming */
|
|
7
|
+
import * as Lantern from '../lantern.js';
|
|
8
|
+
import {TcpConnection} from './TcpConnection.js';
|
|
9
|
+
import {ConnectionPool} from './ConnectionPool.js';
|
|
10
|
+
import {DNSCache} from './DNSCache.js';
|
|
11
|
+
import {SimulatorTimingMap} from './SimulationTimingMap.js';
|
|
12
|
+
|
|
13
|
+
const Constants = Lantern.Simulation.Constants;
|
|
14
|
+
const defaultThrottling = Constants.throttling.mobileSlow4G;
|
|
15
|
+
|
|
16
|
+
/** @typedef {import('../BaseNode.js').Node} Node */
|
|
17
|
+
/** @typedef {import('../NetworkNode.js').NetworkNode} NetworkNode */
|
|
18
|
+
/** @typedef {import('../CpuNode.js').CPUNode} CpuNode */
|
|
19
|
+
/** @typedef {import('./SimulationTimingMap.js').CpuNodeTimingComplete | import('./SimulationTimingMap.js').NetworkNodeTimingComplete} CompleteNodeTiming */
|
|
20
|
+
/** @typedef {import('./SimulationTimingMap.js').ConnectionTiming} ConnectionTiming */
|
|
22
21
|
|
|
23
22
|
// see https://cs.chromium.org/search/?q=kDefaultMaxNumDelayableRequestsPerClient&sq=package:chromium&type=cs
|
|
24
23
|
const DEFAULT_MAXIMUM_CONCURRENT_REQUESTS = 10;
|
|
@@ -34,7 +33,7 @@ const NodeState = {
|
|
|
34
33
|
Complete: 3,
|
|
35
34
|
};
|
|
36
35
|
|
|
37
|
-
/** @type {Record<NetworkNode['
|
|
36
|
+
/** @type {Record<NetworkNode['request']['priority'], number>} */
|
|
38
37
|
const PriorityStartTimePenalty = {
|
|
39
38
|
VeryHigh: 0,
|
|
40
39
|
High: 0.25,
|
|
@@ -50,6 +49,62 @@ const ALL_SIMULATION_NODE_TIMINGS = new Map();
|
|
|
50
49
|
* @template [T=any]
|
|
51
50
|
*/
|
|
52
51
|
class Simulator {
|
|
52
|
+
/**
|
|
53
|
+
* @param {Lantern.Simulation.Settings} settings
|
|
54
|
+
*/
|
|
55
|
+
static createSimulator(settings) {
|
|
56
|
+
const {throttlingMethod, throttling, precomputedLanternData, networkAnalysis} = settings;
|
|
57
|
+
|
|
58
|
+
/** @type {Lantern.Simulation.Options} */
|
|
59
|
+
const options = {
|
|
60
|
+
additionalRttByOrigin: networkAnalysis.additionalRttByOrigin,
|
|
61
|
+
serverResponseTimeByOrigin: networkAnalysis.serverResponseTimeByOrigin,
|
|
62
|
+
observedThroughput: networkAnalysis.throughput,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// If we have precomputed lantern data, overwrite our observed estimates and use precomputed instead
|
|
66
|
+
// for increased stability.
|
|
67
|
+
if (precomputedLanternData) {
|
|
68
|
+
options.additionalRttByOrigin = new Map(Object.entries(
|
|
69
|
+
precomputedLanternData.additionalRttByOrigin));
|
|
70
|
+
options.serverResponseTimeByOrigin = new Map(Object.entries(
|
|
71
|
+
precomputedLanternData.serverResponseTimeByOrigin));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
switch (throttlingMethod) {
|
|
75
|
+
case 'provided':
|
|
76
|
+
options.rtt = networkAnalysis.rtt;
|
|
77
|
+
options.throughput = networkAnalysis.throughput;
|
|
78
|
+
options.cpuSlowdownMultiplier = 1;
|
|
79
|
+
options.layoutTaskMultiplier = 1;
|
|
80
|
+
break;
|
|
81
|
+
case 'devtools':
|
|
82
|
+
if (throttling) {
|
|
83
|
+
options.rtt =
|
|
84
|
+
throttling.requestLatencyMs / Constants.throttling.DEVTOOLS_RTT_ADJUSTMENT_FACTOR;
|
|
85
|
+
options.throughput =
|
|
86
|
+
throttling.downloadThroughputKbps * 1024 /
|
|
87
|
+
Constants.throttling.DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
options.cpuSlowdownMultiplier = 1;
|
|
91
|
+
options.layoutTaskMultiplier = 1;
|
|
92
|
+
break;
|
|
93
|
+
case 'simulate':
|
|
94
|
+
if (throttling) {
|
|
95
|
+
options.rtt = throttling.rttMs;
|
|
96
|
+
options.throughput = throttling.throughputKbps * 1024;
|
|
97
|
+
options.cpuSlowdownMultiplier = throttling.cpuSlowdownMultiplier;
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
// intentionally fallback to simulator defaults
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return new Simulator(options);
|
|
106
|
+
}
|
|
107
|
+
|
|
53
108
|
/**
|
|
54
109
|
* @param {Lantern.Simulation.Options} [options]
|
|
55
110
|
*/
|
|
@@ -57,10 +112,10 @@ class Simulator {
|
|
|
57
112
|
/** @type {Required<Lantern.Simulation.Options>} */
|
|
58
113
|
this._options = Object.assign(
|
|
59
114
|
{
|
|
60
|
-
rtt:
|
|
61
|
-
throughput:
|
|
115
|
+
rtt: defaultThrottling.rttMs,
|
|
116
|
+
throughput: defaultThrottling.throughputKbps * 1024,
|
|
62
117
|
maximumConcurrentRequests: DEFAULT_MAXIMUM_CONCURRENT_REQUESTS,
|
|
63
|
-
cpuSlowdownMultiplier:
|
|
118
|
+
cpuSlowdownMultiplier: defaultThrottling.cpuSlowdownMultiplier,
|
|
64
119
|
layoutTaskMultiplier: DEFAULT_LAYOUT_TASK_MULTIPLIER,
|
|
65
120
|
additionalRttByOrigin: new Map(),
|
|
66
121
|
serverResponseTimeByOrigin: new Map(),
|
|
@@ -106,7 +161,7 @@ class Simulator {
|
|
|
106
161
|
/** @type {Lantern.NetworkRequest[]} */
|
|
107
162
|
const records = [];
|
|
108
163
|
graph.getRootNode().traverse(node => {
|
|
109
|
-
if (node.type === BaseNode.TYPES.NETWORK) {
|
|
164
|
+
if (node.type === Lantern.BaseNode.TYPES.NETWORK) {
|
|
110
165
|
records.push(node.request);
|
|
111
166
|
}
|
|
112
167
|
});
|
|
@@ -192,11 +247,11 @@ class Simulator {
|
|
|
192
247
|
}
|
|
193
248
|
|
|
194
249
|
/**
|
|
195
|
-
* @param {Lantern.NetworkRequest}
|
|
250
|
+
* @param {Lantern.NetworkRequest} request
|
|
196
251
|
* @return {?TcpConnection}
|
|
197
252
|
*/
|
|
198
|
-
_acquireConnection(
|
|
199
|
-
return this._connectionPool.acquire(
|
|
253
|
+
_acquireConnection(request) {
|
|
254
|
+
return this._connectionPool.acquire(request);
|
|
200
255
|
}
|
|
201
256
|
|
|
202
257
|
/**
|
|
@@ -212,7 +267,7 @@ class Simulator {
|
|
|
212
267
|
* @param {number} totalElapsedTime
|
|
213
268
|
*/
|
|
214
269
|
_startNodeIfPossible(node, totalElapsedTime) {
|
|
215
|
-
if (node.type === BaseNode.TYPES.CPU) {
|
|
270
|
+
if (node.type === Lantern.BaseNode.TYPES.CPU) {
|
|
216
271
|
// Start a CPU task if there's no other CPU task in process
|
|
217
272
|
if (this._numberInProgress(node.type) === 0) {
|
|
218
273
|
this._markNodeAsInProgress(node, totalElapsedTime);
|
|
@@ -221,7 +276,7 @@ class Simulator {
|
|
|
221
276
|
return;
|
|
222
277
|
}
|
|
223
278
|
|
|
224
|
-
if (node.type !== BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
|
|
279
|
+
if (node.type !== Lantern.BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
|
|
225
280
|
|
|
226
281
|
// If a network request is connectionless, we can always start it, so skip the connection checks
|
|
227
282
|
if (!node.isConnectionless) {
|
|
@@ -240,7 +295,7 @@ class Simulator {
|
|
|
240
295
|
* currently in flight.
|
|
241
296
|
*/
|
|
242
297
|
_updateNetworkCapacity() {
|
|
243
|
-
const inFlight = this._numberInProgress(BaseNode.TYPES.NETWORK);
|
|
298
|
+
const inFlight = this._numberInProgress(Lantern.BaseNode.TYPES.NETWORK);
|
|
244
299
|
if (inFlight === 0) return;
|
|
245
300
|
|
|
246
301
|
for (const connection of this._connectionPool.connectionsInUse()) {
|
|
@@ -254,9 +309,9 @@ class Simulator {
|
|
|
254
309
|
* @return {number}
|
|
255
310
|
*/
|
|
256
311
|
_estimateTimeRemaining(node) {
|
|
257
|
-
if (node.type === BaseNode.TYPES.CPU) {
|
|
312
|
+
if (node.type === Lantern.BaseNode.TYPES.CPU) {
|
|
258
313
|
return this._estimateCPUTimeRemaining(node);
|
|
259
|
-
} else if (node.type === BaseNode.TYPES.NETWORK) {
|
|
314
|
+
} else if (node.type === Lantern.BaseNode.TYPES.NETWORK) {
|
|
260
315
|
return this._estimateNetworkTimeRemaining(node);
|
|
261
316
|
} else {
|
|
262
317
|
throw new Error('Unsupported');
|
|
@@ -286,7 +341,7 @@ class Simulator {
|
|
|
286
341
|
* @return {number}
|
|
287
342
|
*/
|
|
288
343
|
_estimateNetworkTimeRemaining(networkNode) {
|
|
289
|
-
const
|
|
344
|
+
const request = networkNode.request;
|
|
290
345
|
const timingData = this._nodeTimings.getNetworkStarted(networkNode);
|
|
291
346
|
|
|
292
347
|
let timeElapsed = 0;
|
|
@@ -294,23 +349,23 @@ class Simulator {
|
|
|
294
349
|
// Rough access time for seeking to location on disk and reading sequentially.
|
|
295
350
|
// 8ms per seek + 20ms/MB
|
|
296
351
|
// @see http://norvig.com/21-days.html#answers
|
|
297
|
-
const sizeInMb = (
|
|
352
|
+
const sizeInMb = (request.resourceSize || 0) / 1024 / 1024;
|
|
298
353
|
timeElapsed = 8 + 20 * sizeInMb - timingData.timeElapsed;
|
|
299
354
|
} else if (networkNode.isNonNetworkProtocol) {
|
|
300
355
|
// Estimates for the overhead of a data URL in Chromium and the decoding time for base64-encoded data.
|
|
301
356
|
// 2ms per request + 10ms/MB
|
|
302
357
|
// @see traces on https://dopiaza.org/tools/datauri/examples/index.php
|
|
303
|
-
const sizeInMb = (
|
|
358
|
+
const sizeInMb = (request.resourceSize || 0) / 1024 / 1024;
|
|
304
359
|
timeElapsed = 2 + 10 * sizeInMb - timingData.timeElapsed;
|
|
305
360
|
} else {
|
|
306
|
-
const connection = this._connectionPool.
|
|
307
|
-
const dnsResolutionTime = this._dns.getTimeUntilResolution(
|
|
361
|
+
const connection = this._connectionPool.acquireActiveConnectionFromRequest(request);
|
|
362
|
+
const dnsResolutionTime = this._dns.getTimeUntilResolution(request, {
|
|
308
363
|
requestedAt: timingData.startTime,
|
|
309
364
|
shouldUpdateCache: true,
|
|
310
365
|
});
|
|
311
366
|
const timeAlreadyElapsed = timingData.timeElapsed;
|
|
312
367
|
const calculation = connection.simulateDownloadUntil(
|
|
313
|
-
|
|
368
|
+
request.transferSize - timingData.bytesDownloaded,
|
|
314
369
|
{timeAlreadyElapsed, dnsResolutionTime, maximumTimeToElapse: Infinity}
|
|
315
370
|
);
|
|
316
371
|
|
|
@@ -345,23 +400,23 @@ class Simulator {
|
|
|
345
400
|
const timingData = this._nodeTimings.getInProgress(node);
|
|
346
401
|
const isFinished = timingData.estimatedTimeElapsed === timePeriodLength;
|
|
347
402
|
|
|
348
|
-
if (node.type === BaseNode.TYPES.CPU || node.isConnectionless) {
|
|
403
|
+
if (node.type === Lantern.BaseNode.TYPES.CPU || node.isConnectionless) {
|
|
349
404
|
return isFinished
|
|
350
405
|
? this._markNodeAsComplete(node, totalElapsedTime)
|
|
351
406
|
: (timingData.timeElapsed += timePeriodLength);
|
|
352
407
|
}
|
|
353
408
|
|
|
354
|
-
if (node.type !== BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
|
|
409
|
+
if (node.type !== Lantern.BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
|
|
355
410
|
if (!('bytesDownloaded' in timingData)) throw new Error('Invalid timing data');
|
|
356
411
|
|
|
357
|
-
const
|
|
358
|
-
const connection = this._connectionPool.
|
|
359
|
-
const dnsResolutionTime = this._dns.getTimeUntilResolution(
|
|
412
|
+
const request = node.request;
|
|
413
|
+
const connection = this._connectionPool.acquireActiveConnectionFromRequest(request);
|
|
414
|
+
const dnsResolutionTime = this._dns.getTimeUntilResolution(request, {
|
|
360
415
|
requestedAt: timingData.startTime,
|
|
361
416
|
shouldUpdateCache: true,
|
|
362
417
|
});
|
|
363
418
|
const calculation = connection.simulateDownloadUntil(
|
|
364
|
-
|
|
419
|
+
request.transferSize - timingData.bytesDownloaded,
|
|
365
420
|
{
|
|
366
421
|
dnsResolutionTime,
|
|
367
422
|
timeAlreadyElapsed: timingData.timeElapsed,
|
|
@@ -374,7 +429,7 @@ class Simulator {
|
|
|
374
429
|
|
|
375
430
|
if (isFinished) {
|
|
376
431
|
connection.setWarmed(true);
|
|
377
|
-
this._connectionPool.release(
|
|
432
|
+
this._connectionPool.release(request);
|
|
378
433
|
this._markNodeAsComplete(node, totalElapsedTime, calculation.connectionTiming);
|
|
379
434
|
} else {
|
|
380
435
|
timingData.timeElapsed += calculation.timeElapsed;
|
|
@@ -424,7 +479,7 @@ class Simulator {
|
|
|
424
479
|
*
|
|
425
480
|
* Simulator/connection pool are allowed to deviate from what was
|
|
426
481
|
* observed in the trace/devtoolsLog and start requests as soon as they are queued (i.e. do not
|
|
427
|
-
* wait around for a warm connection to be available if the original
|
|
482
|
+
* wait around for a warm connection to be available if the original request was fetched on a warm
|
|
428
483
|
* connection).
|
|
429
484
|
*
|
|
430
485
|
* @param {Node} graph
|
|
@@ -432,7 +487,7 @@ class Simulator {
|
|
|
432
487
|
* @return {Lantern.Simulation.Result<T>}
|
|
433
488
|
*/
|
|
434
489
|
simulate(graph, options) {
|
|
435
|
-
if (BaseNode.hasCycle(graph)) {
|
|
490
|
+
if (Lantern.BaseNode.hasCycle(graph)) {
|
|
436
491
|
throw new Error('Cannot simulate graph with cycle');
|
|
437
492
|
}
|
|
438
493
|
|
|
@@ -477,7 +532,7 @@ class Simulator {
|
|
|
477
532
|
const minimumTime = this._findNextNodeCompletionTime();
|
|
478
533
|
totalElapsedTime += minimumTime;
|
|
479
534
|
|
|
480
|
-
// While this is no longer strictly necessary, it's always better than
|
|
535
|
+
// While this is no longer strictly necessary, it's always better than hanging
|
|
481
536
|
if (!Number.isFinite(minimumTime) || iteration > 100000) {
|
|
482
537
|
throw new Error('Simulation failed, depth exceeded');
|
|
483
538
|
}
|
|
@@ -524,7 +579,7 @@ class Simulator {
|
|
|
524
579
|
}
|
|
525
580
|
|
|
526
581
|
/**
|
|
527
|
-
* We attempt to start nodes by their observed start time using the
|
|
582
|
+
* We attempt to start nodes by their observed start time using the request priority as a tie breaker.
|
|
528
583
|
* When simulating, just because a low priority image started 5ms before a high priority image doesn't mean
|
|
529
584
|
* it would have happened like that when the network was slower.
|
|
530
585
|
* @param {Node} node
|