@paulirish/trace_engine 0.0.64 → 0.0.66

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.
Files changed (434) hide show
  1. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  2. package/core/platform/ArrayUtilities.d.ts +5 -0
  3. package/core/platform/ArrayUtilities.js +14 -0
  4. package/core/platform/ArrayUtilities.js.map +1 -1
  5. package/core/platform/HostRuntime.d.ts +1 -0
  6. package/core/platform/HostRuntime.js +1 -1
  7. package/core/platform/HostRuntime.js.map +1 -1
  8. package/core/platform/KeyboardUtilities.js +12 -0
  9. package/core/platform/KeyboardUtilities.js.map +1 -1
  10. package/core/platform/MimeType.js +13 -0
  11. package/core/platform/MimeType.js.map +1 -1
  12. package/core/platform/Size.d.ts +12 -0
  13. package/core/platform/Size.js +36 -0
  14. package/core/platform/Size.js.map +1 -0
  15. package/core/platform/StringUtilities.d.ts +50 -0
  16. package/core/platform/StringUtilities.js +145 -4
  17. package/core/platform/StringUtilities.js.map +1 -1
  18. package/core/platform/TypescriptUtilities.d.ts +0 -6
  19. package/core/platform/TypescriptUtilities.js +0 -8
  20. package/core/platform/TypescriptUtilities.js.map +1 -1
  21. package/core/platform/api/HostRuntime.d.ts +30 -3
  22. package/core/platform/api/HostRuntime.js.map +1 -1
  23. package/core/platform/api/api-tsconfig.json +26 -11
  24. package/core/platform/api/api-tsconfig.ref.json +26 -0
  25. package/core/platform/browser/HostRuntime.js +103 -2
  26. package/core/platform/browser/HostRuntime.js.map +1 -1
  27. package/core/platform/browser/browser-tsconfig.json +22 -11
  28. package/core/platform/browser/browser-tsconfig.ref.json +27 -0
  29. package/core/platform/browser/bundle-tsconfig.json +59 -1
  30. package/core/platform/browser/bundle-tsconfig.ref.json +27 -0
  31. package/core/platform/bundle-tsconfig.json +59 -1
  32. package/core/platform/bundle-tsconfig.ref.json +27 -0
  33. package/core/platform/foundation_unittests-tsconfig.json +73 -0
  34. package/core/platform/foundation_unittests-tsconfig.ref.json +40 -0
  35. package/core/platform/foundation_unittests_node_typecheck-tsconfig.json +70 -0
  36. package/core/platform/node/HostRuntime.js +58 -4
  37. package/core/platform/node/HostRuntime.js.map +1 -1
  38. package/core/platform/node/bundle-tsconfig.json +59 -1
  39. package/core/platform/node/bundle-tsconfig.ref.json +27 -0
  40. package/core/platform/node/node-tsconfig.json +16 -9
  41. package/core/platform/node/node-tsconfig.ref.json +27 -0
  42. package/core/platform/platform-tsconfig.json +25 -13
  43. package/core/platform/platform-tsconfig.ref.json +49 -0
  44. package/core/platform/platform.d.ts +2 -1
  45. package/core/platform/platform.js +2 -1
  46. package/core/platform/platform.js.map +1 -1
  47. package/core/platform/platform_node_typecheck-tsconfig.json +18 -14
  48. package/core/platform/platform_node_typecheck.stamp +0 -0
  49. package/generated/protocol.d.ts +941 -718
  50. package/generated/protocol.js +3300 -1
  51. package/locales/af.json +191 -134
  52. package/locales/am.json +191 -134
  53. package/locales/ar.json +194 -137
  54. package/locales/as.json +193 -136
  55. package/locales/az.json +191 -134
  56. package/locales/be.json +189 -132
  57. package/locales/bg.json +190 -133
  58. package/locales/bn.json +191 -134
  59. package/locales/bs.json +189 -132
  60. package/locales/ca.json +193 -136
  61. package/locales/cs.json +185 -128
  62. package/locales/cy.json +191 -134
  63. package/locales/da.json +189 -132
  64. package/locales/de.json +189 -132
  65. package/locales/el.json +188 -131
  66. package/locales/en-GB.json +193 -136
  67. package/locales/en-US.json +165 -141
  68. package/locales/en-XL.json +165 -141
  69. package/locales/es-419.json +187 -130
  70. package/locales/es.json +186 -129
  71. package/locales/et.json +161 -104
  72. package/locales/eu.json +188 -131
  73. package/locales/fa.json +191 -134
  74. package/locales/fi.json +188 -131
  75. package/locales/fil.json +191 -134
  76. package/locales/fr-CA.json +191 -134
  77. package/locales/fr.json +187 -130
  78. package/locales/gl.json +190 -133
  79. package/locales/gu.json +192 -135
  80. package/locales/he.json +193 -136
  81. package/locales/hi.json +193 -136
  82. package/locales/hr.json +190 -133
  83. package/locales/hu.json +148 -91
  84. package/locales/hy.json +184 -127
  85. package/locales/id.json +190 -133
  86. package/locales/is.json +186 -129
  87. package/locales/it.json +190 -133
  88. package/locales/ja.json +187 -130
  89. package/locales/ka.json +193 -136
  90. package/locales/kk.json +98 -41
  91. package/locales/km.json +191 -134
  92. package/locales/kn.json +194 -137
  93. package/locales/ko.json +79 -22
  94. package/locales/ky.json +192 -135
  95. package/locales/lo.json +191 -134
  96. package/locales/lt.json +189 -132
  97. package/locales/lv.json +126 -69
  98. package/locales/mk.json +191 -134
  99. package/locales/ml.json +187 -130
  100. package/locales/mn.json +187 -130
  101. package/locales/mr.json +189 -132
  102. package/locales/ms.json +190 -133
  103. package/locales/my.json +192 -135
  104. package/locales/ne.json +189 -132
  105. package/locales/nl.json +186 -129
  106. package/locales/no.json +188 -131
  107. package/locales/or.json +189 -132
  108. package/locales/pa.json +190 -133
  109. package/locales/pl.json +190 -133
  110. package/locales/pt-PT.json +189 -132
  111. package/locales/pt.json +191 -134
  112. package/locales/ro.json +186 -129
  113. package/locales/ru.json +110 -53
  114. package/locales/si.json +191 -134
  115. package/locales/sk.json +190 -133
  116. package/locales/sl.json +186 -129
  117. package/locales/sq.json +187 -130
  118. package/locales/sr-Latn.json +187 -130
  119. package/locales/sr.json +187 -130
  120. package/locales/sv.json +189 -132
  121. package/locales/sw.json +195 -138
  122. package/locales/ta.json +190 -133
  123. package/locales/te.json +193 -136
  124. package/locales/th.json +148 -91
  125. package/locales/tr.json +188 -131
  126. package/locales/uk.json +186 -129
  127. package/locales/ur.json +188 -131
  128. package/locales/uz.json +185 -128
  129. package/locales/vi.json +196 -139
  130. package/locales/zh-HK.json +187 -130
  131. package/locales/zh-TW.json +190 -133
  132. package/locales/zh.json +189 -132
  133. package/locales/zu.json +193 -136
  134. package/models/cpu_profile/bundle-tsconfig.json +59 -1
  135. package/models/cpu_profile/bundle-tsconfig.ref.json +27 -0
  136. package/models/cpu_profile/cpu_profile-tsconfig.json +24 -16
  137. package/models/cpu_profile/cpu_profile-tsconfig.ref.json +31 -0
  138. package/models/cpu_profile/cpu_profile_node_typecheck-tsconfig.json +60 -0
  139. package/models/cpu_profile/cpu_profile_node_typecheck.stamp +0 -0
  140. package/models/{trace/devtools_entrypoint-bundle-typescript-tsconfig.json → cpu_profile/foundation_unittests-tsconfig.json} +27 -30
  141. package/models/cpu_profile/foundation_unittests-tsconfig.ref.json +30 -0
  142. package/models/cpu_profile/foundation_unittests_node_typecheck-tsconfig.json +60 -0
  143. package/models/trace/EntityMapper.js +1 -1
  144. package/models/trace/EntityMapper.js.map +1 -1
  145. package/models/trace/LanternComputationData.js +7 -0
  146. package/models/trace/LanternComputationData.js.map +1 -1
  147. package/models/trace/ModelImpl.d.ts +1 -5
  148. package/models/trace/ModelImpl.js +11 -0
  149. package/models/trace/ModelImpl.js.map +1 -1
  150. package/models/trace/Name.js +5 -5
  151. package/models/trace/Name.js.map +1 -1
  152. package/models/trace/Processor.d.ts +2 -6
  153. package/models/trace/Processor.js +77 -15
  154. package/models/trace/Processor.js.map +1 -1
  155. package/models/trace/Styles.js +128 -116
  156. package/models/trace/Styles.js.map +1 -1
  157. package/models/trace/bundle-tsconfig.json +77 -1
  158. package/models/trace/bundle-tsconfig.ref.json +45 -0
  159. package/models/trace/extras/StackTraceForEvent.d.ts +1 -1
  160. package/models/trace/extras/StackTraceForEvent.js.map +1 -1
  161. package/models/trace/extras/ThirdParties.js +7 -7
  162. package/models/trace/extras/ThirdParties.js.map +1 -1
  163. package/models/trace/extras/TraceTree.js +23 -3
  164. package/models/trace/extras/TraceTree.js.map +1 -1
  165. package/models/trace/extras/bundle-tsconfig.json +59 -1
  166. package/models/trace/extras/bundle-tsconfig.ref.json +27 -0
  167. package/models/trace/extras/extras-tsconfig.json +28 -20
  168. package/models/trace/extras/extras-tsconfig.ref.json +49 -0
  169. package/models/trace/extras/extras_node_typecheck-tsconfig.json +78 -0
  170. package/models/trace/extras/extras_node_typecheck.stamp +0 -0
  171. package/models/trace/extras/foundation_unittests-tsconfig.json +91 -0
  172. package/models/trace/extras/foundation_unittests-tsconfig.ref.json +58 -0
  173. package/models/trace/extras/foundation_unittests_node_typecheck-tsconfig.json +88 -0
  174. package/models/trace/foundation_unittests-tsconfig.json +70 -0
  175. package/models/trace/foundation_unittests-tsconfig.ref.json +37 -0
  176. package/models/trace/foundation_unittests_node_typecheck-tsconfig.json +67 -0
  177. package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -1
  178. package/models/trace/handlers/ExtensionTraceDataHandler.js +1 -1
  179. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
  180. package/models/trace/handlers/FlowsHandler.js.map +1 -1
  181. package/models/trace/handlers/FramesHandler.d.ts +1 -2
  182. package/models/trace/handlers/FramesHandler.js +23 -18
  183. package/models/trace/handlers/FramesHandler.js.map +1 -1
  184. package/models/trace/handlers/LayerTreeHandler.js +3 -3
  185. package/models/trace/handlers/LayerTreeHandler.js.map +1 -1
  186. package/models/trace/handlers/LayoutShiftsHandler.d.ts +2 -2
  187. package/models/trace/handlers/LayoutShiftsHandler.js +17 -18
  188. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  189. package/models/trace/handlers/MetaHandler.d.ts +2 -3
  190. package/models/trace/handlers/MetaHandler.js +38 -7
  191. package/models/trace/handlers/MetaHandler.js.map +1 -1
  192. package/models/trace/handlers/ModelHandlers.d.ts +0 -1
  193. package/models/trace/handlers/ModelHandlers.js +0 -1
  194. package/models/trace/handlers/ModelHandlers.js.map +1 -1
  195. package/models/trace/handlers/NetworkRequestsHandler.js +13 -11
  196. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  197. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +2 -0
  198. package/models/trace/handlers/PageLoadMetricsHandler.js +43 -4
  199. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
  200. package/models/trace/handlers/RendererHandler.js +19 -20
  201. package/models/trace/handlers/RendererHandler.js.map +1 -1
  202. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  203. package/models/trace/handlers/ScreenshotsHandler.js +1 -43
  204. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -1
  205. package/models/trace/handlers/Threads.d.ts +1 -3
  206. package/models/trace/handlers/Threads.js +4 -8
  207. package/models/trace/handlers/Threads.js.map +1 -1
  208. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -1
  209. package/models/trace/handlers/UserTimingsHandler.d.ts +1 -1
  210. package/models/trace/handlers/UserTimingsHandler.js +16 -6
  211. package/models/trace/handlers/UserTimingsHandler.js.map +1 -1
  212. package/models/trace/handlers/WarningsHandler.js.map +1 -1
  213. package/models/trace/handlers/bundle-tsconfig.json +59 -1
  214. package/models/trace/handlers/bundle-tsconfig.ref.json +27 -0
  215. package/models/trace/handlers/foundation_unittests-tsconfig.json +102 -0
  216. package/models/trace/handlers/foundation_unittests-tsconfig.ref.json +69 -0
  217. package/models/trace/handlers/foundation_unittests_node_typecheck-tsconfig.json +99 -0
  218. package/models/trace/handlers/handlers-tsconfig.json +30 -23
  219. package/models/trace/handlers/handlers-tsconfig.ref.json +80 -0
  220. package/models/trace/handlers/handlers_node_typecheck-tsconfig.json +109 -0
  221. package/models/trace/handlers/handlers_node_typecheck.stamp +0 -0
  222. package/models/trace/helpers/Network.d.ts +3 -1
  223. package/models/trace/helpers/Network.js.map +1 -1
  224. package/models/trace/helpers/SamplesIntegrator.js +22 -6
  225. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  226. package/models/trace/helpers/SyntheticEvents.d.ts +7 -0
  227. package/models/trace/helpers/SyntheticEvents.js +20 -1
  228. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  229. package/models/trace/helpers/Timing.js +14 -1
  230. package/models/trace/helpers/Timing.js.map +1 -1
  231. package/models/trace/helpers/Trace.js.map +1 -1
  232. package/models/trace/helpers/bundle-tsconfig.json +59 -1
  233. package/models/trace/helpers/bundle-tsconfig.ref.json +27 -0
  234. package/models/trace/helpers/foundation_unittests-tsconfig.json +73 -0
  235. package/models/trace/helpers/foundation_unittests-tsconfig.ref.json +40 -0
  236. package/models/trace/helpers/foundation_unittests_node_typecheck-tsconfig.json +70 -0
  237. package/models/trace/helpers/helpers-tsconfig.json +27 -22
  238. package/models/trace/helpers/helpers-tsconfig.ref.json +45 -0
  239. package/models/trace/helpers/helpers_node_typecheck-tsconfig.json +74 -0
  240. package/models/trace/helpers/helpers_node_typecheck.stamp +0 -0
  241. package/models/trace/insights/CLSCulprits.d.ts +18 -15
  242. package/models/trace/insights/CLSCulprits.js +7 -6
  243. package/models/trace/insights/CLSCulprits.js.map +1 -1
  244. package/models/trace/insights/Cache.d.ts +8 -7
  245. package/models/trace/insights/Cache.js.map +1 -1
  246. package/models/trace/insights/CharacterSet.d.ts +10 -9
  247. package/models/trace/insights/CharacterSet.js +4 -4
  248. package/models/trace/insights/CharacterSet.js.map +1 -1
  249. package/models/trace/insights/Common.d.ts +2 -1
  250. package/models/trace/insights/Common.js +32 -3
  251. package/models/trace/insights/Common.js.map +1 -1
  252. package/models/trace/insights/DOMSize.d.ts +15 -14
  253. package/models/trace/insights/DOMSize.js +2 -2
  254. package/models/trace/insights/DOMSize.js.map +1 -1
  255. package/models/trace/insights/DocumentLatency.d.ts +13 -12
  256. package/models/trace/insights/DocumentLatency.js +4 -4
  257. package/models/trace/insights/DocumentLatency.js.map +1 -1
  258. package/models/trace/insights/DuplicatedJavaScript.d.ts +16 -7
  259. package/models/trace/insights/DuplicatedJavaScript.js +11 -3
  260. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
  261. package/models/trace/insights/FontDisplay.d.ts +19 -9
  262. package/models/trace/insights/FontDisplay.js +13 -3
  263. package/models/trace/insights/FontDisplay.js.map +1 -1
  264. package/models/trace/insights/ForcedReflow.d.ts +13 -13
  265. package/models/trace/insights/ForcedReflow.js +4 -4
  266. package/models/trace/insights/ForcedReflow.js.map +1 -1
  267. package/models/trace/insights/INPBreakdown.d.ts +12 -12
  268. package/models/trace/insights/INPBreakdown.js +1 -1
  269. package/models/trace/insights/INPBreakdown.js.map +1 -1
  270. package/models/trace/insights/ImageDelivery.d.ts +13 -12
  271. package/models/trace/insights/ImageDelivery.js +5 -5
  272. package/models/trace/insights/ImageDelivery.js.map +1 -1
  273. package/models/trace/insights/LCPBreakdown.d.ts +13 -12
  274. package/models/trace/insights/LCPBreakdown.js +3 -3
  275. package/models/trace/insights/LCPBreakdown.js.map +1 -1
  276. package/models/trace/insights/LCPDiscovery.d.ts +14 -13
  277. package/models/trace/insights/LCPDiscovery.js +7 -7
  278. package/models/trace/insights/LCPDiscovery.js.map +1 -1
  279. package/models/trace/insights/LegacyJavaScript.d.ts +16 -7
  280. package/models/trace/insights/LegacyJavaScript.js +11 -3
  281. package/models/trace/insights/LegacyJavaScript.js.map +1 -1
  282. package/models/trace/insights/ModernHTTP.d.ts +10 -10
  283. package/models/trace/insights/ModernHTTP.js +9 -5
  284. package/models/trace/insights/ModernHTTP.js.map +1 -1
  285. package/models/trace/insights/NetworkDependencyTree.d.ts +33 -28
  286. package/models/trace/insights/NetworkDependencyTree.js +17 -13
  287. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  288. package/models/trace/insights/RenderBlocking.d.ts +8 -7
  289. package/models/trace/insights/RenderBlocking.js +3 -5
  290. package/models/trace/insights/RenderBlocking.js.map +1 -1
  291. package/models/trace/insights/SlowCSSSelector.d.ts +17 -16
  292. package/models/trace/insights/SlowCSSSelector.js +23 -20
  293. package/models/trace/insights/SlowCSSSelector.js.map +1 -1
  294. package/models/trace/insights/ThirdParties.d.ts +22 -13
  295. package/models/trace/insights/ThirdParties.js +19 -8
  296. package/models/trace/insights/ThirdParties.js.map +1 -1
  297. package/models/trace/insights/Viewport.d.ts +8 -6
  298. package/models/trace/insights/Viewport.js +4 -2
  299. package/models/trace/insights/Viewport.js.map +1 -1
  300. package/models/trace/insights/bundle-tsconfig.json +59 -1
  301. package/models/trace/insights/bundle-tsconfig.ref.json +27 -0
  302. package/models/trace/insights/foundation_unittests-tsconfig.json +98 -0
  303. package/models/trace/insights/foundation_unittests-tsconfig.ref.json +65 -0
  304. package/models/trace/insights/foundation_unittests_node_typecheck-tsconfig.json +95 -0
  305. package/models/trace/insights/insights-tsconfig.json +34 -23
  306. package/models/trace/insights/insights-tsconfig.ref.json +82 -0
  307. package/models/trace/insights/insights_node_typecheck-tsconfig.json +111 -0
  308. package/models/trace/insights/insights_node_typecheck.stamp +0 -0
  309. package/models/trace/insights/types.d.ts +9 -6
  310. package/models/trace/insights/types.js.map +1 -1
  311. package/models/trace/lantern/bundle-tsconfig.json +71 -1
  312. package/models/trace/lantern/bundle-tsconfig.ref.json +39 -0
  313. package/models/trace/lantern/core/NetworkAnalyzer.d.ts +5 -4
  314. package/models/trace/lantern/core/NetworkAnalyzer.js +21 -22
  315. package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -1
  316. package/models/trace/lantern/core/bundle-tsconfig.json +59 -1
  317. package/models/trace/lantern/core/bundle-tsconfig.ref.json +27 -0
  318. package/models/trace/lantern/core/core-tsconfig.json +23 -12
  319. package/models/trace/lantern/core/core-tsconfig.ref.json +28 -0
  320. package/models/trace/lantern/core/core_node_typecheck-tsconfig.json +57 -0
  321. package/models/trace/lantern/core/core_node_typecheck.stamp +0 -0
  322. package/models/trace/lantern/core/{devtools_entrypoint-bundle-typescript-tsconfig.json → foundation_unittests-tsconfig.json} +34 -13
  323. package/models/trace/lantern/core/foundation_unittests-tsconfig.ref.json +36 -0
  324. package/models/trace/lantern/core/foundation_unittests_node_typecheck-tsconfig.json +66 -0
  325. package/models/trace/lantern/graph/BaseNode.d.ts +2 -2
  326. package/models/trace/lantern/graph/BaseNode.js.map +1 -1
  327. package/models/trace/lantern/graph/CPUNode.d.ts +4 -2
  328. package/models/trace/lantern/graph/CPUNode.js +23 -7
  329. package/models/trace/lantern/graph/CPUNode.js.map +1 -1
  330. package/models/trace/lantern/graph/NetworkNode.js +12 -0
  331. package/models/trace/lantern/graph/NetworkNode.js.map +1 -1
  332. package/models/trace/lantern/graph/PageDependencyGraph.js +26 -4
  333. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
  334. package/models/trace/lantern/graph/bundle-tsconfig.json +59 -1
  335. package/models/trace/lantern/graph/bundle-tsconfig.ref.json +27 -0
  336. package/models/trace/lantern/graph/{devtools_entrypoint-bundle-typescript-tsconfig.json → foundation_unittests-tsconfig.json} +26 -13
  337. package/models/trace/lantern/graph/foundation_unittests-tsconfig.ref.json +28 -0
  338. package/models/trace/lantern/graph/foundation_unittests_node_typecheck-tsconfig.json +58 -0
  339. package/models/trace/lantern/graph/graph-tsconfig.json +24 -13
  340. package/models/trace/lantern/graph/graph-tsconfig.ref.json +33 -0
  341. package/models/trace/lantern/graph/graph_node_typecheck-tsconfig.json +62 -0
  342. package/models/trace/lantern/graph/graph_node_typecheck.stamp +0 -0
  343. package/models/trace/lantern/metrics/TotalBlockingTime.js +1 -1
  344. package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -1
  345. package/models/trace/lantern/metrics/bundle-tsconfig.json +59 -1
  346. package/models/trace/lantern/metrics/bundle-tsconfig.ref.json +27 -0
  347. package/models/trace/lantern/metrics/foundation_unittests-tsconfig.json +76 -0
  348. package/models/trace/lantern/metrics/foundation_unittests-tsconfig.ref.json +43 -0
  349. package/models/trace/lantern/metrics/foundation_unittests_node_typecheck-tsconfig.json +73 -0
  350. package/models/trace/lantern/metrics/metrics-tsconfig.json +26 -15
  351. package/models/trace/lantern/metrics/metrics-tsconfig.ref.json +43 -0
  352. package/models/trace/lantern/metrics/metrics_node_typecheck-tsconfig.json +72 -0
  353. package/models/trace/lantern/metrics/metrics_node_typecheck.stamp +0 -0
  354. package/models/trace/lantern/simulation/ConnectionPool.js +4 -4
  355. package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -1
  356. package/models/trace/lantern/simulation/Constants.d.ts +29 -28
  357. package/models/trace/lantern/simulation/Constants.js +3 -1
  358. package/models/trace/lantern/simulation/Constants.js.map +1 -1
  359. package/models/trace/lantern/simulation/DNSCache.js.map +1 -1
  360. package/models/trace/lantern/simulation/Simulator.js +6 -2
  361. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  362. package/models/trace/lantern/simulation/TCPConnection.d.ts +4 -4
  363. package/models/trace/lantern/simulation/TCPConnection.js +12 -12
  364. package/models/trace/lantern/simulation/TCPConnection.js.map +1 -1
  365. package/models/trace/lantern/simulation/bundle-tsconfig.json +59 -1
  366. package/models/trace/lantern/simulation/bundle-tsconfig.ref.json +27 -0
  367. package/models/trace/lantern/simulation/foundation_unittests-tsconfig.json +75 -0
  368. package/models/trace/lantern/simulation/foundation_unittests-tsconfig.ref.json +42 -0
  369. package/models/trace/lantern/simulation/foundation_unittests_node_typecheck-tsconfig.json +72 -0
  370. package/models/trace/lantern/simulation/simulation-tsconfig.json +25 -14
  371. package/models/trace/lantern/simulation/simulation-tsconfig.ref.json +38 -0
  372. package/models/trace/lantern/simulation/simulation_node_typecheck-tsconfig.json +67 -0
  373. package/models/trace/lantern/simulation/simulation_node_typecheck.stamp +0 -0
  374. package/models/trace/lantern/{metrics/devtools_entrypoint-bundle-typescript-tsconfig.json → testing/bundle-tsconfig.json} +25 -13
  375. package/models/trace/lantern/testing/bundle-tsconfig.ref.json +27 -0
  376. package/models/trace/lantern/{simulation/devtools_entrypoint-bundle-typescript-tsconfig.json → testing/testing-tsconfig.json} +28 -13
  377. package/models/trace/lantern/testing/testing-tsconfig.ref.json +30 -0
  378. package/models/trace/lantern/types/Lantern.d.ts +27 -19
  379. package/models/trace/lantern/types/Lantern.js.map +1 -1
  380. package/models/trace/lantern/types/bundle-tsconfig.json +59 -1
  381. package/models/trace/lantern/types/bundle-tsconfig.ref.json +27 -0
  382. package/models/trace/lantern/types/types-tsconfig.json +23 -12
  383. package/models/trace/lantern/types/types-tsconfig.ref.json +27 -0
  384. package/models/trace/lantern/types/{devtools_entrypoint-bundle-typescript-tsconfig.json → types_node_typecheck-tsconfig.json} +25 -17
  385. package/models/trace/lantern/types/types_node_typecheck.stamp +0 -0
  386. package/models/trace/trace-tsconfig.json +31 -32
  387. package/models/trace/trace-tsconfig.ref.json +57 -0
  388. package/models/trace/trace_node_typecheck-tsconfig.json +86 -0
  389. package/models/trace/trace_node_typecheck.stamp +0 -0
  390. package/models/trace/types/Configuration.d.ts +11 -0
  391. package/models/trace/types/Configuration.js +1 -0
  392. package/models/trace/types/Configuration.js.map +1 -1
  393. package/models/trace/types/Extensions.d.ts +1 -1
  394. package/models/trace/types/File.d.ts +7 -1
  395. package/models/trace/types/File.js.map +1 -1
  396. package/models/trace/types/Overlays.d.ts +13 -3
  397. package/models/trace/types/Overlays.js.map +1 -1
  398. package/models/trace/types/TraceEvents.d.ts +39 -9
  399. package/models/trace/types/TraceEvents.js +103 -3
  400. package/models/trace/types/TraceEvents.js.map +1 -1
  401. package/models/trace/types/bundle-tsconfig.json +59 -1
  402. package/models/trace/types/bundle-tsconfig.ref.json +27 -0
  403. package/{core/platform/api/api_node_typecheck-tsconfig.json → models/trace/types/foundation_unittests-tsconfig.json} +32 -13
  404. package/models/trace/types/foundation_unittests-tsconfig.ref.json +34 -0
  405. package/models/trace/types/foundation_unittests_node_typecheck-tsconfig.json +64 -0
  406. package/models/trace/types/types-tsconfig.json +27 -19
  407. package/models/trace/types/types-tsconfig.ref.json +44 -0
  408. package/models/trace/types/types_node_typecheck-tsconfig.json +73 -0
  409. package/models/trace/types/types_node_typecheck.stamp +0 -0
  410. package/package.json +2 -3
  411. package/test/test-trace-engine.mjs +1 -1
  412. package/{models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json → third_party/legacy-javascript/bundle-tsconfig.json} +24 -13
  413. package/third_party/legacy-javascript/bundle-tsconfig.ref.json +27 -0
  414. package/third_party/legacy-javascript/legacy-javascript-tsconfig.ref.json +15 -0
  415. package/third_party/legacy-javascript/legacy-javascript.d.ts +2 -1
  416. package/third_party/legacy-javascript/legacy-javascript.js +3 -1
  417. package/third_party/legacy-javascript/legacy-javascript.js.map +1 -0
  418. package/third_party/legacy-javascript/lib/legacy-javascript.d.ts +18 -0
  419. package/third_party/legacy-javascript/lib/legacy-javascript.js +1119 -0
  420. package/core/platform/api/bundle-tsconfig.json +0 -1
  421. package/core/platform/api/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  422. package/core/platform/browser/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  423. package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  424. package/core/platform/node/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  425. package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  426. package/models/trace/handlers/AuctionWorkletsHandler.d.ts +0 -8
  427. package/models/trace/handlers/AuctionWorkletsHandler.js +0 -163
  428. package/models/trace/handlers/AuctionWorkletsHandler.js.map +0 -1
  429. package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  430. package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  431. package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  432. package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
  433. package/models/trace/lantern/lantern-tsconfig.json +0 -59
  434. package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -48
@@ -0,0 +1,43 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "declaration": true,
5
+ "declarationDir": ".",
6
+ "emitDeclarationOnly": true,
7
+ "outDir": ".",
8
+ "rootDir": "../../../../../../../../front_end/models/trace/lantern/metrics",
9
+ "rootDirs": [
10
+ "../../../../../../../../",
11
+ "../../../../../"
12
+ ],
13
+ "skipLibCheck": true
14
+ },
15
+ "files": [
16
+ "../../../../../../../../front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts",
17
+ "../../../../../../../../front_end/models/trace/lantern/metrics/Interactive.ts",
18
+ "../../../../../../../../front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts",
19
+ "../../../../../../../../front_end/models/trace/lantern/metrics/MaxPotentialFID.ts",
20
+ "../../../../../../../../front_end/models/trace/lantern/metrics/Metric.ts",
21
+ "../../../../../../../../front_end/models/trace/lantern/metrics/SpeedIndex.ts",
22
+ "../../../../../../../../front_end/models/trace/lantern/metrics/TBTUtils.ts",
23
+ "../../../../../../../../front_end/models/trace/lantern/metrics/TotalBlockingTime.ts",
24
+ "../../../../../../../../front_end/legacy/legacy-defs.d.ts",
25
+ "../../../../../../../../front_end/global_typings/global_defs.d.ts",
26
+ "../../../../../../../../node_modules/@types/filesystem/index.d.ts",
27
+ "../../../../../../../../node_modules/@types/filewriter/index.d.ts"
28
+ ],
29
+ "references": [
30
+ {
31
+ "path": "../core/bundle-tsconfig.ref.json"
32
+ },
33
+ {
34
+ "path": "../graph/bundle-tsconfig.ref.json"
35
+ },
36
+ {
37
+ "path": "../simulation/bundle-tsconfig.ref.json"
38
+ },
39
+ {
40
+ "path": "../types/bundle-tsconfig.ref.json"
41
+ }
42
+ ]
43
+ }
@@ -0,0 +1,72 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": false,
4
+ "allowSyntheticDefaultImports": true,
5
+ "checkJs": false,
6
+ "composite": false,
7
+ "declaration": false,
8
+ "disableSourceOfProjectReferenceRedirect": true,
9
+ "experimentalDecorators": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "incremental": false,
12
+ "inlineSources": true,
13
+ "lib": [
14
+ "ES2023",
15
+ "ES2024.Promise",
16
+ "ESNext.Iterator",
17
+ "ESNext.Collection",
18
+ "ESNext.Array"
19
+ ],
20
+ "module": "esnext",
21
+ "moduleResolution": "bundler",
22
+ "noEmit": true,
23
+ "noEmitOnError": true,
24
+ "noFallthroughCasesInSwitch": true,
25
+ "noImplicitOverride": true,
26
+ "noImplicitReturns": true,
27
+ "outDir": ".",
28
+ "preserveConstEnums": true,
29
+ "rootDir": "../../../../../../../../front_end/models/trace/lantern/metrics",
30
+ "rootDirs": [
31
+ "../../../../../../../../",
32
+ "../../../../../"
33
+ ],
34
+ "skipLibCheck": true,
35
+ "sourceMap": true,
36
+ "strict": true,
37
+ "target": "es2023",
38
+ "typeRoots": [
39
+ "../../../../../../../../node_modules/@types",
40
+ "../../../../../../../../node_modules"
41
+ ],
42
+ "types": [
43
+ "node",
44
+ "undici-types"
45
+ ],
46
+ "useUnknownInCatchVariables": false
47
+ },
48
+ "files": [
49
+ "../../../../../../../../front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts",
50
+ "../../../../../../../../front_end/models/trace/lantern/metrics/Interactive.ts",
51
+ "../../../../../../../../front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts",
52
+ "../../../../../../../../front_end/models/trace/lantern/metrics/MaxPotentialFID.ts",
53
+ "../../../../../../../../front_end/models/trace/lantern/metrics/Metric.ts",
54
+ "../../../../../../../../front_end/models/trace/lantern/metrics/SpeedIndex.ts",
55
+ "../../../../../../../../front_end/models/trace/lantern/metrics/TBTUtils.ts",
56
+ "../../../../../../../../front_end/models/trace/lantern/metrics/TotalBlockingTime.ts"
57
+ ],
58
+ "references": [
59
+ {
60
+ "path": "../core/bundle-tsconfig.ref.json"
61
+ },
62
+ {
63
+ "path": "../graph/bundle-tsconfig.ref.json"
64
+ },
65
+ {
66
+ "path": "../simulation/bundle-tsconfig.ref.json"
67
+ },
68
+ {
69
+ "path": "../types/bundle-tsconfig.ref.json"
70
+ }
71
+ ]
72
+ }
@@ -43,16 +43,16 @@ export class ConnectionPool {
43
43
  continue;
44
44
  }
45
45
  const isTLS = TLS_SCHEMES.includes(request.parsedURL.scheme);
46
- const isH2 = request.protocol === 'h2';
47
- const connection = new TCPConnection(this.options.rtt + additionalRtt, this.options.throughput, responseTime, isTLS, isH2);
46
+ const isMultiplexed = Core.NetworkAnalyzer.isMultiplexedProtocol(request.protocol);
47
+ const connection = new TCPConnection(this.options.rtt + additionalRtt, this.options.throughput, responseTime, isTLS, isMultiplexed);
48
48
  connections.push(connection);
49
49
  }
50
50
  if (!connections.length) {
51
51
  throw new Core.LanternError(`Could not find a connection for origin: ${origin}`);
52
52
  }
53
53
  // Make sure each origin has minimum number of connections available for max throughput.
54
- // But only if it's not over H2 which maximizes throughput already.
55
- const minConnections = connections[0].isH2() ? 1 : CONNECTIONS_PER_ORIGIN;
54
+ // But only if it's not over a multiplexed protocol which maximizes throughput already.
55
+ const minConnections = connections[0].isMultiplexed() ? 1 : CONNECTIONS_PER_ORIGIN;
56
56
  while (connections.length < minConnections) {
57
57
  connections.push(connections[0].clone());
58
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionPool.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/ConnectionPool.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAGxC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEjD,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAErC,uDAAuD;AACvD,wHAAwH;AACxH,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC,MAAM,OAAO,cAAc;IACzB,OAAO,CAAuC;IAC9C,OAAO,CAA2B;IAClC,mBAAmB,CAA+B;IAClD,oBAAoB,CAA6C;IACjE,iBAAiB,CAAqB;IACtC,2BAA2B,CAAuB;IAElD,YAAY,OAAiC,EAAE,OAA6C;QAC1F,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;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AC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Core from '../core/core.js';\nimport type * as Lantern from '../types/types.js';\n\nimport {TCPConnection} from './TCPConnection.js';\n\nconst DEFAULT_SERVER_RESPONSE_TIME = 30;\nconst TLS_SCHEMES = ['https', 'wss'];\n\n// Each origin can have 6 simultaneous connections open\n// https://cs.chromium.org/chromium/src/net/socket/client_socket_pool_manager.cc?type=cs&q=\"int+g_max_sockets_per_group\"\nconst CONNECTIONS_PER_ORIGIN = 6;\n\nexport class ConnectionPool {\n options: Required<Lantern.Simulation.Options>;\n records: Lantern.NetworkRequest[];\n connectionsByOrigin: Map<string, TCPConnection[]>;\n connectionsByRequest: Map<Lantern.NetworkRequest, TCPConnection>;\n _connectionsInUse: Set<TCPConnection>;\n connectionReusedByRequestId: Map<string, boolean>;\n\n constructor(records: Lantern.NetworkRequest[], options: Required<Lantern.Simulation.Options>) {\n this.options = options;\n\n this.records = records;\n this.connectionsByOrigin = new Map();\n this.connectionsByRequest = new Map();\n this._connectionsInUse = new Set();\n this.connectionReusedByRequestId = Core.NetworkAnalyzer.estimateIfConnectionWasReused(records, {\n forceCoarseEstimates: true,\n });\n\n this.initializeConnections();\n }\n\n connectionsInUse(): TCPConnection[] {\n return Array.from(this._connectionsInUse);\n }\n\n initializeConnections(): void {\n const connectionReused = this.connectionReusedByRequestId;\n const additionalRttByOrigin = this.options.additionalRttByOrigin;\n const serverResponseTimeByOrigin = this.options.serverResponseTimeByOrigin;\n\n const recordsByOrigin = Core.NetworkAnalyzer.groupByOrigin(this.records);\n for (const [origin, requests] of recordsByOrigin.entries()) {\n const connections = [];\n const additionalRtt = additionalRttByOrigin.get(origin) || 0;\n const responseTime = serverResponseTimeByOrigin.get(origin) || DEFAULT_SERVER_RESPONSE_TIME;\n\n for (const request of requests) {\n if (connectionReused.get(request.requestId)) {\n continue;\n }\n\n const isTLS = TLS_SCHEMES.includes(request.parsedURL.scheme);\n const isH2 = request.protocol === 'h2';\n const connection = new TCPConnection(\n this.options.rtt + additionalRtt,\n this.options.throughput,\n responseTime,\n isTLS,\n isH2,\n );\n\n connections.push(connection);\n }\n\n if (!connections.length) {\n throw new Core.LanternError(`Could not find a connection for origin: ${origin}`);\n }\n\n // Make sure each origin has minimum number of connections available for max throughput.\n // But only if it's not over H2 which maximizes throughput already.\n const minConnections = connections[0].isH2() ? 1 : CONNECTIONS_PER_ORIGIN;\n while (connections.length < minConnections) {\n connections.push(connections[0].clone());\n }\n\n this.connectionsByOrigin.set(origin, connections);\n }\n }\n\n findAvailableConnectionWithLargestCongestionWindow(connections: TCPConnection[]): TCPConnection|null {\n let maxConnection: TCPConnection|null = null;\n for (let i = 0; i < connections.length; i++) {\n const connection = connections[i];\n\n // Connections that are in use are never available.\n if (this._connectionsInUse.has(connection)) {\n continue;\n }\n\n // This connection is a match and is available! Update our max if it has a larger congestionWindow\n const currentMax = (maxConnection?.congestionWindow) || -Infinity;\n if (connection.congestionWindow > currentMax) {\n maxConnection = connection;\n }\n }\n\n return maxConnection;\n }\n\n /**\n * This method finds an available connection to the origin specified by the network request or null\n * if no connection was available. If returned, connection will not be available for other network\n * records until release is called.\n */\n acquire(request: Lantern.NetworkRequest): TCPConnection|null {\n if (this.connectionsByRequest.has(request)) {\n throw new Core.LanternError('Record already has a connection');\n }\n\n const origin = request.parsedURL.securityOrigin;\n const connections = this.connectionsByOrigin.get(origin) || [];\n const connectionToUse = this.findAvailableConnectionWithLargestCongestionWindow(connections);\n\n if (!connectionToUse) {\n return null;\n }\n\n this._connectionsInUse.add(connectionToUse);\n this.connectionsByRequest.set(request, connectionToUse);\n return connectionToUse;\n }\n\n /**\n * Return the connection currently being used to fetch a request. If no connection\n * currently being used for this request, an error will be thrown.\n */\n acquireActiveConnectionFromRequest(request: Lantern.NetworkRequest): TCPConnection {\n const activeConnection = this.connectionsByRequest.get(request);\n if (!activeConnection) {\n throw new Core.LanternError('Could not find an active connection for request');\n }\n\n return activeConnection;\n }\n\n release(request: Lantern.NetworkRequest): void {\n const connection = this.connectionsByRequest.get(request);\n this.connectionsByRequest.delete(request);\n if (connection) {\n this._connectionsInUse.delete(connection);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ConnectionPool.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/ConnectionPool.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAGxC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEjD,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAErC,uDAAuD;AACvD,wHAAwH;AACxH,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC,MAAM,OAAO,cAAc;IACzB,OAAO,CAAuC;IAC9C,OAAO,CAA2B;IAClC,mBAAmB,CAA+B;IAClD,oBAAoB,CAA6C;IACjE,iBAAiB,CAAqB;IACtC,2BAA2B,CAAuB;IAElD,YAAY,OAAiC,EAAE,OAA6C;QAC1F,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;QACnC,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC,eAAe,CAAC,6BAA6B,CAAC,OAAO,EAAE;YAC7F,oBAAoB,EAAE,IAAI;SAC3B,CAAC,CAAC;QAEH,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC/B,CAAC;IAED,gBAAgB;QACd,OAAO,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AM,IAAI,IAAI,CAAC,YAAY,CAAC,iCAAiC,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC/D,MAAM,eAAe,GAAG,IAAI,CAAC,kDAAkD,CAAC,WAAW,CAAC,CAAC;QAE7F,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC5C,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QACxD,OAAO,eAAe,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,kCAAkC,CAAC,OAA+B;QAChE,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,iDAAiD,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,OAAO,CAAC,OAA+B;QACrC,MAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Core from '../core/core.js';\nimport type * as Lantern from '../types/types.js';\n\nimport {TCPConnection} from './TCPConnection.js';\n\nconst DEFAULT_SERVER_RESPONSE_TIME = 30;\nconst TLS_SCHEMES = ['https', 'wss'];\n\n// Each origin can have 6 simultaneous connections open\n// https://cs.chromium.org/chromium/src/net/socket/client_socket_pool_manager.cc?type=cs&q=\"int+g_max_sockets_per_group\"\nconst CONNECTIONS_PER_ORIGIN = 6;\n\nexport class ConnectionPool {\n options: Required<Lantern.Simulation.Options>;\n records: Lantern.NetworkRequest[];\n connectionsByOrigin: Map<string, TCPConnection[]>;\n connectionsByRequest: Map<Lantern.NetworkRequest, TCPConnection>;\n _connectionsInUse: Set<TCPConnection>;\n connectionReusedByRequestId: Map<string, boolean>;\n\n constructor(records: Lantern.NetworkRequest[], options: Required<Lantern.Simulation.Options>) {\n this.options = options;\n\n this.records = records;\n this.connectionsByOrigin = new Map();\n this.connectionsByRequest = new Map();\n this._connectionsInUse = new Set();\n this.connectionReusedByRequestId = Core.NetworkAnalyzer.estimateIfConnectionWasReused(records, {\n forceCoarseEstimates: true,\n });\n\n this.initializeConnections();\n }\n\n connectionsInUse(): TCPConnection[] {\n return Array.from(this._connectionsInUse);\n }\n\n initializeConnections(): void {\n const connectionReused = this.connectionReusedByRequestId;\n const additionalRttByOrigin = this.options.additionalRttByOrigin;\n const serverResponseTimeByOrigin = this.options.serverResponseTimeByOrigin;\n\n const recordsByOrigin = Core.NetworkAnalyzer.groupByOrigin(this.records);\n for (const [origin, requests] of recordsByOrigin.entries()) {\n const connections = [];\n const additionalRtt = additionalRttByOrigin.get(origin) || 0;\n const responseTime = serverResponseTimeByOrigin.get(origin) || DEFAULT_SERVER_RESPONSE_TIME;\n\n for (const request of requests) {\n if (connectionReused.get(request.requestId)) {\n continue;\n }\n\n const isTLS = TLS_SCHEMES.includes(request.parsedURL.scheme);\n const isMultiplexed = Core.NetworkAnalyzer.isMultiplexedProtocol(request.protocol);\n const connection = new TCPConnection(\n this.options.rtt + additionalRtt,\n this.options.throughput,\n responseTime,\n isTLS,\n isMultiplexed,\n );\n\n connections.push(connection);\n }\n\n if (!connections.length) {\n throw new Core.LanternError(`Could not find a connection for origin: ${origin}`);\n }\n\n // Make sure each origin has minimum number of connections available for max throughput.\n // But only if it's not over a multiplexed protocol which maximizes throughput already.\n const minConnections = connections[0].isMultiplexed() ? 1 : CONNECTIONS_PER_ORIGIN;\n while (connections.length < minConnections) {\n connections.push(connections[0].clone());\n }\n\n this.connectionsByOrigin.set(origin, connections);\n }\n }\n\n findAvailableConnectionWithLargestCongestionWindow(connections: TCPConnection[]): TCPConnection|null {\n let maxConnection: TCPConnection|null = null;\n for (let i = 0; i < connections.length; i++) {\n const connection = connections[i];\n\n // Connections that are in use are never available.\n if (this._connectionsInUse.has(connection)) {\n continue;\n }\n\n // This connection is a match and is available! Update our max if it has a larger congestionWindow\n const currentMax = (maxConnection?.congestionWindow) || -Infinity;\n if (connection.congestionWindow > currentMax) {\n maxConnection = connection;\n }\n }\n\n return maxConnection;\n }\n\n /**\n * This method finds an available connection to the origin specified by the network request or null\n * if no connection was available. If returned, connection will not be available for other network\n * records until release is called.\n */\n acquire(request: Lantern.NetworkRequest): TCPConnection|null {\n if (this.connectionsByRequest.has(request)) {\n throw new Core.LanternError('Record already has a connection');\n }\n\n const origin = request.parsedURL.securityOrigin;\n const connections = this.connectionsByOrigin.get(origin) || [];\n const connectionToUse = this.findAvailableConnectionWithLargestCongestionWindow(connections);\n\n if (!connectionToUse) {\n return null;\n }\n\n this._connectionsInUse.add(connectionToUse);\n this.connectionsByRequest.set(request, connectionToUse);\n return connectionToUse;\n }\n\n /**\n * Return the connection currently being used to fetch a request. If no connection\n * currently being used for this request, an error will be thrown.\n */\n acquireActiveConnectionFromRequest(request: Lantern.NetworkRequest): TCPConnection {\n const activeConnection = this.connectionsByRequest.get(request);\n if (!activeConnection) {\n throw new Core.LanternError('Could not find an active connection for request');\n }\n\n return activeConnection;\n }\n\n release(request: Lantern.NetworkRequest): void {\n const connection = this.connectionsByRequest.get(request);\n this.connectionsByRequest.delete(request);\n if (connection) {\n this._connectionsInUse.delete(connection);\n }\n }\n}\n"]}
@@ -1,31 +1,32 @@
1
- declare const Constants: {
2
- throttling: {
3
- DEVTOOLS_RTT_ADJUSTMENT_FACTOR: number;
4
- DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR: number;
5
- mobileSlow4G: {
6
- rttMs: number;
7
- throughputKbps: number;
8
- requestLatencyMs: number;
9
- downloadThroughputKbps: number;
10
- uploadThroughputKbps: number;
11
- cpuSlowdownMultiplier: number;
12
- };
13
- mobileRegular3G: {
14
- rttMs: number;
15
- throughputKbps: number;
16
- requestLatencyMs: number;
17
- downloadThroughputKbps: number;
18
- uploadThroughputKbps: number;
19
- cpuSlowdownMultiplier: number;
20
- };
21
- desktopDense4G: {
22
- rttMs: number;
23
- throughputKbps: number;
24
- cpuSlowdownMultiplier: number;
25
- requestLatencyMs: number;
26
- downloadThroughputKbps: number;
27
- uploadThroughputKbps: number;
28
- };
1
+ export interface ThrottlingSettings {
2
+ DEVTOOLS_RTT_ADJUSTMENT_FACTOR: number;
3
+ DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR: number;
4
+ mobileSlow4G: {
5
+ rttMs: number;
6
+ throughputKbps: number;
7
+ requestLatencyMs: number;
8
+ downloadThroughputKbps: number;
9
+ uploadThroughputKbps: number;
10
+ cpuSlowdownMultiplier: number;
11
+ };
12
+ mobileRegular3G: {
13
+ rttMs: number;
14
+ throughputKbps: number;
15
+ requestLatencyMs: number;
16
+ downloadThroughputKbps: number;
17
+ uploadThroughputKbps: number;
18
+ cpuSlowdownMultiplier: number;
29
19
  };
20
+ desktopDense4G: {
21
+ rttMs: number;
22
+ throughputKbps: number;
23
+ cpuSlowdownMultiplier: number;
24
+ requestLatencyMs: number;
25
+ downloadThroughputKbps: number;
26
+ uploadThroughputKbps: number;
27
+ };
28
+ }
29
+ declare const Constants: {
30
+ throttling: ThrottlingSettings;
30
31
  };
31
32
  export { Constants };
@@ -38,6 +38,8 @@ const throttling = {
38
38
  uploadThroughputKbps: 0,
39
39
  },
40
40
  };
41
- const Constants = { throttling };
41
+ const Constants = {
42
+ throttling,
43
+ };
42
44
  export { Constants };
43
45
  //# sourceMappingURL=Constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/Constants.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAC5C,MAAM,qCAAqC,GAAG,GAAG,CAAC;AAElD,MAAM,UAAU,GAAG;IACjB,8BAA8B;IAC9B,qCAAqC;IACrC,gEAAgE;IAChE,sFAAsF;IACtF,YAAY,EAAE;QACZ,KAAK,EAAE,GAAG;QACV,cAAc,EAAE,GAAG,GAAG,IAAI;QAC1B,gBAAgB,EAAE,GAAG,GAAG,8BAA8B;QACtD,sBAAsB,EAAE,GAAG,GAAG,IAAI,GAAG,qCAAqC;QAC1E,oBAAoB,EAAE,GAAG,GAAG,qCAAqC;QACjE,qBAAqB,EAAE,CAAC;KACzB;IACD,8EAA8E;IAC9E,gGAAgG;IAChG,iEAAiE;IACjE,eAAe,EAAE;QACf,KAAK,EAAE,GAAG;QACV,cAAc,EAAE,GAAG;QACnB,gBAAgB,EAAE,GAAG,GAAG,8BAA8B;QACtD,sBAAsB,EAAE,GAAG,GAAG,qCAAqC;QACnE,oBAAoB,EAAE,GAAG,GAAG,qCAAqC;QACjE,qBAAqB,EAAE,CAAC;KACzB;IACD,sCAAsC;IACtC,2JAA2J;IAC3J,cAAc,EAAE;QACd,KAAK,EAAE,EAAE;QACT,cAAc,EAAE,EAAE,GAAG,IAAI;QACzB,qBAAqB,EAAE,CAAC;QACxB,gBAAgB,EAAE,CAAC,EAAG,gBAAgB;QACtC,sBAAsB,EAAE,CAAC;QACzB,oBAAoB,EAAE,CAAC;KACxB;CACF,CAAC;AAEF,MAAM,SAAS,GAAG,EAAC,UAAU,EAAC,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nconst DEVTOOLS_RTT_ADJUSTMENT_FACTOR = 3.75;\nconst DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR = 0.9;\n\nconst throttling = {\n DEVTOOLS_RTT_ADJUSTMENT_FACTOR,\n DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n // These values align with WebPageTest's definition of \"Fast 3G\"\n // But offer similar characteristics to roughly the 75th percentile of 4G connections.\n mobileSlow4G: {\n rttMs: 150,\n throughputKbps: 1.6 * 1024,\n requestLatencyMs: 150 * DEVTOOLS_RTT_ADJUSTMENT_FACTOR,\n downloadThroughputKbps: 1.6 * 1024 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n uploadThroughputKbps: 750 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n cpuSlowdownMultiplier: 4,\n },\n // These values partially align with WebPageTest's definition of \"Regular 3G\".\n // These values are meant to roughly align with Chrome UX report's 3G definition which are based\n // on HTTP RTT of 300-1400ms and downlink throughput of <700kbps.\n mobileRegular3G: {\n rttMs: 300,\n throughputKbps: 700,\n requestLatencyMs: 300 * DEVTOOLS_RTT_ADJUSTMENT_FACTOR,\n downloadThroughputKbps: 700 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n uploadThroughputKbps: 700 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n cpuSlowdownMultiplier: 4,\n },\n // Using a \"broadband\" connection type\n // Corresponds to \"Dense 4G 25th percentile\" in https://docs.google.com/document/d/1Ft1Bnq9-t4jK5egLSOc28IL4TvR-Tt0se_1faTA4KTY/edit#heading=h.bb7nfy2x9e5v\n desktopDense4G: {\n rttMs: 40,\n throughputKbps: 10 * 1024,\n cpuSlowdownMultiplier: 1,\n requestLatencyMs: 0, // 0 means unset\n downloadThroughputKbps: 0,\n uploadThroughputKbps: 0,\n },\n};\n\nconst Constants = {throttling};\n\nexport {Constants};\n"]}
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/Constants.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,MAAM,8BAA8B,GAAG,IAAI,CAAC;AAC5C,MAAM,qCAAqC,GAAG,GAAG,CAAC;AAgClD,MAAM,UAAU,GAAuB;IACrC,8BAA8B;IAC9B,qCAAqC;IACrC,gEAAgE;IAChE,sFAAsF;IACtF,YAAY,EAAE;QACZ,KAAK,EAAE,GAAG;QACV,cAAc,EAAE,GAAG,GAAG,IAAI;QAC1B,gBAAgB,EAAE,GAAG,GAAG,8BAA8B;QACtD,sBAAsB,EAAE,GAAG,GAAG,IAAI,GAAG,qCAAqC;QAC1E,oBAAoB,EAAE,GAAG,GAAG,qCAAqC;QACjE,qBAAqB,EAAE,CAAC;KACzB;IACD,8EAA8E;IAC9E,gGAAgG;IAChG,iEAAiE;IACjE,eAAe,EAAE;QACf,KAAK,EAAE,GAAG;QACV,cAAc,EAAE,GAAG;QACnB,gBAAgB,EAAE,GAAG,GAAG,8BAA8B;QACtD,sBAAsB,EAAE,GAAG,GAAG,qCAAqC;QACnE,oBAAoB,EAAE,GAAG,GAAG,qCAAqC;QACjE,qBAAqB,EAAE,CAAC;KACzB;IACD,sCAAsC;IACtC,2JAA2J;IAC3J,cAAc,EAAE;QACd,KAAK,EAAE,EAAE;QACT,cAAc,EAAE,EAAE,GAAG,IAAI;QACzB,qBAAqB,EAAE,CAAC;QACxB,gBAAgB,EAAE,CAAC,EAAG,gBAAgB;QACtC,sBAAsB,EAAE,CAAC;QACzB,oBAAoB,EAAE,CAAC;KACxB;CACF,CAAC;AAEF,MAAM,SAAS,GAAqC;IAClD,UAAU;CACX,CAAC;AAEF,OAAO,EAAC,SAAS,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nconst DEVTOOLS_RTT_ADJUSTMENT_FACTOR = 3.75;\nconst DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR = 0.9;\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport interface ThrottlingSettings {\n DEVTOOLS_RTT_ADJUSTMENT_FACTOR: number;\n DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR: number;\n mobileSlow4G: {\n rttMs: number,\n throughputKbps: number,\n requestLatencyMs: number,\n downloadThroughputKbps: number,\n uploadThroughputKbps: number,\n cpuSlowdownMultiplier: number,\n };\n mobileRegular3G: {\n rttMs: number,\n throughputKbps: number,\n requestLatencyMs: number,\n downloadThroughputKbps: number,\n uploadThroughputKbps: number,\n cpuSlowdownMultiplier: number,\n };\n desktopDense4G: {\n rttMs: number,\n throughputKbps: number,\n cpuSlowdownMultiplier: number,\n requestLatencyMs: number,\n downloadThroughputKbps: number,\n uploadThroughputKbps: number,\n };\n}\n\nconst throttling: ThrottlingSettings = {\n DEVTOOLS_RTT_ADJUSTMENT_FACTOR,\n DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n // These values align with WebPageTest's definition of \"Fast 3G\"\n // But offer similar characteristics to roughly the 75th percentile of 4G connections.\n mobileSlow4G: {\n rttMs: 150,\n throughputKbps: 1.6 * 1024,\n requestLatencyMs: 150 * DEVTOOLS_RTT_ADJUSTMENT_FACTOR,\n downloadThroughputKbps: 1.6 * 1024 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n uploadThroughputKbps: 750 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n cpuSlowdownMultiplier: 4,\n },\n // These values partially align with WebPageTest's definition of \"Regular 3G\".\n // These values are meant to roughly align with Chrome UX report's 3G definition which are based\n // on HTTP RTT of 300-1400ms and downlink throughput of <700kbps.\n mobileRegular3G: {\n rttMs: 300,\n throughputKbps: 700,\n requestLatencyMs: 300 * DEVTOOLS_RTT_ADJUSTMENT_FACTOR,\n downloadThroughputKbps: 700 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n uploadThroughputKbps: 700 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,\n cpuSlowdownMultiplier: 4,\n },\n // Using a \"broadband\" connection type\n // Corresponds to \"Dense 4G 25th percentile\" in https://docs.google.com/document/d/1Ft1Bnq9-t4jK5egLSOc28IL4TvR-Tt0se_1faTA4KTY/edit#heading=h.bb7nfy2x9e5v\n desktopDense4G: {\n rttMs: 40,\n throughputKbps: 10 * 1024,\n cpuSlowdownMultiplier: 1,\n requestLatencyMs: 0, // 0 means unset\n downloadThroughputKbps: 0,\n uploadThroughputKbps: 0,\n },\n};\n\nconst Constants: {throttling: ThrottlingSettings} = {\n throttling,\n};\n\nexport {Constants};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DNSCache.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/DNSCache.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAI7B,wGAAwG;AACxG,yHAAyH;AACzH,yHAAyH;AACzH,mGAAmG;AACnG,oGAAoG;AACpG,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAExC,MAAM,QAAQ;IACZ,MAAM,CAAC,aAAa,GAAG,6BAA6B,CAAC;IAErD,GAAG,CAAS;IACZ,mBAAmB,CAAoC;IAEvD,YAAY,EAAC,GAAG,EAAgB;QAC9B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;IACvC,CAAC;IAED,sBAAsB,CAClB,OAA+B,EAAE,OAA6D;QAChG,MAAM,EAAC,WAAW,GAAG,CAAC,EAAE,iBAAiB,GAAG,KAAK,EAAC,GAAG,OAAO,IAAI,EAAE,CAAC;QAEnE,MAAM,MAAM,GAAG,OAAO,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a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Lantern from '../types/types.js';\n\n// A DNS lookup will usually take ~1-2 roundtrips of connection latency plus the extra DNS routing time.\n// Example: https://www.webpagetest.org/result/180703_3A_e33ec79747c002ed4d7bcbfc81462203/1/details/#waterfall_view_step1\n// Example: https://www.webpagetest.org/result/180707_1M_89673eb633b5d98386de95dfcf9b33d5/1/details/#waterfall_view_step1\n// DNS is highly variable though, many times it's a little more than 1, but can easily be 4-5x RTT.\n// We'll use 2 since it seems to give the most accurate results on average, but this can be tweaked.\nconst DNS_RESOLUTION_RTT_MULTIPLIER = 2;\n\nclass DNSCache {\n static rttMultiplier = DNS_RESOLUTION_RTT_MULTIPLIER;\n\n rtt: number;\n resolvedDomainNames: Map<string, {resolvedAt: number}>;\n\n constructor({rtt}: {rtt: number}) {\n this.rtt = rtt;\n this.resolvedDomainNames = new Map();\n }\n\n getTimeUntilResolution(\n request: Lantern.NetworkRequest, options?: {requestedAt?: number, shouldUpdateCache?: boolean}): number {\n const {requestedAt = 0, shouldUpdateCache = false} = options || {};\n\n const domain = request.parsedURL.host;\n const cacheEntry = this.resolvedDomainNames.get(domain);\n let timeUntilResolved = this.rtt * DNSCache.rttMultiplier;\n if (cacheEntry) {\n const timeUntilCachedIsResolved = Math.max(cacheEntry.resolvedAt - requestedAt, 0);\n timeUntilResolved = Math.min(timeUntilCachedIsResolved, timeUntilResolved);\n }\n\n const resolvedAt = requestedAt + timeUntilResolved;\n if (shouldUpdateCache) {\n this.updateCacheResolvedAtIfNeeded(request, resolvedAt);\n }\n\n return timeUntilResolved;\n }\n\n updateCacheResolvedAtIfNeeded(request: Lantern.NetworkRequest, resolvedAt: number): void {\n const domain = request.parsedURL.host;\n const cacheEntry = this.resolvedDomainNames.get(domain) || {resolvedAt};\n cacheEntry.resolvedAt = Math.min(cacheEntry.resolvedAt, resolvedAt);\n this.resolvedDomainNames.set(domain, cacheEntry);\n }\n\n /**\n * Forcefully sets the DNS resolution time for a request.\n * Useful for testing and alternate execution simulations.\n */\n setResolvedAt(domain: string, resolvedAt: number): void {\n this.resolvedDomainNames.set(domain, {resolvedAt});\n }\n}\n\nexport {DNSCache};\n"]}
1
+ {"version":3,"file":"DNSCache.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/DNSCache.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAI7B,wGAAwG;AACxG,yHAAyH;AACzH,yHAAyH;AACzH,mGAAmG;AACnG,oGAAoG;AACpG,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAExC,MAAM,QAAQ;IACZ,MAAM,CAAC,aAAa,GAAW,6BAA6B,CAAC;IAE7D,GAAG,CAAS;IACZ,mBAAmB,CAAoC;IAEvD,YAAY,EAAC,GAAG,EAAgB;QAC9B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;IACvC,CAAC;IAED,sBAAsB,CAClB,OAA+B,EAAE,OAA6D;QAChG,MAAM,EAAC,WAAW,GAAG,CAAC,EAAE,iBAAiB,GAAG,KAAK,EAAC,GAAG,OAAO,IAAI,EAAE,CAAC;QAEnE,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxD,IAAI,iBAAiB,GAAG,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC;QAC1D,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,yBAAyB,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC;YACnF,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,iBAAiB,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,UAAU,GAAG,WAAW,GAAG,iBAAiB,CAAC;QACnD,IAAI,iBAAiB,EAAE,CAAC;YACtB,IAAI,CAAC,6BAA6B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,6BAA6B,CAAC,OAA+B,EAAE,UAAkB;QAC/E,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAC,UAAU,EAAC,CAAC;QACxE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACpE,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,MAAc,EAAE,UAAkB;QAC9C,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,EAAE,EAAC,UAAU,EAAC,CAAC,CAAC;IACrD,CAAC;CACF;AAED,OAAO,EAAC,QAAQ,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Lantern from '../types/types.js';\n\n// A DNS lookup will usually take ~1-2 roundtrips of connection latency plus the extra DNS routing time.\n// Example: https://www.webpagetest.org/result/180703_3A_e33ec79747c002ed4d7bcbfc81462203/1/details/#waterfall_view_step1\n// Example: https://www.webpagetest.org/result/180707_1M_89673eb633b5d98386de95dfcf9b33d5/1/details/#waterfall_view_step1\n// DNS is highly variable though, many times it's a little more than 1, but can easily be 4-5x RTT.\n// We'll use 2 since it seems to give the most accurate results on average, but this can be tweaked.\nconst DNS_RESOLUTION_RTT_MULTIPLIER = 2;\n\nclass DNSCache {\n static rttMultiplier: number = DNS_RESOLUTION_RTT_MULTIPLIER;\n\n rtt: number;\n resolvedDomainNames: Map<string, {resolvedAt: number}>;\n\n constructor({rtt}: {rtt: number}) {\n this.rtt = rtt;\n this.resolvedDomainNames = new Map();\n }\n\n getTimeUntilResolution(\n request: Lantern.NetworkRequest, options?: {requestedAt?: number, shouldUpdateCache?: boolean}): number {\n const {requestedAt = 0, shouldUpdateCache = false} = options || {};\n\n const domain = request.parsedURL.host;\n const cacheEntry = this.resolvedDomainNames.get(domain);\n let timeUntilResolved = this.rtt * DNSCache.rttMultiplier;\n if (cacheEntry) {\n const timeUntilCachedIsResolved = Math.max(cacheEntry.resolvedAt - requestedAt, 0);\n timeUntilResolved = Math.min(timeUntilCachedIsResolved, timeUntilResolved);\n }\n\n const resolvedAt = requestedAt + timeUntilResolved;\n if (shouldUpdateCache) {\n this.updateCacheResolvedAtIfNeeded(request, resolvedAt);\n }\n\n return timeUntilResolved;\n }\n\n updateCacheResolvedAtIfNeeded(request: Lantern.NetworkRequest, resolvedAt: number): void {\n const domain = request.parsedURL.host;\n const cacheEntry = this.resolvedDomainNames.get(domain) || {resolvedAt};\n cacheEntry.resolvedAt = Math.min(cacheEntry.resolvedAt, resolvedAt);\n this.resolvedDomainNames.set(domain, cacheEntry);\n }\n\n /**\n * Forcefully sets the DNS resolution time for a request.\n * Useful for testing and alternate execution simulations.\n */\n setResolvedAt(domain: string, resolvedAt: number): void {\n this.resolvedDomainNames.set(domain, {resolvedAt});\n }\n}\n\nexport {DNSCache};\n"]}
@@ -158,13 +158,17 @@ class Simulator {
158
158
  this.cachedNodeListByStartPosition.splice(indexOfNodeToStart, 1);
159
159
  this.nodes[NodeState.InProgress].add(node);
160
160
  this.nodes[NodeState.ReadyToStart].delete(node);
161
- this.numberInProgressByType.set(node.type, this.numberInProgress(node.type) + 1);
161
+ if (!(node.type === Graph.BaseNode.types.NETWORK && node.isConnectionless)) {
162
+ this.numberInProgressByType.set(node.type, this.numberInProgress(node.type) + 1);
163
+ }
162
164
  this.nodeTimings.setInProgress(node, { startTime });
163
165
  }
164
166
  markNodeAsComplete(node, endTime, connectionTiming) {
165
167
  this.nodes[NodeState.Complete].add(node);
166
168
  this.nodes[NodeState.InProgress].delete(node);
167
- this.numberInProgressByType.set(node.type, this.numberInProgress(node.type) - 1);
169
+ if (!(node.type === Graph.BaseNode.types.NETWORK && node.isConnectionless)) {
170
+ this.numberInProgressByType.set(node.type, this.numberInProgress(node.type) - 1);
171
+ }
168
172
  this.nodeTimings.setCompleted(node, { endTime, connectionTiming });
169
173
  // Try to add all its dependents to the queue
170
174
  for (const dependent of node.getDependents()) {
@@ -1 +1 @@
1
- {"version":3,"file":"Simulator.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/Simulator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAiD,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAOjD,MAAM,iBAAiB,GAAG,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC;AAE5D,6GAA6G;AAC7G,MAAM,mCAAmC,GAAG,EAAE,CAAC;AAC/C,6FAA6F;AAC7F,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAC3C,gHAAgH;AAChH,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAEhD,MAAM,SAAS,GAAG;IAChB,eAAe,EAAE,CAAC;IAClB,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,wBAAwB,G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CAAC,SAAS,CAAC;QACxB,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF;AAED,OAAO,EAAC,SAAS,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Core from '../core/core.js';\nimport * as Graph from '../graph/graph.js';\nimport type * as Lantern from '../types/types.js';\n\nimport {ConnectionPool} from './ConnectionPool.js';\nimport {Constants} from './Constants.js';\nimport {DNSCache} from './DNSCache.js';\nimport {type CompleteNodeTiming, type ConnectionTiming, SimulatorTimingMap} from './SimulationTimingMap.js';\nimport {TCPConnection} from './TCPConnection.js';\n\nexport interface Result<T = Lantern.AnyNetworkObject> {\n timeInMs: number;\n nodeTimings: Map<Graph.Node<T>, Lantern.Simulation.NodeTiming>;\n}\n\nconst defaultThrottling = Constants.throttling.mobileSlow4G;\n\n// see https://cs.chromium.org/search/?q=kDefaultMaxNumDelayableRequestsPerClient&sq=package:chromium&type=cs\nconst DEFAULT_MAXIMUM_CONCURRENT_REQUESTS = 10;\n// layout tasks tend to be less CPU-bound and do not experience the same increase in duration\nconst DEFAULT_LAYOUT_TASK_MULTIPLIER = 0.5;\n// if a task takes more than 10 seconds it's usually a sign it isn't actually CPU bound and we're overestimating\nconst DEFAULT_MAXIMUM_CPU_TASK_DURATION = 10000;\n\nconst NodeState = {\n NotReadyToStart: 0,\n ReadyToStart: 1,\n InProgress: 2,\n Complete: 3,\n};\n\nconst PriorityStartTimePenalty: Record<Lantern.ResourcePriority, number> = {\n VeryHigh: 0,\n High: 0.25,\n Medium: 0.5,\n Low: 1,\n VeryLow: 2,\n};\n\nconst ALL_SIMULATION_NODE_TIMINGS = new Map<string, Map<Graph.Node, CompleteNodeTiming>>();\n\nclass Simulator<T = Lantern.AnyNetworkObject> {\n static createSimulator(settings: Lantern.Simulation.Settings): Simulator {\n const {throttlingMethod, throttling, precomputedLanternData, networkAnalysis} = settings;\n\n const options: Lantern.Simulation.Options = {\n additionalRttByOrigin: networkAnalysis.additionalRttByOrigin,\n serverResponseTimeByOrigin: networkAnalysis.serverResponseTimeByOrigin,\n observedThroughput: networkAnalysis.throughput,\n };\n\n // If we have precomputed lantern data, overwrite our observed estimates and use precomputed instead\n // for increased stability.\n if (precomputedLanternData) {\n options.additionalRttByOrigin = new Map(Object.entries(precomputedLanternData.additionalRttByOrigin));\n options.serverResponseTimeByOrigin = new Map(Object.entries(precomputedLanternData.serverResponseTimeByOrigin));\n }\n\n switch (throttlingMethod) {\n case 'provided':\n options.rtt = networkAnalysis.rtt;\n options.throughput = networkAnalysis.throughput;\n options.cpuSlowdownMultiplier = 1;\n options.layoutTaskMultiplier = 1;\n break;\n case 'devtools':\n if (throttling) {\n options.rtt = throttling.requestLatencyMs / Constants.throttling.DEVTOOLS_RTT_ADJUSTMENT_FACTOR;\n options.throughput =\n throttling.downloadThroughputKbps * 1024 / Constants.throttling.DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR;\n }\n\n options.cpuSlowdownMultiplier = 1;\n options.layoutTaskMultiplier = 1;\n break;\n case 'simulate':\n if (throttling) {\n options.rtt = throttling.rttMs;\n options.throughput = throttling.throughputKbps * 1024;\n options.cpuSlowdownMultiplier = throttling.cpuSlowdownMultiplier;\n }\n break;\n default:\n // intentionally fallback to simulator defaults\n break;\n }\n\n return new Simulator(options);\n }\n\n options: Required<Lantern.Simulation.Options>;\n _rtt: number;\n throughput: number;\n maximumConcurrentRequests: number;\n cpuSlowdownMultiplier: number;\n layoutTaskMultiplier: number;\n cachedNodeListByStartPosition: Graph.Node[];\n nodeTimings: SimulatorTimingMap;\n numberInProgressByType: Map<string, number>;\n nodes: Record<number, Set<Graph.Node>>;\n dns: DNSCache;\n connectionPool: ConnectionPool;\n\n constructor(options?: Lantern.Simulation.Options) {\n this.options = Object.assign(\n {\n rtt: defaultThrottling.rttMs,\n throughput: defaultThrottling.throughputKbps * 1024,\n maximumConcurrentRequests: DEFAULT_MAXIMUM_CONCURRENT_REQUESTS,\n cpuSlowdownMultiplier: defaultThrottling.cpuSlowdownMultiplier,\n layoutTaskMultiplier: DEFAULT_LAYOUT_TASK_MULTIPLIER,\n additionalRttByOrigin: new Map(),\n serverResponseTimeByOrigin: new Map(),\n },\n options,\n );\n\n this._rtt = this.options.rtt;\n this.throughput = this.options.throughput;\n this.maximumConcurrentRequests = Math.max(\n Math.min(\n TCPConnection.maximumSaturatedConnections(this._rtt, this.throughput),\n this.options.maximumConcurrentRequests,\n ),\n 1);\n this.cpuSlowdownMultiplier = this.options.cpuSlowdownMultiplier;\n this.layoutTaskMultiplier = this.cpuSlowdownMultiplier * this.options.layoutTaskMultiplier;\n this.cachedNodeListByStartPosition = [];\n\n // Properties reset on every `.simulate` call but duplicated here for type checking\n this.nodeTimings = new SimulatorTimingMap();\n this.numberInProgressByType = new Map<string, number>();\n this.nodes = {};\n this.dns = new DNSCache({rtt: this._rtt});\n // @ts-expect-error\n this.connectionPool = null;\n\n if (!Number.isFinite(this._rtt)) {\n throw new Core.LanternError(`Invalid rtt ${this._rtt}`);\n }\n if (!Number.isFinite(this.throughput)) {\n throw new Core.LanternError(`Invalid throughput ${this.throughput}`);\n }\n }\n\n get rtt(): number {\n return this._rtt;\n }\n\n initializeConnectionPool(graph: Graph.Node): void {\n const records: Lantern.NetworkRequest[] = [];\n graph.getRootNode().traverse(node => {\n if (node.type === Graph.BaseNode.types.NETWORK) {\n records.push(node.request);\n }\n });\n\n this.connectionPool = new ConnectionPool(records, this.options);\n }\n\n /**\n * Initializes the various state data structures such _nodeTimings and the _node Sets by state.\n */\n initializeAuxiliaryData(): void {\n this.nodeTimings = new SimulatorTimingMap();\n this.numberInProgressByType = new Map();\n\n this.nodes = {};\n this.cachedNodeListByStartPosition = [];\n // NOTE: We don't actually need *all* of these sets, but the clarity that each node progresses\n // through the system is quite nice.\n for (const state of Object.values(NodeState)) {\n this.nodes[state] = new Set();\n }\n }\n\n numberInProgress(type: string): number {\n return this.numberInProgressByType.get(type) || 0;\n }\n\n markNodeAsReadyToStart(node: Graph.Node, queuedTime: number): void {\n const nodeStartPosition = Simulator.computeNodeStartPosition(node);\n const firstNodeIndexWithGreaterStartPosition = this.cachedNodeListByStartPosition.findIndex(\n candidate => Simulator.computeNodeStartPosition(candidate) > nodeStartPosition);\n const insertionIndex = firstNodeIndexWithGreaterStartPosition === -1 ? this.cachedNodeListByStartPosition.length :\n firstNodeIndexWithGreaterStartPosition;\n this.cachedNodeListByStartPosition.splice(insertionIndex, 0, node);\n\n this.nodes[NodeState.ReadyToStart].add(node);\n this.nodes[NodeState.NotReadyToStart].delete(node);\n this.nodeTimings.setReadyToStart(node, {queuedTime});\n }\n\n markNodeAsInProgress(node: Graph.Node, startTime: number): void {\n const indexOfNodeToStart = this.cachedNodeListByStartPosition.indexOf(node);\n this.cachedNodeListByStartPosition.splice(indexOfNodeToStart, 1);\n\n this.nodes[NodeState.InProgress].add(node);\n this.nodes[NodeState.ReadyToStart].delete(node);\n this.numberInProgressByType.set(node.type, this.numberInProgress(node.type) + 1);\n this.nodeTimings.setInProgress(node, {startTime});\n }\n\n markNodeAsComplete(node: Graph.Node, endTime: number, connectionTiming?: ConnectionTiming): void {\n this.nodes[NodeState.Complete].add(node);\n this.nodes[NodeState.InProgress].delete(node);\n this.numberInProgressByType.set(node.type, this.numberInProgress(node.type) - 1);\n this.nodeTimings.setCompleted(node, {endTime, connectionTiming});\n\n // Try to add all its dependents to the queue\n for (const dependent of node.getDependents()) {\n // Skip dependent node if one of its dependencies hasn't finished yet\n const dependencies = dependent.getDependencies();\n if (dependencies.some(dep => !this.nodes[NodeState.Complete].has(dep))) {\n continue;\n }\n\n // Otherwise add it to the queue\n this.markNodeAsReadyToStart(dependent, endTime);\n }\n }\n\n acquireConnection(request: Lantern.NetworkRequest): TCPConnection|null {\n return this.connectionPool.acquire(request);\n }\n\n getNodesSortedByStartPosition(): Graph.Node[] {\n // Make a copy so we don't skip nodes due to concurrent modification\n return Array.from(this.cachedNodeListByStartPosition);\n }\n\n startNodeIfPossible(node: Graph.Node, totalElapsedTime: number): void {\n if (node.type === Graph.BaseNode.types.CPU) {\n // Start a CPU task if there's no other CPU task in process\n if (this.numberInProgress(node.type) === 0) {\n this.markNodeAsInProgress(node, totalElapsedTime);\n }\n\n return;\n }\n\n if (node.type !== Graph.BaseNode.types.NETWORK) {\n throw new Core.LanternError('Unsupported');\n }\n\n // If a network request is connectionless, we can always start it, so skip the connection checks\n if (!node.isConnectionless) {\n // Start a network request if we're not at max requests and a connection is available\n const numberOfActiveRequests = this.numberInProgress(node.type);\n if (numberOfActiveRequests >= this.maximumConcurrentRequests) {\n return;\n }\n const connection = this.acquireConnection(node.request);\n if (!connection) {\n return;\n }\n }\n\n this.markNodeAsInProgress(node, totalElapsedTime);\n }\n\n /**\n * Updates each connection in use with the available throughput based on the number of network requests\n * currently in flight.\n */\n updateNetworkCapacity(): void {\n const inFlight = this.numberInProgress(Graph.BaseNode.types.NETWORK);\n if (inFlight === 0) {\n return;\n }\n\n for (const connection of this.connectionPool.connectionsInUse()) {\n connection.setThroughput(this.throughput / inFlight);\n }\n }\n\n /**\n * Estimates the number of milliseconds remaining given current conditions before the node is complete.\n */\n estimateTimeRemaining(node: Graph.Node): number {\n if (node.type === Graph.BaseNode.types.CPU) {\n return this.estimateCPUTimeRemaining(node);\n }\n if (node.type === Graph.BaseNode.types.NETWORK) {\n return this.estimateNetworkTimeRemaining(node);\n }\n throw new Core.LanternError('Unsupported');\n }\n\n estimateCPUTimeRemaining(cpuNode: Graph.CPUNode): number {\n const timingData = this.nodeTimings.getCpuStarted(cpuNode);\n const multiplier = cpuNode.didPerformLayout() ? this.layoutTaskMultiplier : this.cpuSlowdownMultiplier;\n const totalDuration = Math.min(\n Math.round(cpuNode.duration / 1000 * multiplier),\n DEFAULT_MAXIMUM_CPU_TASK_DURATION,\n );\n const estimatedTimeElapsed = totalDuration - timingData.timeElapsed;\n this.nodeTimings.setCpuEstimated(cpuNode, {estimatedTimeElapsed});\n return estimatedTimeElapsed;\n }\n\n estimateNetworkTimeRemaining(networkNode: Graph.NetworkNode): number {\n const request = networkNode.request;\n const timingData = this.nodeTimings.getNetworkStarted(networkNode);\n\n let timeElapsed = 0;\n if (networkNode.fromDiskCache) {\n // Rough access time for seeking to location on disk and reading sequentially.\n // 8ms per seek + 20ms/MB\n // @see http://norvig.com/21-days.html#answers\n const sizeInMb = (request.resourceSize || 0) / 1024 / 1024;\n timeElapsed = 8 + 20 * sizeInMb - timingData.timeElapsed;\n } else if (networkNode.isNonNetworkProtocol) {\n // Estimates for the overhead of a data URL in Chromium and the decoding time for base64-encoded data.\n // 2ms per request + 10ms/MB\n // @see traces on https://dopiaza.org/tools/datauri/examples/index.php\n const sizeInMb = (request.resourceSize || 0) / 1024 / 1024;\n timeElapsed = 2 + 10 * sizeInMb - timingData.timeElapsed;\n } else {\n const connection = this.connectionPool.acquireActiveConnectionFromRequest(request);\n const dnsResolutionTime = this.dns.getTimeUntilResolution(request, {\n requestedAt: timingData.startTime,\n shouldUpdateCache: true,\n });\n const timeAlreadyElapsed = timingData.timeElapsed;\n const calculation = connection.simulateDownloadUntil(\n request.transferSize - timingData.bytesDownloaded,\n {timeAlreadyElapsed, dnsResolutionTime, maximumTimeToElapse: Infinity},\n );\n\n timeElapsed = calculation.timeElapsed;\n }\n\n const estimatedTimeElapsed = timeElapsed + timingData.timeElapsedOvershoot;\n this.nodeTimings.setNetworkEstimated(networkNode, {estimatedTimeElapsed});\n return estimatedTimeElapsed;\n }\n\n /**\n * Computes and returns the minimum estimated completion time of the nodes currently in progress.\n */\n findNextNodeCompletionTime(): number {\n let minimumTime = Infinity;\n for (const node of this.nodes[NodeState.InProgress]) {\n minimumTime = Math.min(minimumTime, this.estimateTimeRemaining(node));\n }\n\n return minimumTime;\n }\n\n /**\n * Given a time period, computes the progress toward completion that the node made during that time.\n */\n updateProgressMadeInTimePeriod(node: Graph.Node, timePeriodLength: number, totalElapsedTime: number): void {\n const timingData = this.nodeTimings.getInProgress(node);\n const isFinished = timingData.estimatedTimeElapsed === timePeriodLength;\n\n if (node.type === Graph.BaseNode.types.CPU || node.isConnectionless) {\n if (isFinished) {\n this.markNodeAsComplete(node, totalElapsedTime);\n } else {\n timingData.timeElapsed += timePeriodLength;\n }\n return;\n }\n\n if (node.type !== Graph.BaseNode.types.NETWORK) {\n throw new Core.LanternError('Unsupported');\n }\n if (!('bytesDownloaded' in timingData)) {\n throw new Core.LanternError('Invalid timing data');\n }\n\n const request = node.request;\n const connection = this.connectionPool.acquireActiveConnectionFromRequest(request);\n const dnsResolutionTime = this.dns.getTimeUntilResolution(request, {\n requestedAt: timingData.startTime,\n shouldUpdateCache: true,\n });\n const calculation = connection.simulateDownloadUntil(\n request.transferSize - timingData.bytesDownloaded,\n {\n dnsResolutionTime,\n timeAlreadyElapsed: timingData.timeElapsed,\n maximumTimeToElapse: timePeriodLength - timingData.timeElapsedOvershoot,\n },\n );\n\n connection.setCongestionWindow(calculation.congestionWindow);\n connection.setH2OverflowBytesDownloaded(calculation.extraBytesDownloaded);\n\n if (isFinished) {\n connection.setWarmed(true);\n this.connectionPool.release(request);\n this.markNodeAsComplete(node, totalElapsedTime, calculation.connectionTiming);\n } else {\n timingData.timeElapsed += calculation.timeElapsed;\n timingData.timeElapsedOvershoot += calculation.timeElapsed - timePeriodLength;\n timingData.bytesDownloaded += calculation.bytesDownloaded;\n }\n }\n\n computeFinalNodeTimings(): {\n nodeTimings: Map<Graph.Node, Lantern.Simulation.NodeTiming>,\n completeNodeTimings: Map<Graph.Node, CompleteNodeTiming>,\n } {\n const completeNodeTimingEntries: Array<[Graph.Node, CompleteNodeTiming]> = this.nodeTimings.getNodes().map(node => {\n return [node, this.nodeTimings.getCompleted(node)];\n });\n\n // Most consumers will want the entries sorted by startTime, so insert them in that order\n completeNodeTimingEntries.sort((a, b) => a[1].startTime - b[1].startTime);\n\n // Trimmed version of type `Lantern.Simulation.NodeTiming`.\n const nodeTimingEntries: Array<[Graph.Node, Lantern.Simulation.NodeTiming]> =\n completeNodeTimingEntries.map(([node, timing]) => {\n return [\n node,\n {\n startTime: timing.startTime,\n endTime: timing.endTime,\n duration: timing.endTime - timing.startTime,\n },\n ];\n });\n\n return {\n nodeTimings: new Map(nodeTimingEntries),\n completeNodeTimings: new Map(completeNodeTimingEntries),\n };\n }\n\n getOptions(): Required<Lantern.Simulation.Options> {\n return this.options;\n }\n\n /**\n * Estimates the time taken to process all of the graph's nodes, returns the overall time along with\n * each node annotated by start/end times.\n *\n * Simulator/connection pool are allowed to deviate from what was\n * observed in the trace/devtoolsLog and start requests as soon as they are queued (i.e. do not\n * wait around for a warm connection to be available if the original request was fetched on a warm\n * connection).\n */\n simulate(graph: Graph.Node, options?: {label?: string}): Result<T> {\n if (Graph.BaseNode.findCycle(graph)) {\n throw new Core.LanternError('Cannot simulate graph with cycle');\n }\n\n options = Object.assign(\n {\n label: undefined,\n },\n options);\n\n // initialize the necessary data containers\n this.dns = new DNSCache({rtt: this._rtt});\n this.initializeConnectionPool(graph);\n this.initializeAuxiliaryData();\n\n const nodesNotReadyToStart = this.nodes[NodeState.NotReadyToStart];\n const nodesReadyToStart = this.nodes[NodeState.ReadyToStart];\n const nodesInProgress = this.nodes[NodeState.InProgress];\n\n const rootNode = graph.getRootNode();\n rootNode.traverse(node => nodesNotReadyToStart.add(node));\n let totalElapsedTime = 0;\n let iteration = 0;\n\n // root node is always ready to start\n this.markNodeAsReadyToStart(rootNode, totalElapsedTime);\n\n // loop as long as we have nodes in the queue or currently in progress\n while (nodesReadyToStart.size || nodesInProgress.size) {\n // move all possible queued nodes to in progress\n for (const node of this.getNodesSortedByStartPosition()) {\n this.startNodeIfPossible(node, totalElapsedTime);\n }\n\n if (!nodesInProgress.size) {\n // Interplay between fromDiskCache and connectionReused can be incorrect,\n // have to give up.\n throw new Core.LanternError('Failed to start a node');\n }\n\n // set the available throughput for all connections based on # in-flight\n this.updateNetworkCapacity();\n\n // find the time that the next node will finish\n const minimumTime = this.findNextNodeCompletionTime();\n totalElapsedTime += minimumTime;\n\n // While this is no longer strictly necessary, it's always better than hanging\n if (!Number.isFinite(minimumTime) || iteration > 100000) {\n throw new Core.LanternError('Simulation failed, depth exceeded');\n }\n\n iteration++;\n // update how far each node will progress until that point\n for (const node of nodesInProgress) {\n this.updateProgressMadeInTimePeriod(node, minimumTime, totalElapsedTime);\n }\n }\n\n // `nodeTimings` are used for simulator consumers, `completeNodeTimings` kept for debugging.\n const {nodeTimings, completeNodeTimings} = this.computeFinalNodeTimings();\n ALL_SIMULATION_NODE_TIMINGS.set(options.label || 'unlabeled', completeNodeTimings);\n\n return {\n timeInMs: totalElapsedTime,\n nodeTimings,\n };\n }\n\n computeWastedMsFromWastedBytes(wastedBytes: number): number {\n const {throughput, observedThroughput} = this.options;\n\n // https://github.com/GoogleChrome/lighthouse/pull/13323#issuecomment-962031709\n // 0 throughput means the no (additional) throttling is expected.\n // This is common for desktop + devtools throttling where throttling is additive and we don't want any additional.\n const bitsPerSecond = throughput === 0 ? observedThroughput : throughput;\n if (bitsPerSecond === 0) {\n return 0;\n }\n\n const wastedBits = wastedBytes * 8;\n const wastedMs = wastedBits / bitsPerSecond * 1000;\n\n // This is an estimate of wasted time, so we won't be more precise than 10ms.\n return Math.round(wastedMs / 10) * 10;\n }\n\n // Used by Lighthouse asset-saver\n static get allNodeTimings(): Map<string, Map<Graph.Node, CompleteNodeTiming>> {\n return ALL_SIMULATION_NODE_TIMINGS;\n }\n\n /**\n * We attempt to start nodes by their observed start time using the request priority as a tie breaker.\n * When simulating, just because a low priority image started 5ms before a high priority image doesn't mean\n * it would have happened like that when the network was slower.\n */\n static computeNodeStartPosition(node: Graph.Node): number {\n if (node.type === 'cpu') {\n return node.startTime;\n }\n return node.startTime + (PriorityStartTimePenalty[node.request.priority] * 1000 * 1000 || 0);\n }\n}\n\nexport {Simulator};\n"]}
1
+ {"version":3,"file":"Simulator.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/Simulator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAiD,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAOjD,MAAM,iBAAiB,GAAG,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC;AAE5D,6GAA6G;AAC7G,MAAM,mCAAmC,GAAG,EAAE,CAAC;AAC/C,6FAA6F;AAC7F,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAC3C,gHAAgH;AAChH,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAEhD,MAAM,SAAS,GAAG;IAChB,eAAe,EAAE,CAAC;IAClB,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,wBAAwB,GAA6C;IACzE,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,GAAG;IACX,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,MAAM,2BAA2B,GAAG,IAAI,GAAG,EAA+C,CAAC;AAE3F,MAAM,SAAS;IACb,MAAM,CAAC,eAAe,CAAC,QAAqC;QAC1D,MAAM,EAAC,gBAAgB,EAAE,UAAU,EAAE,sBAAsB,EAAE,eAAe,EAAC,GAAG,QAAQ,CAAC;QAEz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IAAI,CAAC,SAAS,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF;AAED,OAAO,EAAC,SAAS,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Core from '../core/core.js';\nimport * as Graph from '../graph/graph.js';\nimport type * as Lantern from '../types/types.js';\n\nimport {ConnectionPool} from './ConnectionPool.js';\nimport {Constants} from './Constants.js';\nimport {DNSCache} from './DNSCache.js';\nimport {type CompleteNodeTiming, type ConnectionTiming, SimulatorTimingMap} from './SimulationTimingMap.js';\nimport {TCPConnection} from './TCPConnection.js';\n\nexport interface Result<T = Lantern.AnyNetworkObject> {\n timeInMs: number;\n nodeTimings: Map<Graph.Node<T>, Lantern.Simulation.NodeTiming>;\n}\n\nconst defaultThrottling = Constants.throttling.mobileSlow4G;\n\n// see https://cs.chromium.org/search/?q=kDefaultMaxNumDelayableRequestsPerClient&sq=package:chromium&type=cs\nconst DEFAULT_MAXIMUM_CONCURRENT_REQUESTS = 10;\n// layout tasks tend to be less CPU-bound and do not experience the same increase in duration\nconst DEFAULT_LAYOUT_TASK_MULTIPLIER = 0.5;\n// if a task takes more than 10 seconds it's usually a sign it isn't actually CPU bound and we're overestimating\nconst DEFAULT_MAXIMUM_CPU_TASK_DURATION = 10000;\n\nconst NodeState = {\n NotReadyToStart: 0,\n ReadyToStart: 1,\n InProgress: 2,\n Complete: 3,\n};\n\nconst PriorityStartTimePenalty: Record<Lantern.ResourcePriority, number> = {\n VeryHigh: 0,\n High: 0.25,\n Medium: 0.5,\n Low: 1,\n VeryLow: 2,\n};\n\nconst ALL_SIMULATION_NODE_TIMINGS = new Map<string, Map<Graph.Node, CompleteNodeTiming>>();\n\nclass Simulator<T = Lantern.AnyNetworkObject> {\n static createSimulator(settings: Lantern.Simulation.Settings): Simulator {\n const {throttlingMethod, throttling, precomputedLanternData, networkAnalysis} = settings;\n\n const options: Lantern.Simulation.Options = {\n additionalRttByOrigin: networkAnalysis.additionalRttByOrigin,\n serverResponseTimeByOrigin: networkAnalysis.serverResponseTimeByOrigin,\n observedThroughput: networkAnalysis.throughput,\n };\n\n // If we have precomputed lantern data, overwrite our observed estimates and use precomputed instead\n // for increased stability.\n if (precomputedLanternData) {\n options.additionalRttByOrigin = new Map(Object.entries(precomputedLanternData.additionalRttByOrigin));\n options.serverResponseTimeByOrigin = new Map(Object.entries(precomputedLanternData.serverResponseTimeByOrigin));\n }\n\n switch (throttlingMethod) {\n case 'provided':\n options.rtt = networkAnalysis.rtt;\n options.throughput = networkAnalysis.throughput;\n options.cpuSlowdownMultiplier = 1;\n options.layoutTaskMultiplier = 1;\n break;\n case 'devtools':\n if (throttling) {\n options.rtt = throttling.requestLatencyMs / Constants.throttling.DEVTOOLS_RTT_ADJUSTMENT_FACTOR;\n options.throughput =\n throttling.downloadThroughputKbps * 1024 / Constants.throttling.DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR;\n }\n\n options.cpuSlowdownMultiplier = 1;\n options.layoutTaskMultiplier = 1;\n break;\n case 'simulate':\n if (throttling) {\n options.rtt = throttling.rttMs;\n options.throughput = throttling.throughputKbps * 1024;\n options.cpuSlowdownMultiplier = throttling.cpuSlowdownMultiplier;\n }\n break;\n default:\n // intentionally fallback to simulator defaults\n break;\n }\n\n return new Simulator(options);\n }\n\n options: Required<Lantern.Simulation.Options>;\n _rtt: number;\n throughput: number;\n maximumConcurrentRequests: number;\n cpuSlowdownMultiplier: number;\n layoutTaskMultiplier: number;\n cachedNodeListByStartPosition: Graph.Node[];\n nodeTimings: SimulatorTimingMap;\n numberInProgressByType: Map<string, number>;\n nodes: Record<number, Set<Graph.Node>>;\n dns: DNSCache;\n connectionPool: ConnectionPool;\n\n constructor(options?: Lantern.Simulation.Options) {\n this.options = Object.assign(\n {\n rtt: defaultThrottling.rttMs,\n throughput: defaultThrottling.throughputKbps * 1024,\n maximumConcurrentRequests: DEFAULT_MAXIMUM_CONCURRENT_REQUESTS,\n cpuSlowdownMultiplier: defaultThrottling.cpuSlowdownMultiplier,\n layoutTaskMultiplier: DEFAULT_LAYOUT_TASK_MULTIPLIER,\n additionalRttByOrigin: new Map(),\n serverResponseTimeByOrigin: new Map(),\n },\n options,\n );\n\n this._rtt = this.options.rtt;\n this.throughput = this.options.throughput;\n this.maximumConcurrentRequests = Math.max(\n Math.min(\n TCPConnection.maximumSaturatedConnections(this._rtt, this.throughput),\n this.options.maximumConcurrentRequests,\n ),\n 1);\n this.cpuSlowdownMultiplier = this.options.cpuSlowdownMultiplier;\n this.layoutTaskMultiplier = this.cpuSlowdownMultiplier * this.options.layoutTaskMultiplier;\n this.cachedNodeListByStartPosition = [];\n\n // Properties reset on every `.simulate` call but duplicated here for type checking\n this.nodeTimings = new SimulatorTimingMap();\n this.numberInProgressByType = new Map<string, number>();\n this.nodes = {};\n this.dns = new DNSCache({rtt: this._rtt});\n // @ts-expect-error\n this.connectionPool = null;\n\n if (!Number.isFinite(this._rtt)) {\n throw new Core.LanternError(`Invalid rtt ${this._rtt}`);\n }\n if (!Number.isFinite(this.throughput)) {\n throw new Core.LanternError(`Invalid throughput ${this.throughput}`);\n }\n }\n\n get rtt(): number {\n return this._rtt;\n }\n\n initializeConnectionPool(graph: Graph.Node): void {\n const records: Lantern.NetworkRequest[] = [];\n graph.getRootNode().traverse(node => {\n if (node.type === Graph.BaseNode.types.NETWORK) {\n records.push(node.request);\n }\n });\n\n this.connectionPool = new ConnectionPool(records, this.options);\n }\n\n /**\n * Initializes the various state data structures such _nodeTimings and the _node Sets by state.\n */\n initializeAuxiliaryData(): void {\n this.nodeTimings = new SimulatorTimingMap();\n this.numberInProgressByType = new Map();\n\n this.nodes = {};\n this.cachedNodeListByStartPosition = [];\n // NOTE: We don't actually need *all* of these sets, but the clarity that each node progresses\n // through the system is quite nice.\n for (const state of Object.values(NodeState)) {\n this.nodes[state] = new Set();\n }\n }\n\n numberInProgress(type: string): number {\n return this.numberInProgressByType.get(type) || 0;\n }\n\n markNodeAsReadyToStart(node: Graph.Node, queuedTime: number): void {\n const nodeStartPosition = Simulator.computeNodeStartPosition(node);\n const firstNodeIndexWithGreaterStartPosition = this.cachedNodeListByStartPosition.findIndex(\n candidate => Simulator.computeNodeStartPosition(candidate) > nodeStartPosition);\n const insertionIndex = firstNodeIndexWithGreaterStartPosition === -1 ? this.cachedNodeListByStartPosition.length :\n firstNodeIndexWithGreaterStartPosition;\n this.cachedNodeListByStartPosition.splice(insertionIndex, 0, node);\n\n this.nodes[NodeState.ReadyToStart].add(node);\n this.nodes[NodeState.NotReadyToStart].delete(node);\n this.nodeTimings.setReadyToStart(node, {queuedTime});\n }\n\n markNodeAsInProgress(node: Graph.Node, startTime: number): void {\n const indexOfNodeToStart = this.cachedNodeListByStartPosition.indexOf(node);\n this.cachedNodeListByStartPosition.splice(indexOfNodeToStart, 1);\n\n this.nodes[NodeState.InProgress].add(node);\n this.nodes[NodeState.ReadyToStart].delete(node);\n if (!(node.type === Graph.BaseNode.types.NETWORK && node.isConnectionless)) {\n this.numberInProgressByType.set(node.type, this.numberInProgress(node.type) + 1);\n }\n this.nodeTimings.setInProgress(node, {startTime});\n }\n\n markNodeAsComplete(node: Graph.Node, endTime: number, connectionTiming?: ConnectionTiming): void {\n this.nodes[NodeState.Complete].add(node);\n this.nodes[NodeState.InProgress].delete(node);\n if (!(node.type === Graph.BaseNode.types.NETWORK && node.isConnectionless)) {\n this.numberInProgressByType.set(node.type, this.numberInProgress(node.type) - 1);\n }\n this.nodeTimings.setCompleted(node, {endTime, connectionTiming});\n\n // Try to add all its dependents to the queue\n for (const dependent of node.getDependents()) {\n // Skip dependent node if one of its dependencies hasn't finished yet\n const dependencies = dependent.getDependencies();\n if (dependencies.some(dep => !this.nodes[NodeState.Complete].has(dep))) {\n continue;\n }\n\n // Otherwise add it to the queue\n this.markNodeAsReadyToStart(dependent, endTime);\n }\n }\n\n acquireConnection(request: Lantern.NetworkRequest): TCPConnection|null {\n return this.connectionPool.acquire(request);\n }\n\n getNodesSortedByStartPosition(): Graph.Node[] {\n // Make a copy so we don't skip nodes due to concurrent modification\n return Array.from(this.cachedNodeListByStartPosition);\n }\n\n startNodeIfPossible(node: Graph.Node, totalElapsedTime: number): void {\n if (node.type === Graph.BaseNode.types.CPU) {\n // Start a CPU task if there's no other CPU task in process\n if (this.numberInProgress(node.type) === 0) {\n this.markNodeAsInProgress(node, totalElapsedTime);\n }\n\n return;\n }\n\n if (node.type !== Graph.BaseNode.types.NETWORK) {\n throw new Core.LanternError('Unsupported');\n }\n\n // If a network request is connectionless, we can always start it, so skip the connection checks\n if (!node.isConnectionless) {\n // Start a network request if we're not at max requests and a connection is available\n const numberOfActiveRequests = this.numberInProgress(node.type);\n if (numberOfActiveRequests >= this.maximumConcurrentRequests) {\n return;\n }\n const connection = this.acquireConnection(node.request);\n if (!connection) {\n return;\n }\n }\n\n this.markNodeAsInProgress(node, totalElapsedTime);\n }\n\n /**\n * Updates each connection in use with the available throughput based on the number of network requests\n * currently in flight.\n */\n updateNetworkCapacity(): void {\n const inFlight = this.numberInProgress(Graph.BaseNode.types.NETWORK);\n if (inFlight === 0) {\n return;\n }\n\n for (const connection of this.connectionPool.connectionsInUse()) {\n connection.setThroughput(this.throughput / inFlight);\n }\n }\n\n /**\n * Estimates the number of milliseconds remaining given current conditions before the node is complete.\n */\n estimateTimeRemaining(node: Graph.Node): number {\n if (node.type === Graph.BaseNode.types.CPU) {\n return this.estimateCPUTimeRemaining(node);\n }\n if (node.type === Graph.BaseNode.types.NETWORK) {\n return this.estimateNetworkTimeRemaining(node);\n }\n throw new Core.LanternError('Unsupported');\n }\n\n estimateCPUTimeRemaining(cpuNode: Graph.CPUNode): number {\n const timingData = this.nodeTimings.getCpuStarted(cpuNode);\n const multiplier = cpuNode.didPerformLayout() ? this.layoutTaskMultiplier : this.cpuSlowdownMultiplier;\n const totalDuration = Math.min(\n Math.round(cpuNode.duration / 1000 * multiplier),\n DEFAULT_MAXIMUM_CPU_TASK_DURATION,\n );\n const estimatedTimeElapsed = totalDuration - timingData.timeElapsed;\n this.nodeTimings.setCpuEstimated(cpuNode, {estimatedTimeElapsed});\n return estimatedTimeElapsed;\n }\n\n estimateNetworkTimeRemaining(networkNode: Graph.NetworkNode): number {\n const request = networkNode.request;\n const timingData = this.nodeTimings.getNetworkStarted(networkNode);\n\n let timeElapsed = 0;\n if (networkNode.fromDiskCache) {\n // Rough access time for seeking to location on disk and reading sequentially.\n // 8ms per seek + 20ms/MB\n // @see http://norvig.com/21-days.html#answers\n const sizeInMb = (request.resourceSize || 0) / 1024 / 1024;\n timeElapsed = 8 + 20 * sizeInMb - timingData.timeElapsed;\n } else if (networkNode.isNonNetworkProtocol) {\n // Estimates for the overhead of a data URL in Chromium and the decoding time for base64-encoded data.\n // 2ms per request + 10ms/MB\n // @see traces on https://dopiaza.org/tools/datauri/examples/index.php\n const sizeInMb = (request.resourceSize || 0) / 1024 / 1024;\n timeElapsed = 2 + 10 * sizeInMb - timingData.timeElapsed;\n } else {\n const connection = this.connectionPool.acquireActiveConnectionFromRequest(request);\n const dnsResolutionTime = this.dns.getTimeUntilResolution(request, {\n requestedAt: timingData.startTime,\n shouldUpdateCache: true,\n });\n const timeAlreadyElapsed = timingData.timeElapsed;\n const calculation = connection.simulateDownloadUntil(\n request.transferSize - timingData.bytesDownloaded,\n {timeAlreadyElapsed, dnsResolutionTime, maximumTimeToElapse: Infinity},\n );\n\n timeElapsed = calculation.timeElapsed;\n }\n\n const estimatedTimeElapsed = timeElapsed + timingData.timeElapsedOvershoot;\n this.nodeTimings.setNetworkEstimated(networkNode, {estimatedTimeElapsed});\n return estimatedTimeElapsed;\n }\n\n /**\n * Computes and returns the minimum estimated completion time of the nodes currently in progress.\n */\n findNextNodeCompletionTime(): number {\n let minimumTime = Infinity;\n for (const node of this.nodes[NodeState.InProgress]) {\n minimumTime = Math.min(minimumTime, this.estimateTimeRemaining(node));\n }\n\n return minimumTime;\n }\n\n /**\n * Given a time period, computes the progress toward completion that the node made during that time.\n */\n updateProgressMadeInTimePeriod(node: Graph.Node, timePeriodLength: number, totalElapsedTime: number): void {\n const timingData = this.nodeTimings.getInProgress(node);\n const isFinished = timingData.estimatedTimeElapsed === timePeriodLength;\n\n if (node.type === Graph.BaseNode.types.CPU || node.isConnectionless) {\n if (isFinished) {\n this.markNodeAsComplete(node, totalElapsedTime);\n } else {\n timingData.timeElapsed += timePeriodLength;\n }\n return;\n }\n\n if (node.type !== Graph.BaseNode.types.NETWORK) {\n throw new Core.LanternError('Unsupported');\n }\n if (!('bytesDownloaded' in timingData)) {\n throw new Core.LanternError('Invalid timing data');\n }\n\n const request = node.request;\n const connection = this.connectionPool.acquireActiveConnectionFromRequest(request);\n const dnsResolutionTime = this.dns.getTimeUntilResolution(request, {\n requestedAt: timingData.startTime,\n shouldUpdateCache: true,\n });\n const calculation = connection.simulateDownloadUntil(\n request.transferSize - timingData.bytesDownloaded,\n {\n dnsResolutionTime,\n timeAlreadyElapsed: timingData.timeElapsed,\n maximumTimeToElapse: timePeriodLength - timingData.timeElapsedOvershoot,\n },\n );\n\n connection.setCongestionWindow(calculation.congestionWindow);\n connection.setH2OverflowBytesDownloaded(calculation.extraBytesDownloaded);\n\n if (isFinished) {\n connection.setWarmed(true);\n this.connectionPool.release(request);\n this.markNodeAsComplete(node, totalElapsedTime, calculation.connectionTiming);\n } else {\n timingData.timeElapsed += calculation.timeElapsed;\n timingData.timeElapsedOvershoot += calculation.timeElapsed - timePeriodLength;\n timingData.bytesDownloaded += calculation.bytesDownloaded;\n }\n }\n\n computeFinalNodeTimings(): {\n nodeTimings: Map<Graph.Node, Lantern.Simulation.NodeTiming>,\n completeNodeTimings: Map<Graph.Node, CompleteNodeTiming>,\n } {\n const completeNodeTimingEntries: Array<[Graph.Node, CompleteNodeTiming]> = this.nodeTimings.getNodes().map(node => {\n return [node, this.nodeTimings.getCompleted(node)];\n });\n\n // Most consumers will want the entries sorted by startTime, so insert them in that order\n completeNodeTimingEntries.sort((a, b) => a[1].startTime - b[1].startTime);\n\n // Trimmed version of type `Lantern.Simulation.NodeTiming`.\n const nodeTimingEntries: Array<[Graph.Node, Lantern.Simulation.NodeTiming]> =\n completeNodeTimingEntries.map(([node, timing]) => {\n return [\n node,\n {\n startTime: timing.startTime,\n endTime: timing.endTime,\n duration: timing.endTime - timing.startTime,\n },\n ];\n });\n\n return {\n nodeTimings: new Map(nodeTimingEntries),\n completeNodeTimings: new Map(completeNodeTimingEntries),\n };\n }\n\n getOptions(): Required<Lantern.Simulation.Options> {\n return this.options;\n }\n\n /**\n * Estimates the time taken to process all of the graph's nodes, returns the overall time along with\n * each node annotated by start/end times.\n *\n * Simulator/connection pool are allowed to deviate from what was\n * observed in the trace/devtoolsLog and start requests as soon as they are queued (i.e. do not\n * wait around for a warm connection to be available if the original request was fetched on a warm\n * connection).\n */\n simulate(graph: Graph.Node, options?: {label?: string}): Result<T> {\n if (Graph.BaseNode.findCycle(graph)) {\n throw new Core.LanternError('Cannot simulate graph with cycle');\n }\n\n options = Object.assign(\n {\n label: undefined,\n },\n options);\n\n // initialize the necessary data containers\n this.dns = new DNSCache({rtt: this._rtt});\n this.initializeConnectionPool(graph);\n this.initializeAuxiliaryData();\n\n const nodesNotReadyToStart = this.nodes[NodeState.NotReadyToStart];\n const nodesReadyToStart = this.nodes[NodeState.ReadyToStart];\n const nodesInProgress = this.nodes[NodeState.InProgress];\n\n const rootNode = graph.getRootNode();\n rootNode.traverse(node => nodesNotReadyToStart.add(node));\n let totalElapsedTime = 0;\n let iteration = 0;\n\n // root node is always ready to start\n this.markNodeAsReadyToStart(rootNode, totalElapsedTime);\n\n // loop as long as we have nodes in the queue or currently in progress\n while (nodesReadyToStart.size || nodesInProgress.size) {\n // move all possible queued nodes to in progress\n for (const node of this.getNodesSortedByStartPosition()) {\n this.startNodeIfPossible(node, totalElapsedTime);\n }\n\n if (!nodesInProgress.size) {\n // Interplay between fromDiskCache and connectionReused can be incorrect,\n // have to give up.\n throw new Core.LanternError('Failed to start a node');\n }\n\n // set the available throughput for all connections based on # in-flight\n this.updateNetworkCapacity();\n\n // find the time that the next node will finish\n const minimumTime = this.findNextNodeCompletionTime();\n totalElapsedTime += minimumTime;\n\n // While this is no longer strictly necessary, it's always better than hanging\n if (!Number.isFinite(minimumTime) || iteration > 100000) {\n throw new Core.LanternError('Simulation failed, depth exceeded');\n }\n\n iteration++;\n // update how far each node will progress until that point\n for (const node of nodesInProgress) {\n this.updateProgressMadeInTimePeriod(node, minimumTime, totalElapsedTime);\n }\n }\n\n // `nodeTimings` are used for simulator consumers, `completeNodeTimings` kept for debugging.\n const {nodeTimings, completeNodeTimings} = this.computeFinalNodeTimings();\n ALL_SIMULATION_NODE_TIMINGS.set(options.label || 'unlabeled', completeNodeTimings);\n\n return {\n timeInMs: totalElapsedTime,\n nodeTimings,\n };\n }\n\n computeWastedMsFromWastedBytes(wastedBytes: number): number {\n const {throughput, observedThroughput} = this.options;\n\n // https://github.com/GoogleChrome/lighthouse/pull/13323#issuecomment-962031709\n // 0 throughput means the no (additional) throttling is expected.\n // This is common for desktop + devtools throttling where throttling is additive and we don't want any additional.\n const bitsPerSecond = throughput === 0 ? observedThroughput : throughput;\n if (bitsPerSecond === 0) {\n return 0;\n }\n\n const wastedBits = wastedBytes * 8;\n const wastedMs = wastedBits / bitsPerSecond * 1000;\n\n // This is an estimate of wasted time, so we won't be more precise than 10ms.\n return Math.round(wastedMs / 10) * 10;\n }\n\n // Used by Lighthouse asset-saver\n static get allNodeTimings(): Map<string, Map<Graph.Node, CompleteNodeTiming>> {\n return ALL_SIMULATION_NODE_TIMINGS;\n }\n\n /**\n * We attempt to start nodes by their observed start time using the request priority as a tie breaker.\n * When simulating, just because a low priority image started 5ms before a high priority image doesn't mean\n * it would have happened like that when the network was slower.\n */\n static computeNodeStartPosition(node: Graph.Node): number {\n if (node.type === 'cpu') {\n return node.startTime;\n }\n return node.startTime + (PriorityStartTimePenalty[node.request.priority] * 1000 * 1000 || 0);\n }\n}\n\nexport {Simulator};\n"]}
@@ -15,23 +15,23 @@ interface DownloadResults {
15
15
  declare class TCPConnection {
16
16
  warmed: boolean;
17
17
  ssl: boolean;
18
- h2: boolean;
18
+ multiplexed: boolean;
19
19
  rtt: number;
20
20
  throughput: number;
21
21
  serverLatency: number;
22
22
  _congestionWindow: number;
23
23
  h2OverflowBytesDownloaded: number;
24
- constructor(rtt: number, throughput: number, serverLatency?: number, ssl?: boolean, h2?: boolean);
24
+ constructor(rtt: number, throughput: number, serverLatency?: number, ssl?: boolean, multiplexed?: boolean);
25
25
  static maximumSaturatedConnections(rtt: number, availableThroughput: number): number;
26
26
  computeMaximumCongestionWindowInSegments(): number;
27
27
  setThroughput(throughput: number): void;
28
28
  setCongestionWindow(congestion: number): void;
29
29
  setWarmed(warmed: boolean): void;
30
- isH2(): boolean;
30
+ isMultiplexed(): boolean;
31
31
  get congestionWindow(): number;
32
32
  /**
33
33
  * Sets the number of excess bytes that are available to this connection on future downloads, only
34
- * applies to H2 connections.
34
+ * applies to multiplexed (H2/H3) connections.
35
35
  */
36
36
  setH2OverflowBytesDownloaded(bytes: number): void;
37
37
  clone(): TCPConnection;
@@ -6,16 +6,16 @@ const TCP_SEGMENT_SIZE = 1460;
6
6
  class TCPConnection {
7
7
  warmed;
8
8
  ssl;
9
- h2;
9
+ multiplexed;
10
10
  rtt;
11
11
  throughput;
12
12
  serverLatency;
13
13
  _congestionWindow;
14
14
  h2OverflowBytesDownloaded;
15
- constructor(rtt, throughput, serverLatency = 0, ssl = true, h2 = false) {
15
+ constructor(rtt, throughput, serverLatency = 0, ssl = true, multiplexed = false) {
16
16
  this.warmed = false;
17
17
  this.ssl = ssl;
18
- this.h2 = h2;
18
+ this.multiplexed = multiplexed;
19
19
  this.rtt = rtt;
20
20
  this.throughput = throughput;
21
21
  this.serverLatency = serverLatency;
@@ -44,18 +44,18 @@ class TCPConnection {
44
44
  setWarmed(warmed) {
45
45
  this.warmed = warmed;
46
46
  }
47
- isH2() {
48
- return this.h2;
47
+ isMultiplexed() {
48
+ return this.multiplexed;
49
49
  }
50
50
  get congestionWindow() {
51
51
  return this._congestionWindow;
52
52
  }
53
53
  /**
54
54
  * Sets the number of excess bytes that are available to this connection on future downloads, only
55
- * applies to H2 connections.
55
+ * applies to multiplexed (H2/H3) connections.
56
56
  */
57
57
  setH2OverflowBytesDownloaded(bytes) {
58
- if (!this.h2) {
58
+ if (!this.multiplexed) {
59
59
  return;
60
60
  }
61
61
  this.h2OverflowBytesDownloaded = bytes;
@@ -72,7 +72,7 @@ class TCPConnection {
72
72
  */
73
73
  simulateDownloadUntil(bytesToDownload, options) {
74
74
  const { timeAlreadyElapsed = 0, maximumTimeToElapse = Infinity, dnsResolutionTime = 0 } = options || {};
75
- if (this.warmed && this.h2) {
75
+ if (this.warmed && this.multiplexed) {
76
76
  bytesToDownload -= this.h2OverflowBytesDownloaded;
77
77
  }
78
78
  const twoWayLatency = this.rtt;
@@ -94,7 +94,7 @@ class TCPConnection {
94
94
  }
95
95
  let roundTrips = Math.ceil(handshakeAndRequest / twoWayLatency);
96
96
  let timeToFirstByte = handshakeAndRequest + this.serverLatency + oneWayLatency;
97
- if (this.warmed && this.h2) {
97
+ if (this.warmed && this.multiplexed) {
98
98
  timeToFirstByte = 0;
99
99
  }
100
100
  const timeElapsedForTTFB = Math.max(timeToFirstByte - timeAlreadyElapsed, 0);
@@ -118,7 +118,7 @@ class TCPConnection {
118
118
  bytesRemaining -= bytesDownloadedInWindow;
119
119
  }
120
120
  const timeElapsed = timeElapsedForTTFB + downloadTimeElapsed;
121
- const extraBytesDownloaded = this.h2 ? Math.max(totalBytesDownloaded - bytesToDownload, 0) : 0;
121
+ const extraBytesDownloaded = this.multiplexed ? Math.max(totalBytesDownloaded - bytesToDownload, 0) : 0;
122
122
  const bytesDownloaded = Math.max(Math.min(totalBytesDownloaded, bytesToDownload), 0);
123
123
  let connectionTiming;
124
124
  if (!this.warmed) {
@@ -129,8 +129,8 @@ class TCPConnection {
129
129
  timeToFirstByte,
130
130
  };
131
131
  }
132
- else if (this.h2) {
133
- // TODO: timing information currently difficult to model for warm h2 connections.
132
+ else if (this.multiplexed) {
133
+ // TODO: timing information currently difficult to model for warm h2/h3 connections.
134
134
  connectionTiming = {
135
135
  timeToFirstByte,
136
136
  };