@paulirish/trace_engine 0.0.54 → 0.0.55

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 (187) hide show
  1. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts +4 -0
  2. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts.map +1 -0
  3. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  4. package/core/platform/MimeType.d.ts +3 -2
  5. package/core/platform/MimeType.js +4 -3
  6. package/core/platform/MimeType.js.map +1 -1
  7. package/generated/protocol.d.ts +115 -16
  8. package/locales/af.json +52 -10
  9. package/locales/am.json +52 -10
  10. package/locales/ar.json +51 -9
  11. package/locales/as.json +52 -10
  12. package/locales/az.json +52 -10
  13. package/locales/be.json +52 -10
  14. package/locales/bg.json +52 -10
  15. package/locales/bn.json +52 -10
  16. package/locales/bs.json +52 -10
  17. package/locales/ca.json +52 -10
  18. package/locales/cs.json +52 -10
  19. package/locales/cy.json +52 -10
  20. package/locales/da.json +52 -10
  21. package/locales/de.json +52 -10
  22. package/locales/el.json +52 -10
  23. package/locales/en-GB.json +52 -10
  24. package/locales/en-US.json +12 -12
  25. package/locales/en-XL.json +12 -12
  26. package/locales/es-419.json +52 -10
  27. package/locales/es.json +50 -8
  28. package/locales/et.json +52 -10
  29. package/locales/eu.json +52 -10
  30. package/locales/fa.json +51 -9
  31. package/locales/fi.json +52 -10
  32. package/locales/fil.json +52 -10
  33. package/locales/fr-CA.json +52 -10
  34. package/locales/fr.json +52 -10
  35. package/locales/gl.json +52 -10
  36. package/locales/gu.json +52 -10
  37. package/locales/he.json +52 -10
  38. package/locales/hi.json +52 -10
  39. package/locales/hr.json +52 -10
  40. package/locales/hu.json +51 -9
  41. package/locales/hy.json +51 -9
  42. package/locales/id.json +52 -10
  43. package/locales/is.json +53 -11
  44. package/locales/it.json +51 -9
  45. package/locales/ja.json +52 -10
  46. package/locales/ka.json +53 -11
  47. package/locales/kk.json +51 -9
  48. package/locales/km.json +52 -10
  49. package/locales/kn.json +52 -10
  50. package/locales/ko.json +52 -10
  51. package/locales/ky.json +51 -9
  52. package/locales/lo.json +52 -10
  53. package/locales/lt.json +52 -10
  54. package/locales/lv.json +51 -9
  55. package/locales/mk.json +52 -10
  56. package/locales/ml.json +53 -11
  57. package/locales/mn.json +52 -10
  58. package/locales/mr.json +52 -10
  59. package/locales/ms.json +52 -10
  60. package/locales/my.json +51 -9
  61. package/locales/ne.json +52 -10
  62. package/locales/nl.json +52 -10
  63. package/locales/no.json +52 -10
  64. package/locales/or.json +53 -11
  65. package/locales/pa.json +53 -11
  66. package/locales/pl.json +51 -9
  67. package/locales/pt-PT.json +52 -10
  68. package/locales/pt.json +52 -10
  69. package/locales/ro.json +52 -10
  70. package/locales/ru.json +53 -11
  71. package/locales/si.json +52 -10
  72. package/locales/sk.json +51 -9
  73. package/locales/sl.json +51 -9
  74. package/locales/sq.json +52 -10
  75. package/locales/sr-Latn.json +52 -10
  76. package/locales/sr.json +52 -10
  77. package/locales/sv.json +52 -10
  78. package/locales/sw.json +51 -9
  79. package/locales/ta.json +52 -10
  80. package/locales/te.json +52 -10
  81. package/locales/th.json +51 -9
  82. package/locales/tr.json +52 -10
  83. package/locales/uk.json +52 -10
  84. package/locales/ur.json +52 -10
  85. package/locales/uz.json +51 -9
  86. package/locales/vi.json +52 -10
  87. package/locales/zh-HK.json +52 -10
  88. package/locales/zh-TW.json +51 -9
  89. package/locales/zh.json +52 -10
  90. package/locales/zu.json +52 -10
  91. package/models/cpu_profile/CPUProfileDataModel.d.ts +4 -2
  92. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
  93. package/models/cpu_profile/ProfileTreeModel.d.ts +0 -1
  94. package/models/cpu_profile/ProfileTreeModel.js +0 -2
  95. package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
  96. package/models/trace/LanternComputationData.js +7 -6
  97. package/models/trace/LanternComputationData.js.map +1 -1
  98. package/models/trace/Processor.js +23 -16
  99. package/models/trace/Processor.js.map +1 -1
  100. package/models/trace/extras/extras-tsconfig.json +0 -2
  101. package/models/trace/extras/extras.js.map +1 -1
  102. package/models/trace/handlers/MetaHandler.js +2 -0
  103. package/models/trace/handlers/MetaHandler.js.map +1 -1
  104. package/models/trace/handlers/NetworkRequestsHandler.d.ts +0 -5
  105. package/models/trace/handlers/NetworkRequestsHandler.js +0 -19
  106. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  107. package/models/trace/handlers/SamplesHandler.js +7 -2
  108. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  109. package/models/trace/handlers/ScriptsHandler.js.map +1 -1
  110. package/models/trace/helpers/SamplesIntegrator.js +8 -13
  111. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  112. package/models/trace/helpers/Trace.js +0 -7
  113. package/models/trace/helpers/Trace.js.map +1 -1
  114. package/models/trace/insights/CLSCulprits.d.ts +24 -4
  115. package/models/trace/insights/CLSCulprits.js +30 -11
  116. package/models/trace/insights/CLSCulprits.js.map +1 -1
  117. package/models/trace/insights/DocumentLatency.d.ts +2 -2
  118. package/models/trace/insights/DocumentLatency.js +2 -2
  119. package/models/trace/insights/DocumentLatency.js.map +1 -1
  120. package/models/trace/insights/NetworkDependencyTree.d.ts +31 -5
  121. package/models/trace/insights/NetworkDependencyTree.js +135 -10
  122. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  123. package/models/trace/insights/Viewport.d.ts +8 -2
  124. package/models/trace/insights/Viewport.js +16 -1
  125. package/models/trace/insights/Viewport.js.map +1 -1
  126. package/models/trace/lantern/graph/BaseNode.d.ts +5 -2
  127. package/models/trace/lantern/graph/BaseNode.js +8 -5
  128. package/models/trace/lantern/graph/BaseNode.js.map +1 -1
  129. package/models/trace/lantern/graph/PageDependencyGraph.js +46 -3
  130. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
  131. package/models/trace/lantern/simulation/Simulator.js +1 -1
  132. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  133. package/models/trace/trace-tsconfig.json +0 -1
  134. package/models/trace/trace.d.ts +1 -2
  135. package/models/trace/trace.js +1 -2
  136. package/models/trace/trace.js.map +1 -1
  137. package/models/trace/types/Extensions.d.ts +6 -1
  138. package/models/trace/types/Extensions.js.map +1 -1
  139. package/models/trace/types/File.d.ts +15 -1
  140. package/models/trace/types/File.js.map +1 -1
  141. package/models/trace/types/TraceEvents.d.ts +7 -4
  142. package/models/trace/types/TraceEvents.js +4 -3
  143. package/models/trace/types/TraceEvents.js.map +1 -1
  144. package/package.json +1 -1
  145. package/core/platform/ServerTiming.d.ts +0 -31
  146. package/core/platform/ServerTiming.js +0 -212
  147. package/core/platform/ServerTiming.js.map +0 -1
  148. package/models/trace/TracingManager.js.map +0 -1
  149. package/models/trace/extras/FetchNodes.d.ts +0 -61
  150. package/models/trace/extras/FetchNodes.js +0 -214
  151. package/models/trace/extras/FetchNodes.js.map +0 -1
  152. package/models/trace/extras/Metadata.d.ts +0 -3
  153. package/models/trace/extras/Metadata.js +0 -71
  154. package/models/trace/extras/Metadata.js.map +0 -1
  155. package/models/trace/extras/TimelineJSProfile.d.ts +0 -13
  156. package/models/trace/extras/TimelineJSProfile.js +0 -55
  157. package/models/trace/extras/TimelineJSProfile.js.map +0 -1
  158. package/models/trace/extras/URLForEntry.d.ts +0 -12
  159. package/models/trace/extras/URLForEntry.js +0 -43
  160. package/models/trace/extras/URLForEntry.js.map +0 -1
  161. package/models/trace/handlers/ServerTimingsHandler.d.ts +0 -9
  162. package/models/trace/handlers/ServerTimingsHandler.js +0 -106
  163. package/models/trace/handlers/ServerTimingsHandler.js.map +0 -1
  164. package/models/trace/insights/CumulativeLayoutShift.d.ts +0 -57
  165. package/models/trace/insights/CumulativeLayoutShift.js +0 -335
  166. package/models/trace/insights/CumulativeLayoutShift.js.map +0 -1
  167. package/models/trace/insights/InsightRunners.d.ts +0 -9
  168. package/models/trace/insights/InsightRunners.js +0 -13
  169. package/models/trace/insights/InsightRunners.js.map +0 -1
  170. package/models/trace/insights/LargestContentfulPaint.d.ts +0 -38
  171. package/models/trace/insights/LargestContentfulPaint.js +0 -113
  172. package/models/trace/insights/LargestContentfulPaint.js.map +0 -1
  173. package/models/trace/insights/ThirdPartyWeb.d.ts +0 -13
  174. package/models/trace/insights/ThirdPartyWeb.js +0 -42
  175. package/models/trace/insights/ThirdPartyWeb.js.map +0 -1
  176. package/models/trace/root-causes/LayoutShift.d.ts +0 -125
  177. package/models/trace/root-causes/LayoutShift.js +0 -519
  178. package/models/trace/root-causes/LayoutShift.js.map +0 -1
  179. package/models/trace/root-causes/RootCauses.d.ts +0 -15
  180. package/models/trace/root-causes/RootCauses.js +0 -12
  181. package/models/trace/root-causes/RootCauses.js.map +0 -1
  182. package/models/trace/root-causes/bundle-tsconfig.json +0 -1
  183. package/models/trace/root-causes/devtools_entrypoint-bundle-typescript-tsconfig.json +0 -42
  184. package/models/trace/root-causes/root-causes-tsconfig.json +0 -55
  185. package/models/trace/root-causes/root-causes.d.ts +0 -1
  186. package/models/trace/root-causes/root-causes.js +0 -5
  187. package/models/trace/root-causes/root-causes.js.map +0 -1
@@ -477,19 +477,34 @@ class PageDependencyGraph {
477
477
  PageDependencyGraph.linkNetworkNodes(rootNode, networkNodeOutput);
478
478
  PageDependencyGraph.linkCPUNodes(rootNode, networkNodeOutput, cpuNodes);
479
479
  mainDocumentNode.setIsMainDocument(true);
480
- if (NetworkNode.hasCycle(rootNode)) {
480
+ if (NetworkNode.findCycle(rootNode)) {
481
+ // Uncomment the following if you are debugging cycles.
482
+ // this.printGraph(rootNode);
481
483
  throw new Core.LanternError('Invalid dependency graph created, cycle detected');
482
484
  }
483
485
  return rootNode;
484
486
  }
485
487
  // Unused, but useful for debugging.
486
- static printGraph(rootNode, widthInCharacters = 100) {
488
+ static printGraph(rootNode, widthInCharacters = 80) {
487
489
  function padRight(str, target, padChar = ' ') {
488
490
  return str + padChar.repeat(Math.max(target - str.length, 0));
489
491
  }
490
492
  const nodes = [];
491
493
  rootNode.traverse(node => nodes.push(node));
492
494
  nodes.sort((a, b) => a.startTime - b.startTime);
495
+ // Assign labels (A, B, C, ..., Z, Z1, Z2, ...) for each node.
496
+ const nodeToLabel = new Map();
497
+ rootNode.traverse(node => {
498
+ const ascii = 65 + nodeToLabel.size;
499
+ let label;
500
+ if (ascii > 90) {
501
+ label = `Z${ascii - 90}`;
502
+ }
503
+ else {
504
+ label = String.fromCharCode(ascii);
505
+ }
506
+ nodeToLabel.set(node, label);
507
+ });
493
508
  const min = nodes[0].startTime;
494
509
  const max = nodes.reduce((max, node) => Math.max(max, node.endTime), 0);
495
510
  const totalTime = max - min;
@@ -501,8 +516,36 @@ class PageDependencyGraph {
501
516
  // @ts-expect-error -- disambiguate displayName from across possible Node types.
502
517
  const displayName = node.request ? node.request.url : node.type;
503
518
  // eslint-disable-next-line
504
- console.log(padRight(bar, widthInCharacters), `| ${displayName.slice(0, 30)}`);
519
+ console.log(padRight(bar, widthInCharacters), `| ${displayName.slice(0, 50)}`);
520
+ });
521
+ // Print labels for each node.
522
+ // eslint-disable-next-line
523
+ console.log();
524
+ // Print dependencies.
525
+ nodes.forEach(node => {
526
+ // @ts-expect-error -- disambiguate displayName from across possible Node types.
527
+ const displayName = node.request ? node.request.url : node.type;
528
+ // eslint-disable-next-line
529
+ console.log(nodeToLabel.get(node), displayName.slice(0, widthInCharacters - 5));
530
+ for (const child of node.dependents) {
531
+ // @ts-expect-error -- disambiguate displayName from across possible Node types.
532
+ const displayName = child.request ? child.request.url : child.type;
533
+ // eslint-disable-next-line
534
+ console.log(' ->', nodeToLabel.get(child), displayName.slice(0, widthInCharacters - 10));
535
+ }
536
+ // eslint-disable-next-line
537
+ console.log();
505
538
  });
539
+ // Show cycle.
540
+ const cyclePath = NetworkNode.findCycle(rootNode);
541
+ // eslint-disable-next-line
542
+ console.log('Cycle?', cyclePath ? 'yes' : 'no');
543
+ if (cyclePath) {
544
+ const path = [...cyclePath];
545
+ path.push(path[0]);
546
+ // eslint-disable-next-line
547
+ console.log(path.map(node => nodeToLabel.get(node)).join(' -> '));
548
+ }
506
549
  }
507
550
  }
508
551
  export { PageDependencyGraph };
@@ -1 +1 @@
1
- {"version":3,"file":"PageDependencyGraph.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/graph/PageDependencyGraph.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAIxC,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,oEAAoE;AACpE,MAAM,yBAAyB,GAAG,SAAS,CAAC;AAC5C,2HAA2H;AAC3H,MAAM,2BAA2B,GAAG,+BAA+B,CAAC;AACpE,sEAAsE;AACtE,MAAM,2BAA2B,GAAG,8BAA8B,CAAC;AACnE,kBAAkB;AAClB,MAAM,2BAA2B,GAAG,4CAA4C,CAAC;AASjF,8DAA8D;AAC9D,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAExC,6FAA6F;AAC7F,gFAAgF;AAChF,MAAM,wBAAwB,GAAG,QAAQ,CAAC;AAE1C,MAAM,mBAAmB;IACvB,MAAM,CAAC,oBAAoB,CAAC,OAA+B;QACzD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,IAAI,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YAC1B,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACxC,8FAA8F;YAC9F,sGAAsG;YACtG,wDAAwD;YACxD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;YACrC,IAAI,KAAK,GAAG,OAAO,CAAC,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AC,CAAC,IAAI,CAAC,IAAI,CAAC;YAChE,2BAA2B;YAC3B,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,EAAE,KAAK,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,OAAO,EAAC,mBAAmB,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\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 type {Node} from './BaseNode.js';\nimport {CPUNode} from './CPUNode.js';\nimport {NetworkNode} from './NetworkNode.js';\n\n// COMPAT: m71+ We added RunTask to `disabled-by-default-lighthouse`\nconst SCHEDULABLE_TASK_TITLE_LH = 'RunTask';\n// m69-70 DoWork is different and we now need RunTask, see https://bugs.chromium.org/p/chromium/issues/detail?id=871204#c11\nconst SCHEDULABLE_TASK_TITLE_ALT1 = 'ThreadControllerImpl::RunTask';\n// In m66-68 refactored to this task title, https://crrev.com/c/883346\nconst SCHEDULABLE_TASK_TITLE_ALT2 = 'ThreadControllerImpl::DoWork';\n// m65 and earlier\nconst SCHEDULABLE_TASK_TITLE_ALT3 = 'TaskQueueManager::ProcessTaskFromWorkQueue';\n\ninterface NetworkNodeOutput {\n nodes: NetworkNode[];\n idToNodeMap: Map<string, NetworkNode>;\n urlToNodeMap: Map<string, NetworkNode[]>;\n frameIdToNodeMap: Map<string, NetworkNode|null>;\n}\n\n// Shorter tasks have negligible impact on simulation results.\nconst SIGNIFICANT_DUR_THRESHOLD_MS = 10;\n\n// TODO: video files tend to be enormous and throw off all graph traversals, move this ignore\n// into estimation logic when we use the dependency graph for other purposes.\nconst IGNORED_MIME_TYPES_REGEX = /^video/;\n\nclass PageDependencyGraph {\n static getNetworkInitiators(request: Lantern.NetworkRequest): string[] {\n if (!request.initiator) {\n return [];\n }\n if (request.initiator.url) {\n return [request.initiator.url];\n }\n if (request.initiator.type === 'script') {\n // Script initiators have the stack of callFrames from all functions that led to this request.\n // If async stacks are enabled, then the stack will also have the parent functions that asynchronously\n // led to this request chained in the `parent` property.\n const scriptURLs = new Set<string>();\n let stack = request.initiator.stack;\n while (stack) {\n const callFrames = stack.callFrames || [];\n for (const frame of callFrames) {\n if (frame.url) {\n scriptURLs.add(frame.url);\n }\n }\n\n stack = stack.parent;\n }\n\n return Array.from(scriptURLs);\n }\n\n return [];\n }\n\n static getNetworkNodeOutput(networkRequests: Lantern.NetworkRequest[]): NetworkNodeOutput {\n const nodes: NetworkNode[] = [];\n const idToNodeMap = new Map<string, NetworkNode>();\n const urlToNodeMap = new Map<string, NetworkNode[]>();\n const frameIdToNodeMap = new Map<string, NetworkNode|null>();\n\n networkRequests.forEach(request => {\n if (IGNORED_MIME_TYPES_REGEX.test(request.mimeType)) {\n return;\n }\n if (request.fromWorker) {\n return;\n }\n\n // Network requestIds can be duplicated for an unknown reason\n // Suffix all subsequent requests with `:duplicate` until it's unique\n // NOTE: This should never happen with modern NetworkRequest library, but old fixtures\n // might still have this issue.\n while (idToNodeMap.has(request.requestId)) {\n request.requestId += ':duplicate';\n }\n\n const node = new NetworkNode(request);\n nodes.push(node);\n\n const urlList = urlToNodeMap.get(request.url) || [];\n urlList.push(node);\n\n idToNodeMap.set(request.requestId, node);\n urlToNodeMap.set(request.url, urlList);\n\n // If the request was for the root document of an iframe, save an entry in our\n // map so we can link up the task `args.data.frame` dependencies later in graph creation.\n if (request.frameId && request.resourceType === 'Document' && request.documentURL === request.url) {\n // If there's ever any ambiguity, permanently set the value to `false` to avoid loops in the graph.\n const value = frameIdToNodeMap.has(request.frameId) ? null : node;\n frameIdToNodeMap.set(request.frameId, value);\n }\n });\n\n return {nodes, idToNodeMap, urlToNodeMap, frameIdToNodeMap};\n }\n\n static isScheduleableTask(evt: Lantern.TraceEvent): boolean {\n return evt.name === SCHEDULABLE_TASK_TITLE_LH || evt.name === SCHEDULABLE_TASK_TITLE_ALT1 ||\n evt.name === SCHEDULABLE_TASK_TITLE_ALT2 || evt.name === SCHEDULABLE_TASK_TITLE_ALT3;\n }\n\n /**\n * There should *always* be at least one top level event, having 0 typically means something is\n * drastically wrong with the trace and we should just give up early and loudly.\n */\n static assertHasToplevelEvents(events: Lantern.TraceEvent[]): void {\n const hasToplevelTask = events.some(this.isScheduleableTask);\n if (!hasToplevelTask) {\n throw new Core.LanternError('Could not find any top level events');\n }\n }\n\n static getCPUNodes(mainThreadEvents: Lantern.TraceEvent[]): CPUNode[] {\n const nodes: CPUNode[] = [];\n let i = 0;\n\n PageDependencyGraph.assertHasToplevelEvents(mainThreadEvents);\n\n while (i < mainThreadEvents.length) {\n const evt = mainThreadEvents[i];\n i++;\n\n // Skip all trace events that aren't schedulable tasks with sizable duration\n if (!PageDependencyGraph.isScheduleableTask(evt) || !evt.dur) {\n continue;\n }\n\n let correctedEndTs: number|undefined = undefined;\n\n // Capture all events that occurred within the task\n const children: Lantern.TraceEvent[] = [];\n for (const endTime = evt.ts + evt.dur; i < mainThreadEvents.length && mainThreadEvents[i].ts < endTime; i++) {\n const event = mainThreadEvents[i];\n\n // Temporary fix for a Chrome bug where some RunTask events can be overlapping.\n // We correct that here be ensuring each RunTask ends at least 1 microsecond before the next\n // https://github.com/GoogleChrome/lighthouse/issues/15896\n // https://issues.chromium.org/issues/329678173\n if (PageDependencyGraph.isScheduleableTask(event) && event.dur) {\n correctedEndTs = event.ts - 1;\n break;\n }\n\n children.push(event);\n }\n\n nodes.push(new CPUNode(evt, children, correctedEndTs));\n }\n\n return nodes;\n }\n\n static linkNetworkNodes(rootNode: NetworkNode, networkNodeOutput: NetworkNodeOutput): void {\n networkNodeOutput.nodes.forEach(node => {\n const directInitiatorRequest = node.request.initiatorRequest || rootNode.request;\n const directInitiatorNode = networkNodeOutput.idToNodeMap.get(directInitiatorRequest.requestId) || rootNode;\n const canDependOnInitiator = !directInitiatorNode.isDependentOn(node) && node.canDependOn(directInitiatorNode);\n const initiators = PageDependencyGraph.getNetworkInitiators(node.request);\n if (initiators.length) {\n initiators.forEach(initiator => {\n const parentCandidates = networkNodeOutput.urlToNodeMap.get(initiator) || [];\n // Only add the edge if the parent is unambiguous with valid timing and isn't circular.\n if (parentCandidates.length === 1 && parentCandidates[0].startTime <= node.startTime &&\n !parentCandidates[0].isDependentOn(node)) {\n node.addDependency(parentCandidates[0]);\n } else if (canDependOnInitiator) {\n directInitiatorNode.addDependent(node);\n }\n });\n } else if (canDependOnInitiator) {\n directInitiatorNode.addDependent(node);\n }\n\n // Make sure the nodes are attached to the graph if the initiator information was invalid.\n if (node !== rootNode && node.getDependencies().length === 0 && node.canDependOn(rootNode)) {\n node.addDependency(rootNode);\n }\n\n if (!node.request.redirects) {\n return;\n }\n\n const redirects = [...node.request.redirects, node.request];\n for (let i = 1; i < redirects.length; i++) {\n const redirectNode = networkNodeOutput.idToNodeMap.get(redirects[i - 1].requestId);\n const actualNode = networkNodeOutput.idToNodeMap.get(redirects[i].requestId);\n if (actualNode && redirectNode) {\n actualNode.addDependency(redirectNode);\n }\n }\n });\n }\n\n static linkCPUNodes(rootNode: Node, networkNodeOutput: NetworkNodeOutput, cpuNodes: CPUNode[]): void {\n const linkableResourceTypes = new Set<Lantern.ResourceType|undefined>([\n 'XHR',\n 'Fetch',\n 'Script',\n ]);\n\n function addDependentNetworkRequest(cpuNode: CPUNode, reqId: string): void {\n const networkNode = networkNodeOutput.idToNodeMap.get(reqId);\n if (!networkNode ||\n // Ignore all network nodes that started before this CPU task started\n // A network request that started earlier could not possibly have been started by this task\n networkNode.startTime <= cpuNode.startTime) {\n return;\n }\n const {request} = networkNode;\n const resourceType = request.resourceType || request.redirectDestination?.resourceType;\n if (!linkableResourceTypes.has(resourceType)) {\n // We only link some resources to CPU nodes because we observe LCP simulation\n // regressions when including images, etc.\n return;\n }\n cpuNode.addDependent(networkNode);\n }\n\n /**\n * If the node has an associated frameId, then create a dependency on the root document request\n * for the frame. The task obviously couldn't have started before the frame was even downloaded.\n */\n function addDependencyOnFrame(cpuNode: CPUNode, frameId: string|undefined): void {\n if (!frameId) {\n return;\n }\n const networkNode = networkNodeOutput.frameIdToNodeMap.get(frameId);\n if (!networkNode) {\n return;\n }\n // Ignore all network nodes that started after this CPU task started\n // A network request that started after could not possibly be required this task\n if (networkNode.startTime >= cpuNode.startTime) {\n return;\n }\n cpuNode.addDependency(networkNode);\n }\n\n function addDependencyOnUrl(cpuNode: CPUNode, url: string): void {\n if (!url) {\n return;\n }\n // Allow network requests that end up to 100ms before the task started\n // Some script evaluations can start before the script finishes downloading\n const minimumAllowableTimeSinceNetworkNodeEnd = -100 * 1000;\n const candidates = networkNodeOutput.urlToNodeMap.get(url) || [];\n\n let minCandidate = null;\n let minDistance = Infinity;\n // Find the closest request that finished before this CPU task started\n for (const candidate of candidates) {\n // Explicitly ignore all requests that started after this CPU node\n // A network request that started after this task started cannot possibly be a dependency\n if (cpuNode.startTime <= candidate.startTime) {\n return;\n }\n\n const distance = cpuNode.startTime - candidate.endTime;\n if (distance >= minimumAllowableTimeSinceNetworkNodeEnd && distance < minDistance) {\n minCandidate = candidate;\n minDistance = distance;\n }\n }\n\n if (!minCandidate) {\n return;\n }\n cpuNode.addDependency(minCandidate);\n }\n\n const timers = new Map<string, CPUNode>();\n for (const node of cpuNodes) {\n for (const evt of node.childEvents) {\n if (!evt.args.data) {\n continue;\n }\n\n const argsUrl = evt.args.data.url;\n const stackTraceUrls = (evt.args.data.stackTrace || []).map(l => l.url).filter(Boolean);\n\n switch (evt.name) {\n case 'TimerInstall':\n // @ts-expect-error - 'TimerInstall' event means timerId exists.\n timers.set(evt.args.data.timerId, node);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n case 'TimerFire': {\n // @ts-expect-error - 'TimerFire' event means timerId exists.\n const installer = timers.get(evt.args.data.timerId);\n if (!installer || installer.endTime > node.startTime) {\n break;\n }\n installer.addDependent(node);\n break;\n }\n\n case 'InvalidateLayout':\n case 'ScheduleStyleRecalculation':\n addDependencyOnFrame(node, evt.args.data.frame);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n\n case 'EvaluateScript':\n addDependencyOnFrame(node, evt.args.data.frame);\n // @ts-expect-error - 'EvaluateScript' event means argsUrl is defined.\n addDependencyOnUrl(node, argsUrl);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n\n case 'XHRReadyStateChange':\n // Only create the dependency if the request was completed\n // 'XHRReadyStateChange' event means readyState is defined.\n if (evt.args.data.readyState !== 4) {\n break;\n }\n\n // @ts-expect-error - 'XHRReadyStateChange' event means argsUrl is defined.\n addDependencyOnUrl(node, argsUrl);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n\n case 'FunctionCall':\n case 'v8.compile':\n addDependencyOnFrame(node, evt.args.data.frame);\n // @ts-expect-error - events mean argsUrl is defined.\n addDependencyOnUrl(node, argsUrl);\n break;\n\n case 'ParseAuthorStyleSheet':\n addDependencyOnFrame(node, evt.args.data.frame);\n // @ts-expect-error - 'ParseAuthorStyleSheet' event means styleSheetUrl is defined.\n addDependencyOnUrl(node, evt.args.data.styleSheetUrl);\n break;\n\n case 'ResourceSendRequest':\n addDependencyOnFrame(node, evt.args.data.frame);\n // @ts-expect-error - 'ResourceSendRequest' event means requestId is defined.\n addDependentNetworkRequest(node, evt.args.data.requestId);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n }\n }\n\n // Nodes starting before the root node cannot depend on it.\n if (node.getNumberOfDependencies() === 0 && node.canDependOn(rootNode)) {\n node.addDependency(rootNode);\n }\n }\n\n // Second pass to prune the graph of short tasks.\n const minimumEvtDur = SIGNIFICANT_DUR_THRESHOLD_MS * 1000;\n let foundFirstLayout = false;\n let foundFirstPaint = false;\n let foundFirstParse = false;\n\n for (const node of cpuNodes) {\n // Don't prune if event is the first ParseHTML/Layout/Paint.\n // See https://github.com/GoogleChrome/lighthouse/issues/9627#issuecomment-526699524 for more.\n let isFirst = false;\n if (!foundFirstLayout && node.childEvents.some(evt => evt.name === 'Layout')) {\n isFirst = foundFirstLayout = true;\n }\n if (!foundFirstPaint && node.childEvents.some(evt => evt.name === 'Paint')) {\n isFirst = foundFirstPaint = true;\n }\n if (!foundFirstParse && node.childEvents.some(evt => evt.name === 'ParseHTML')) {\n isFirst = foundFirstParse = true;\n }\n\n if (isFirst || node.duration >= minimumEvtDur) {\n // Don't prune this node. The task is long / important so it will impact simulation.\n continue;\n }\n\n // Prune the node if it isn't highly connected to minimize graph size. Rewiring the graph\n // here replaces O(M + N) edges with (M * N) edges, which is fine if either M or N is at\n // most 1.\n if (node.getNumberOfDependencies() === 1 || node.getNumberOfDependents() <= 1) {\n PageDependencyGraph.pruneNode(node);\n }\n }\n }\n\n /**\n * Removes the given node from the graph, but retains all paths between its dependencies and\n * dependents.\n */\n static pruneNode(node: Node): void {\n const dependencies = node.getDependencies();\n const dependents = node.getDependents();\n for (const dependency of dependencies) {\n node.removeDependency(dependency);\n for (const dependent of dependents) {\n dependency.addDependent(dependent);\n }\n }\n for (const dependent of dependents) {\n node.removeDependent(dependent);\n }\n }\n\n /**\n * TODO: remove when CDT backend in Lighthouse is gone. Until then, this is a useful debugging tool\n * to find delta between using CDP or the trace to create the network requests.\n *\n * When a test fails using the trace backend, I enabled this debug method and copied the network\n * requests when CDP was used, then when trace is used, and diff'd them. This method helped\n * remove non-logical differences from the comparison (order of properties, slight rounding\n * discrepancies, removing object cycles, etc).\n *\n * When using for a unit test, make sure to do `.only` so you are getting what you expect.\n */\n static debugNormalizeRequests(lanternRequests: Lantern.NetworkRequest[]): void {\n for (const request of lanternRequests) {\n request.rendererStartTime = Math.round(request.rendererStartTime * 1000) / 1000;\n request.networkRequestTime = Math.round(request.networkRequestTime * 1000) / 1000;\n request.responseHeadersEndTime = Math.round(request.responseHeadersEndTime * 1000) / 1000;\n request.networkEndTime = Math.round(request.networkEndTime * 1000) / 1000;\n }\n\n for (const r of lanternRequests) {\n delete r.rawRequest;\n if (r.initiatorRequest) {\n // @ts-expect-error\n r.initiatorRequest = {id: r.initiatorRequest.requestId};\n }\n if (r.redirectDestination) {\n // @ts-expect-error\n r.redirectDestination = {id: r.redirectDestination.requestId};\n }\n if (r.redirectSource) {\n // @ts-expect-error\n r.redirectSource = {id: r.redirectSource.requestId};\n }\n if (r.redirects) {\n // @ts-expect-error\n r.redirects = r.redirects.map(r2 => r2.requestId);\n }\n }\n const requests: Lantern.NetworkRequest[] = lanternRequests\n .map(r => ({\n requestId: r.requestId,\n connectionId: r.connectionId,\n connectionReused: r.connectionReused,\n url: r.url,\n protocol: r.protocol,\n parsedURL: r.parsedURL,\n documentURL: r.documentURL,\n rendererStartTime: r.rendererStartTime,\n networkRequestTime: r.networkRequestTime,\n responseHeadersEndTime: r.responseHeadersEndTime,\n networkEndTime: r.networkEndTime,\n transferSize: r.transferSize,\n resourceSize: r.resourceSize,\n fromDiskCache: r.fromDiskCache,\n fromMemoryCache: r.fromMemoryCache,\n finished: r.finished,\n statusCode: r.statusCode,\n redirectSource: r.redirectSource,\n redirectDestination: r.redirectDestination,\n redirects: r.redirects,\n failed: r.failed,\n initiator: r.initiator,\n timing: r.timing ? {\n requestTime: r.timing.requestTime,\n proxyStart: r.timing.proxyStart,\n proxyEnd: r.timing.proxyEnd,\n dnsStart: r.timing.dnsStart,\n dnsEnd: r.timing.dnsEnd,\n connectStart: r.timing.connectStart,\n connectEnd: r.timing.connectEnd,\n sslStart: r.timing.sslStart,\n sslEnd: r.timing.sslEnd,\n workerStart: r.timing.workerStart,\n workerReady: r.timing.workerReady,\n workerFetchStart: r.timing.workerFetchStart,\n workerRespondWithSettled: r.timing.workerRespondWithSettled,\n sendStart: r.timing.sendStart,\n sendEnd: r.timing.sendEnd,\n pushStart: r.timing.pushStart,\n pushEnd: r.timing.pushEnd,\n receiveHeadersStart: r.timing.receiveHeadersStart,\n receiveHeadersEnd: r.timing.receiveHeadersEnd,\n } :\n r.timing,\n resourceType: r.resourceType,\n mimeType: r.mimeType,\n priority: r.priority,\n initiatorRequest: r.initiatorRequest,\n frameId: r.frameId,\n fromWorker: r.fromWorker,\n isLinkPreload: r.isLinkPreload,\n serverResponseTime: r.serverResponseTime,\n }))\n .filter(r => !r.fromWorker);\n\n const debug = requests;\n // Set breakpoint here.\n // Copy `debug` and compare with https://www.diffchecker.com/text-compare/\n // eslint-disable-next-line no-console\n console.log(debug);\n }\n\n static createGraph(\n mainThreadEvents: Lantern.TraceEvent[], networkRequests: Lantern.NetworkRequest[],\n url: Lantern.Simulation.URL): Node {\n // This is for debugging trace/devtoolslog network records.\n // const debug = PageDependencyGraph.debugNormalizeRequests(networkRequests);\n const networkNodeOutput = PageDependencyGraph.getNetworkNodeOutput(networkRequests);\n const cpuNodes = PageDependencyGraph.getCPUNodes(mainThreadEvents);\n const {requestedUrl, mainDocumentUrl} = url;\n if (!requestedUrl) {\n throw new Core.LanternError('requestedUrl is required to get the root request');\n }\n if (!mainDocumentUrl) {\n throw new Core.LanternError('mainDocumentUrl is required to get the main resource');\n }\n\n const rootRequest = Core.NetworkAnalyzer.findResourceForUrl(networkRequests, requestedUrl);\n if (!rootRequest) {\n throw new Core.LanternError('rootRequest not found');\n }\n const rootNode = networkNodeOutput.idToNodeMap.get(rootRequest.requestId);\n if (!rootNode) {\n throw new Core.LanternError('rootNode not found');\n }\n const mainDocumentRequest = Core.NetworkAnalyzer.findLastDocumentForUrl(networkRequests, mainDocumentUrl);\n if (!mainDocumentRequest) {\n throw new Core.LanternError('mainDocumentRequest not found');\n }\n const mainDocumentNode = networkNodeOutput.idToNodeMap.get(mainDocumentRequest.requestId);\n if (!mainDocumentNode) {\n throw new Core.LanternError('mainDocumentNode not found');\n }\n\n PageDependencyGraph.linkNetworkNodes(rootNode, networkNodeOutput);\n PageDependencyGraph.linkCPUNodes(rootNode, networkNodeOutput, cpuNodes);\n mainDocumentNode.setIsMainDocument(true);\n\n if (NetworkNode.hasCycle(rootNode)) {\n throw new Core.LanternError('Invalid dependency graph created, cycle detected');\n }\n\n return rootNode;\n }\n\n // Unused, but useful for debugging.\n static printGraph(rootNode: Node, widthInCharacters = 100): void {\n function padRight(str: string, target: number, padChar = ' '): string {\n return str + padChar.repeat(Math.max(target - str.length, 0));\n }\n\n const nodes: Node[] = [];\n rootNode.traverse(node => nodes.push(node));\n nodes.sort((a, b) => a.startTime - b.startTime);\n\n const min = nodes[0].startTime;\n const max = nodes.reduce((max, node) => Math.max(max, node.endTime), 0);\n\n const totalTime = max - min;\n const timePerCharacter = totalTime / widthInCharacters;\n nodes.forEach(node => {\n const offset = Math.round((node.startTime - min) / timePerCharacter);\n const length = Math.ceil((node.endTime - node.startTime) / timePerCharacter);\n const bar = padRight('', offset) + padRight('', length, '=');\n\n // @ts-expect-error -- disambiguate displayName from across possible Node types.\n const displayName = node.request ? node.request.url : node.type;\n // eslint-disable-next-line\n console.log(padRight(bar, widthInCharacters), `| ${displayName.slice(0, 30)}`);\n });\n }\n}\n\nexport {PageDependencyGraph};\n"]}
1
+ {"version":3,"file":"PageDependencyGraph.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/graph/PageDependencyGraph.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAIxC,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,oEAAoE;AACpE,MAAM,yBAAyB,GAAG,SAAS,CAAC;AAC5C,2HAA2H;AAC3H,MAAM,2BAA2B,GAAG,+BAA+B,CAAC;AACpE,sEAAsE;AACtE,MAAM,2BAA2B,GAAG,8BAA8B,CAAC;AACnE,kBAAkB;AAClB,MAAM,2BAA2B,GAAG,4CAA4C,CAAC;AASjF,8DAA8D;AAC9D,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAExC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5B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACnB,2BAA2B;YAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF;AAED,OAAO,EAAC,mBAAmB,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\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 type {BaseNode, Node} from './BaseNode.js';\nimport {CPUNode} from './CPUNode.js';\nimport {NetworkNode} from './NetworkNode.js';\n\n// COMPAT: m71+ We added RunTask to `disabled-by-default-lighthouse`\nconst SCHEDULABLE_TASK_TITLE_LH = 'RunTask';\n// m69-70 DoWork is different and we now need RunTask, see https://bugs.chromium.org/p/chromium/issues/detail?id=871204#c11\nconst SCHEDULABLE_TASK_TITLE_ALT1 = 'ThreadControllerImpl::RunTask';\n// In m66-68 refactored to this task title, https://crrev.com/c/883346\nconst SCHEDULABLE_TASK_TITLE_ALT2 = 'ThreadControllerImpl::DoWork';\n// m65 and earlier\nconst SCHEDULABLE_TASK_TITLE_ALT3 = 'TaskQueueManager::ProcessTaskFromWorkQueue';\n\ninterface NetworkNodeOutput {\n nodes: NetworkNode[];\n idToNodeMap: Map<string, NetworkNode>;\n urlToNodeMap: Map<string, NetworkNode[]>;\n frameIdToNodeMap: Map<string, NetworkNode|null>;\n}\n\n// Shorter tasks have negligible impact on simulation results.\nconst SIGNIFICANT_DUR_THRESHOLD_MS = 10;\n\n// TODO: video files tend to be enormous and throw off all graph traversals, move this ignore\n// into estimation logic when we use the dependency graph for other purposes.\nconst IGNORED_MIME_TYPES_REGEX = /^video/;\n\nclass PageDependencyGraph {\n static getNetworkInitiators(request: Lantern.NetworkRequest): string[] {\n if (!request.initiator) {\n return [];\n }\n if (request.initiator.url) {\n return [request.initiator.url];\n }\n if (request.initiator.type === 'script') {\n // Script initiators have the stack of callFrames from all functions that led to this request.\n // If async stacks are enabled, then the stack will also have the parent functions that asynchronously\n // led to this request chained in the `parent` property.\n const scriptURLs = new Set<string>();\n let stack = request.initiator.stack;\n while (stack) {\n const callFrames = stack.callFrames || [];\n for (const frame of callFrames) {\n if (frame.url) {\n scriptURLs.add(frame.url);\n }\n }\n\n stack = stack.parent;\n }\n\n return Array.from(scriptURLs);\n }\n\n return [];\n }\n\n static getNetworkNodeOutput(networkRequests: Lantern.NetworkRequest[]): NetworkNodeOutput {\n const nodes: NetworkNode[] = [];\n const idToNodeMap = new Map<string, NetworkNode>();\n const urlToNodeMap = new Map<string, NetworkNode[]>();\n const frameIdToNodeMap = new Map<string, NetworkNode|null>();\n\n networkRequests.forEach(request => {\n if (IGNORED_MIME_TYPES_REGEX.test(request.mimeType)) {\n return;\n }\n if (request.fromWorker) {\n return;\n }\n\n // Network requestIds can be duplicated for an unknown reason\n // Suffix all subsequent requests with `:duplicate` until it's unique\n // NOTE: This should never happen with modern NetworkRequest library, but old fixtures\n // might still have this issue.\n while (idToNodeMap.has(request.requestId)) {\n request.requestId += ':duplicate';\n }\n\n const node = new NetworkNode(request);\n nodes.push(node);\n\n const urlList = urlToNodeMap.get(request.url) || [];\n urlList.push(node);\n\n idToNodeMap.set(request.requestId, node);\n urlToNodeMap.set(request.url, urlList);\n\n // If the request was for the root document of an iframe, save an entry in our\n // map so we can link up the task `args.data.frame` dependencies later in graph creation.\n if (request.frameId && request.resourceType === 'Document' && request.documentURL === request.url) {\n // If there's ever any ambiguity, permanently set the value to `false` to avoid loops in the graph.\n const value = frameIdToNodeMap.has(request.frameId) ? null : node;\n frameIdToNodeMap.set(request.frameId, value);\n }\n });\n\n return {nodes, idToNodeMap, urlToNodeMap, frameIdToNodeMap};\n }\n\n static isScheduleableTask(evt: Lantern.TraceEvent): boolean {\n return evt.name === SCHEDULABLE_TASK_TITLE_LH || evt.name === SCHEDULABLE_TASK_TITLE_ALT1 ||\n evt.name === SCHEDULABLE_TASK_TITLE_ALT2 || evt.name === SCHEDULABLE_TASK_TITLE_ALT3;\n }\n\n /**\n * There should *always* be at least one top level event, having 0 typically means something is\n * drastically wrong with the trace and we should just give up early and loudly.\n */\n static assertHasToplevelEvents(events: Lantern.TraceEvent[]): void {\n const hasToplevelTask = events.some(this.isScheduleableTask);\n if (!hasToplevelTask) {\n throw new Core.LanternError('Could not find any top level events');\n }\n }\n\n static getCPUNodes(mainThreadEvents: Lantern.TraceEvent[]): CPUNode[] {\n const nodes: CPUNode[] = [];\n let i = 0;\n\n PageDependencyGraph.assertHasToplevelEvents(mainThreadEvents);\n\n while (i < mainThreadEvents.length) {\n const evt = mainThreadEvents[i];\n i++;\n\n // Skip all trace events that aren't schedulable tasks with sizable duration\n if (!PageDependencyGraph.isScheduleableTask(evt) || !evt.dur) {\n continue;\n }\n\n let correctedEndTs: number|undefined = undefined;\n\n // Capture all events that occurred within the task\n const children: Lantern.TraceEvent[] = [];\n for (const endTime = evt.ts + evt.dur; i < mainThreadEvents.length && mainThreadEvents[i].ts < endTime; i++) {\n const event = mainThreadEvents[i];\n\n // Temporary fix for a Chrome bug where some RunTask events can be overlapping.\n // We correct that here be ensuring each RunTask ends at least 1 microsecond before the next\n // https://github.com/GoogleChrome/lighthouse/issues/15896\n // https://issues.chromium.org/issues/329678173\n if (PageDependencyGraph.isScheduleableTask(event) && event.dur) {\n correctedEndTs = event.ts - 1;\n break;\n }\n\n children.push(event);\n }\n\n nodes.push(new CPUNode(evt, children, correctedEndTs));\n }\n\n return nodes;\n }\n\n static linkNetworkNodes(rootNode: NetworkNode, networkNodeOutput: NetworkNodeOutput): void {\n networkNodeOutput.nodes.forEach(node => {\n const directInitiatorRequest = node.request.initiatorRequest || rootNode.request;\n const directInitiatorNode = networkNodeOutput.idToNodeMap.get(directInitiatorRequest.requestId) || rootNode;\n const canDependOnInitiator = !directInitiatorNode.isDependentOn(node) && node.canDependOn(directInitiatorNode);\n const initiators = PageDependencyGraph.getNetworkInitiators(node.request);\n if (initiators.length) {\n initiators.forEach(initiator => {\n const parentCandidates = networkNodeOutput.urlToNodeMap.get(initiator) || [];\n // Only add the edge if the parent is unambiguous with valid timing and isn't circular.\n if (parentCandidates.length === 1 && parentCandidates[0].startTime <= node.startTime &&\n !parentCandidates[0].isDependentOn(node)) {\n node.addDependency(parentCandidates[0]);\n } else if (canDependOnInitiator) {\n directInitiatorNode.addDependent(node);\n }\n });\n } else if (canDependOnInitiator) {\n directInitiatorNode.addDependent(node);\n }\n\n // Make sure the nodes are attached to the graph if the initiator information was invalid.\n if (node !== rootNode && node.getDependencies().length === 0 && node.canDependOn(rootNode)) {\n node.addDependency(rootNode);\n }\n\n if (!node.request.redirects) {\n return;\n }\n\n const redirects = [...node.request.redirects, node.request];\n for (let i = 1; i < redirects.length; i++) {\n const redirectNode = networkNodeOutput.idToNodeMap.get(redirects[i - 1].requestId);\n const actualNode = networkNodeOutput.idToNodeMap.get(redirects[i].requestId);\n if (actualNode && redirectNode) {\n actualNode.addDependency(redirectNode);\n }\n }\n });\n }\n\n static linkCPUNodes(rootNode: Node, networkNodeOutput: NetworkNodeOutput, cpuNodes: CPUNode[]): void {\n const linkableResourceTypes = new Set<Lantern.ResourceType|undefined>([\n 'XHR',\n 'Fetch',\n 'Script',\n ]);\n\n function addDependentNetworkRequest(cpuNode: CPUNode, reqId: string): void {\n const networkNode = networkNodeOutput.idToNodeMap.get(reqId);\n if (!networkNode ||\n // Ignore all network nodes that started before this CPU task started\n // A network request that started earlier could not possibly have been started by this task\n networkNode.startTime <= cpuNode.startTime) {\n return;\n }\n const {request} = networkNode;\n const resourceType = request.resourceType || request.redirectDestination?.resourceType;\n if (!linkableResourceTypes.has(resourceType)) {\n // We only link some resources to CPU nodes because we observe LCP simulation\n // regressions when including images, etc.\n return;\n }\n cpuNode.addDependent(networkNode);\n }\n\n /**\n * If the node has an associated frameId, then create a dependency on the root document request\n * for the frame. The task obviously couldn't have started before the frame was even downloaded.\n */\n function addDependencyOnFrame(cpuNode: CPUNode, frameId: string|undefined): void {\n if (!frameId) {\n return;\n }\n const networkNode = networkNodeOutput.frameIdToNodeMap.get(frameId);\n if (!networkNode) {\n return;\n }\n // Ignore all network nodes that started after this CPU task started\n // A network request that started after could not possibly be required this task\n if (networkNode.startTime >= cpuNode.startTime) {\n return;\n }\n cpuNode.addDependency(networkNode);\n }\n\n function addDependencyOnUrl(cpuNode: CPUNode, url: string): void {\n if (!url) {\n return;\n }\n // Allow network requests that end up to 100ms before the task started\n // Some script evaluations can start before the script finishes downloading\n const minimumAllowableTimeSinceNetworkNodeEnd = -100 * 1000;\n const candidates = networkNodeOutput.urlToNodeMap.get(url) || [];\n\n let minCandidate = null;\n let minDistance = Infinity;\n // Find the closest request that finished before this CPU task started\n for (const candidate of candidates) {\n // Explicitly ignore all requests that started after this CPU node\n // A network request that started after this task started cannot possibly be a dependency\n if (cpuNode.startTime <= candidate.startTime) {\n return;\n }\n\n const distance = cpuNode.startTime - candidate.endTime;\n if (distance >= minimumAllowableTimeSinceNetworkNodeEnd && distance < minDistance) {\n minCandidate = candidate;\n minDistance = distance;\n }\n }\n\n if (!minCandidate) {\n return;\n }\n cpuNode.addDependency(minCandidate);\n }\n\n const timers = new Map<string, CPUNode>();\n for (const node of cpuNodes) {\n for (const evt of node.childEvents) {\n if (!evt.args.data) {\n continue;\n }\n\n const argsUrl = evt.args.data.url;\n const stackTraceUrls = (evt.args.data.stackTrace || []).map(l => l.url).filter(Boolean);\n\n switch (evt.name) {\n case 'TimerInstall':\n // @ts-expect-error - 'TimerInstall' event means timerId exists.\n timers.set(evt.args.data.timerId, node);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n case 'TimerFire': {\n // @ts-expect-error - 'TimerFire' event means timerId exists.\n const installer = timers.get(evt.args.data.timerId);\n if (!installer || installer.endTime > node.startTime) {\n break;\n }\n installer.addDependent(node);\n break;\n }\n\n case 'InvalidateLayout':\n case 'ScheduleStyleRecalculation':\n addDependencyOnFrame(node, evt.args.data.frame);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n\n case 'EvaluateScript':\n addDependencyOnFrame(node, evt.args.data.frame);\n // @ts-expect-error - 'EvaluateScript' event means argsUrl is defined.\n addDependencyOnUrl(node, argsUrl);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n\n case 'XHRReadyStateChange':\n // Only create the dependency if the request was completed\n // 'XHRReadyStateChange' event means readyState is defined.\n if (evt.args.data.readyState !== 4) {\n break;\n }\n\n // @ts-expect-error - 'XHRReadyStateChange' event means argsUrl is defined.\n addDependencyOnUrl(node, argsUrl);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n\n case 'FunctionCall':\n case 'v8.compile':\n addDependencyOnFrame(node, evt.args.data.frame);\n // @ts-expect-error - events mean argsUrl is defined.\n addDependencyOnUrl(node, argsUrl);\n break;\n\n case 'ParseAuthorStyleSheet':\n addDependencyOnFrame(node, evt.args.data.frame);\n // @ts-expect-error - 'ParseAuthorStyleSheet' event means styleSheetUrl is defined.\n addDependencyOnUrl(node, evt.args.data.styleSheetUrl);\n break;\n\n case 'ResourceSendRequest':\n addDependencyOnFrame(node, evt.args.data.frame);\n // @ts-expect-error - 'ResourceSendRequest' event means requestId is defined.\n addDependentNetworkRequest(node, evt.args.data.requestId);\n stackTraceUrls.forEach(url => addDependencyOnUrl(node, url));\n break;\n }\n }\n\n // Nodes starting before the root node cannot depend on it.\n if (node.getNumberOfDependencies() === 0 && node.canDependOn(rootNode)) {\n node.addDependency(rootNode);\n }\n }\n\n // Second pass to prune the graph of short tasks.\n const minimumEvtDur = SIGNIFICANT_DUR_THRESHOLD_MS * 1000;\n let foundFirstLayout = false;\n let foundFirstPaint = false;\n let foundFirstParse = false;\n\n for (const node of cpuNodes) {\n // Don't prune if event is the first ParseHTML/Layout/Paint.\n // See https://github.com/GoogleChrome/lighthouse/issues/9627#issuecomment-526699524 for more.\n let isFirst = false;\n if (!foundFirstLayout && node.childEvents.some(evt => evt.name === 'Layout')) {\n isFirst = foundFirstLayout = true;\n }\n if (!foundFirstPaint && node.childEvents.some(evt => evt.name === 'Paint')) {\n isFirst = foundFirstPaint = true;\n }\n if (!foundFirstParse && node.childEvents.some(evt => evt.name === 'ParseHTML')) {\n isFirst = foundFirstParse = true;\n }\n\n if (isFirst || node.duration >= minimumEvtDur) {\n // Don't prune this node. The task is long / important so it will impact simulation.\n continue;\n }\n\n // Prune the node if it isn't highly connected to minimize graph size. Rewiring the graph\n // here replaces O(M + N) edges with (M * N) edges, which is fine if either M or N is at\n // most 1.\n if (node.getNumberOfDependencies() === 1 || node.getNumberOfDependents() <= 1) {\n PageDependencyGraph.pruneNode(node);\n }\n }\n }\n\n /**\n * Removes the given node from the graph, but retains all paths between its dependencies and\n * dependents.\n */\n static pruneNode(node: Node): void {\n const dependencies = node.getDependencies();\n const dependents = node.getDependents();\n for (const dependency of dependencies) {\n node.removeDependency(dependency);\n for (const dependent of dependents) {\n dependency.addDependent(dependent);\n }\n }\n for (const dependent of dependents) {\n node.removeDependent(dependent);\n }\n }\n\n /**\n * TODO: remove when CDT backend in Lighthouse is gone. Until then, this is a useful debugging tool\n * to find delta between using CDP or the trace to create the network requests.\n *\n * When a test fails using the trace backend, I enabled this debug method and copied the network\n * requests when CDP was used, then when trace is used, and diff'd them. This method helped\n * remove non-logical differences from the comparison (order of properties, slight rounding\n * discrepancies, removing object cycles, etc).\n *\n * When using for a unit test, make sure to do `.only` so you are getting what you expect.\n */\n static debugNormalizeRequests(lanternRequests: Lantern.NetworkRequest[]): void {\n for (const request of lanternRequests) {\n request.rendererStartTime = Math.round(request.rendererStartTime * 1000) / 1000;\n request.networkRequestTime = Math.round(request.networkRequestTime * 1000) / 1000;\n request.responseHeadersEndTime = Math.round(request.responseHeadersEndTime * 1000) / 1000;\n request.networkEndTime = Math.round(request.networkEndTime * 1000) / 1000;\n }\n\n for (const r of lanternRequests) {\n delete r.rawRequest;\n if (r.initiatorRequest) {\n // @ts-expect-error\n r.initiatorRequest = {id: r.initiatorRequest.requestId};\n }\n if (r.redirectDestination) {\n // @ts-expect-error\n r.redirectDestination = {id: r.redirectDestination.requestId};\n }\n if (r.redirectSource) {\n // @ts-expect-error\n r.redirectSource = {id: r.redirectSource.requestId};\n }\n if (r.redirects) {\n // @ts-expect-error\n r.redirects = r.redirects.map(r2 => r2.requestId);\n }\n }\n const requests: Lantern.NetworkRequest[] = lanternRequests\n .map(r => ({\n requestId: r.requestId,\n connectionId: r.connectionId,\n connectionReused: r.connectionReused,\n url: r.url,\n protocol: r.protocol,\n parsedURL: r.parsedURL,\n documentURL: r.documentURL,\n rendererStartTime: r.rendererStartTime,\n networkRequestTime: r.networkRequestTime,\n responseHeadersEndTime: r.responseHeadersEndTime,\n networkEndTime: r.networkEndTime,\n transferSize: r.transferSize,\n resourceSize: r.resourceSize,\n fromDiskCache: r.fromDiskCache,\n fromMemoryCache: r.fromMemoryCache,\n finished: r.finished,\n statusCode: r.statusCode,\n redirectSource: r.redirectSource,\n redirectDestination: r.redirectDestination,\n redirects: r.redirects,\n failed: r.failed,\n initiator: r.initiator,\n timing: r.timing ? {\n requestTime: r.timing.requestTime,\n proxyStart: r.timing.proxyStart,\n proxyEnd: r.timing.proxyEnd,\n dnsStart: r.timing.dnsStart,\n dnsEnd: r.timing.dnsEnd,\n connectStart: r.timing.connectStart,\n connectEnd: r.timing.connectEnd,\n sslStart: r.timing.sslStart,\n sslEnd: r.timing.sslEnd,\n workerStart: r.timing.workerStart,\n workerReady: r.timing.workerReady,\n workerFetchStart: r.timing.workerFetchStart,\n workerRespondWithSettled: r.timing.workerRespondWithSettled,\n sendStart: r.timing.sendStart,\n sendEnd: r.timing.sendEnd,\n pushStart: r.timing.pushStart,\n pushEnd: r.timing.pushEnd,\n receiveHeadersStart: r.timing.receiveHeadersStart,\n receiveHeadersEnd: r.timing.receiveHeadersEnd,\n } :\n r.timing,\n resourceType: r.resourceType,\n mimeType: r.mimeType,\n priority: r.priority,\n initiatorRequest: r.initiatorRequest,\n frameId: r.frameId,\n fromWorker: r.fromWorker,\n isLinkPreload: r.isLinkPreload,\n serverResponseTime: r.serverResponseTime,\n }))\n .filter(r => !r.fromWorker);\n\n const debug = requests;\n // Set breakpoint here.\n // Copy `debug` and compare with https://www.diffchecker.com/text-compare/\n // eslint-disable-next-line no-console\n console.log(debug);\n }\n\n static createGraph(\n mainThreadEvents: Lantern.TraceEvent[], networkRequests: Lantern.NetworkRequest[],\n url: Lantern.Simulation.URL): Node {\n // This is for debugging trace/devtoolslog network records.\n // const debug = PageDependencyGraph.debugNormalizeRequests(networkRequests);\n const networkNodeOutput = PageDependencyGraph.getNetworkNodeOutput(networkRequests);\n const cpuNodes = PageDependencyGraph.getCPUNodes(mainThreadEvents);\n const {requestedUrl, mainDocumentUrl} = url;\n if (!requestedUrl) {\n throw new Core.LanternError('requestedUrl is required to get the root request');\n }\n if (!mainDocumentUrl) {\n throw new Core.LanternError('mainDocumentUrl is required to get the main resource');\n }\n\n const rootRequest = Core.NetworkAnalyzer.findResourceForUrl(networkRequests, requestedUrl);\n if (!rootRequest) {\n throw new Core.LanternError('rootRequest not found');\n }\n const rootNode = networkNodeOutput.idToNodeMap.get(rootRequest.requestId);\n if (!rootNode) {\n throw new Core.LanternError('rootNode not found');\n }\n const mainDocumentRequest = Core.NetworkAnalyzer.findLastDocumentForUrl(networkRequests, mainDocumentUrl);\n if (!mainDocumentRequest) {\n throw new Core.LanternError('mainDocumentRequest not found');\n }\n const mainDocumentNode = networkNodeOutput.idToNodeMap.get(mainDocumentRequest.requestId);\n if (!mainDocumentNode) {\n throw new Core.LanternError('mainDocumentNode not found');\n }\n\n PageDependencyGraph.linkNetworkNodes(rootNode, networkNodeOutput);\n PageDependencyGraph.linkCPUNodes(rootNode, networkNodeOutput, cpuNodes);\n mainDocumentNode.setIsMainDocument(true);\n\n if (NetworkNode.findCycle(rootNode)) {\n // Uncomment the following if you are debugging cycles.\n // this.printGraph(rootNode);\n throw new Core.LanternError('Invalid dependency graph created, cycle detected');\n }\n\n return rootNode;\n }\n\n // Unused, but useful for debugging.\n static printGraph(rootNode: Node, widthInCharacters = 80): void {\n function padRight(str: string, target: number, padChar = ' '): string {\n return str + padChar.repeat(Math.max(target - str.length, 0));\n }\n\n const nodes: Node[] = [];\n rootNode.traverse(node => nodes.push(node));\n nodes.sort((a, b) => a.startTime - b.startTime);\n\n // Assign labels (A, B, C, ..., Z, Z1, Z2, ...) for each node.\n const nodeToLabel = new Map<BaseNode, string>();\n rootNode.traverse(node => {\n const ascii = 65 + nodeToLabel.size;\n let label;\n if (ascii > 90) {\n label = `Z${ascii - 90}`;\n } else {\n label = String.fromCharCode(ascii);\n }\n nodeToLabel.set(node, label);\n });\n\n const min = nodes[0].startTime;\n const max = nodes.reduce((max, node) => Math.max(max, node.endTime), 0);\n\n const totalTime = max - min;\n const timePerCharacter = totalTime / widthInCharacters;\n nodes.forEach(node => {\n const offset = Math.round((node.startTime - min) / timePerCharacter);\n const length = Math.ceil((node.endTime - node.startTime) / timePerCharacter);\n const bar = padRight('', offset) + padRight('', length, '=');\n\n // @ts-expect-error -- disambiguate displayName from across possible Node types.\n const displayName = node.request ? node.request.url : node.type;\n // eslint-disable-next-line\n console.log(padRight(bar, widthInCharacters), `| ${displayName.slice(0, 50)}`);\n });\n\n // Print labels for each node.\n\n // eslint-disable-next-line\n console.log();\n\n // Print dependencies.\n nodes.forEach(node => {\n // @ts-expect-error -- disambiguate displayName from across possible Node types.\n const displayName = node.request ? node.request.url : node.type;\n // eslint-disable-next-line\n console.log(nodeToLabel.get(node), displayName.slice(0, widthInCharacters - 5));\n\n for (const child of node.dependents) {\n // @ts-expect-error -- disambiguate displayName from across possible Node types.\n const displayName = child.request ? child.request.url : child.type;\n // eslint-disable-next-line\n console.log(' ->', nodeToLabel.get(child), displayName.slice(0, widthInCharacters - 10));\n }\n\n // eslint-disable-next-line\n console.log();\n });\n\n // Show cycle.\n const cyclePath = NetworkNode.findCycle(rootNode);\n // eslint-disable-next-line\n console.log('Cycle?', cyclePath ? 'yes' : 'no');\n if (cyclePath) {\n const path = [...cyclePath];\n path.push(path[0]);\n // eslint-disable-next-line\n console.log(path.map(node => nodeToLabel.get(node)).join(' -> '));\n }\n }\n}\n\nexport {PageDependencyGraph};\n"]}
@@ -364,7 +364,7 @@ class Simulator {
364
364
  * connection).
365
365
  */
366
366
  simulate(graph, options) {
367
- if (Graph.BaseNode.hasCycle(graph)) {
367
+ if (Graph.BaseNode.findCycle(graph)) {
368
368
  throw new Core.LanternError('Cannot simulate graph with cycle');
369
369
  }
370
370
  options = Object.assign({
@@ -1 +1 @@
1
- {"version":3,"file":"Simulator.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/simulation/Simulator.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,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;I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C;IAED;;;;OAIG;IACH,MAAM,CAAC,wBAAwB,CAAC,IAAgB;QAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,OAAO,IAAI,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. All rights reserved.\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.hasCycle(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,4DAA4D;AAC5D,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,MAA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AO,EAAC,SAAS,EAAC,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\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"]}
@@ -33,7 +33,6 @@
33
33
  "../../../../../../front_end/models/trace/LanternComputationData.ts",
34
34
  "../../../../../../front_end/models/trace/ModelImpl.ts",
35
35
  "../../../../../../front_end/models/trace/Processor.ts",
36
- "../../../../../../front_end/models/trace/TracingManager.ts",
37
36
  "../../../../../../front_end/legacy/legacy-defs.d.ts",
38
37
  "../../../../../../front_end/global_typings/global_defs.d.ts",
39
38
  "../../../../../../node_modules/@types/filesystem/index.d.ts"
@@ -6,6 +6,5 @@ import * as Lantern from './lantern/lantern.js';
6
6
  import * as LanternComputationData from './LanternComputationData.js';
7
7
  import * as TraceModel from './ModelImpl.js';
8
8
  import * as Processor from './Processor.js';
9
- import * as TracingManager from './TracingManager.js';
10
9
  import * as Types from './types/types.js';
11
- export { Extras, Handlers, Helpers, Insights, Lantern, LanternComputationData, Processor, TraceModel, TracingManager, Types, };
10
+ export { Extras, Handlers, Helpers, Insights, Lantern, LanternComputationData, Processor, TraceModel, Types, };
@@ -9,7 +9,6 @@ import * as Lantern from './lantern/lantern.js';
9
9
  import * as LanternComputationData from './LanternComputationData.js';
10
10
  import * as TraceModel from './ModelImpl.js';
11
11
  import * as Processor from './Processor.js';
12
- import * as TracingManager from './TracingManager.js';
13
12
  import * as Types from './types/types.js';
14
- export { Extras, Handlers, Helpers, Insights, Lantern, LanternComputationData, Processor, TraceModel, TracingManager, Types, };
13
+ export { Extras, Handlers, Helpers, Insights, Lantern, LanternComputationData, Processor, TraceModel, Types, };
15
14
  //# sourceMappingURL=trace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/trace.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,sBAAsB,EACtB,SAAS,EACT,UAAU,EACV,cAAc,EACd,KAAK,GACN,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\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 Extras from './extras/extras.js';\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Lantern from './lantern/lantern.js';\nimport * as LanternComputationData from './LanternComputationData.js';\nimport * as TraceModel from './ModelImpl.js';\nimport * as Processor from './Processor.js';\nimport * as TracingManager from './TracingManager.js';\nimport * as Types from './types/types.js';\n\nexport {\n Extras,\n Handlers,\n Helpers,\n Insights,\n Lantern,\n LanternComputationData,\n Processor,\n TraceModel,\n TracingManager,\n Types,\n};\n"]}
1
+ {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/trace.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,UAAU,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,sBAAsB,EACtB,SAAS,EACT,UAAU,EACV,KAAK,GACN,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\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 Extras from './extras/extras.js';\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Lantern from './lantern/lantern.js';\nimport * as LanternComputationData from './LanternComputationData.js';\nimport * as TraceModel from './ModelImpl.js';\nimport * as Processor from './Processor.js';\nimport * as Types from './types/types.js';\n\nexport {\n Extras,\n Handlers,\n Helpers,\n Insights,\n Lantern,\n LanternComputationData,\n Processor,\n TraceModel,\n Types,\n};\n"]}
@@ -4,7 +4,12 @@ export declare const extensionPalette: readonly ["primary", "primary-light", "pr
4
4
  export type ExtensionColorFromPalette = typeof extensionPalette[number];
5
5
  export interface ExtensionDataPayloadBase {
6
6
  color?: ExtensionColorFromPalette;
7
- properties?: Array<[string, string]>;
7
+ /**
8
+ * We document to users that we support only string values here, but because
9
+ * this is coming from user code the values could be anything, so we ensure we
10
+ * deal with bad data by typing this as unknown.
11
+ */
12
+ properties?: Array<[string, unknown]>;
8
13
  tooltipText?: string;
9
14
  }
10
15
  export type ExtensionDataPayload = ExtensionTrackEntryPayload | ExtensionMarkerPayload;
@@ -1 +1 @@
1
- {"version":3,"file":"Extensions.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/Extensions.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAQ7B,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS;IACT,eAAe;IACf,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,OAAO;IACP,SAAS;CACD,CAAC;AAiDX,MAAM,UAAU,wBAAwB,CAAC,OAA4B;IACnE,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,OAA4C;IAEvF,MAAM,QAAQ,GAAG,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC;IAC5F,OAAO,cAAc,IAAI,QAAQ,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAA4C;IAClF,OAAO,wBAAwB,CAAC,OAAO,CAAC,IAAI,4BAA4B,CAAC,OAAO,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAY;IACpD,OAAO,KAAK,CAAC,GAAG,KAAK,oBAAoB,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\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 {\n Args, ConsoleTimeStamp, Event, PerformanceMark, PerformanceMeasureBegin, Phase, SyntheticBased} from\n './TraceEvents.js';\n\nexport type ExtensionEntryType = 'track-entry'|'marker';\n\nexport const extensionPalette = [\n 'primary',\n 'primary-light',\n 'primary-dark',\n 'secondary',\n 'secondary-light',\n 'secondary-dark',\n 'tertiary',\n 'tertiary-light',\n 'tertiary-dark',\n 'error',\n 'warning',\n] as const;\n\nexport type ExtensionColorFromPalette = typeof extensionPalette[number];\n\nexport interface ExtensionDataPayloadBase {\n color?: ExtensionColorFromPalette;\n properties?: Array<[string, string]>;\n tooltipText?: string;\n}\n\nexport type ExtensionDataPayload = ExtensionTrackEntryPayload|ExtensionMarkerPayload;\n\nexport interface ExtensionTrackEntryPayload extends ExtensionDataPayloadBase {\n // Typed as possibly undefined since when no data type is provided\n // the entry is defaulted to a track entry\n dataType?: 'track-entry';\n // The name of the track the entry will be displayed in.\n // Entries intended to be displayed in the same track must contain the\n // same value in this property.\n // If undefined, measurement is added to the Timings track\n track: string;\n // The track group an entry’s track belongs to.\n // Entries intended to be displayed in the same track must contain the\n // same value in this property as well as the same value in the track\n // property.\n trackGroup?: string;\n}\n\nexport interface ExtensionMarkerPayload extends ExtensionDataPayloadBase {\n dataType: 'marker';\n}\n\n/**\n * Synthetic events created for extension tracks.\n */\nexport interface SyntheticExtensionTrackEntry extends\n SyntheticBased<Phase.COMPLETE, PerformanceMeasureBegin|PerformanceMark|ConsoleTimeStamp> {\n args: Args&ExtensionTrackEntryPayload;\n}\n\n/**\n * Synthetic events created for extension marks.\n */\nexport interface SyntheticExtensionMarker extends SyntheticBased<Phase.COMPLETE, PerformanceMark> {\n args: Args&ExtensionMarkerPayload;\n}\n\nexport type SyntheticExtensionEntry = SyntheticExtensionTrackEntry|SyntheticExtensionMarker;\n\nexport function isExtensionPayloadMarker(payload: {dataType?: string}): payload is ExtensionMarkerPayload {\n return payload.dataType === 'marker';\n}\n\nexport function isExtensionPayloadTrackEntry(payload: {track?: string, dataType?: string}):\n payload is ExtensionTrackEntryPayload {\n const hasTrack = 'track' in payload && Boolean(payload.track);\n const validEntryType = payload.dataType === 'track-entry' || payload.dataType === undefined;\n return validEntryType && hasTrack;\n}\n\nexport function isValidExtensionPayload(payload: {track?: string, dataType?: string}): payload is ExtensionDataPayload {\n return isExtensionPayloadMarker(payload) || isExtensionPayloadTrackEntry(payload);\n}\n\nexport function isSyntheticExtensionEntry(entry: Event): entry is SyntheticExtensionEntry {\n return entry.cat === 'devtools.extension';\n}\n\nexport interface ExtensionTrackData {\n // Name of the top level track. If it's a track group then this value\n // has the name of the group, otherwise it has the name of the track.\n name: string;\n isTrackGroup: boolean;\n // If this contains the data of a track group, this property contains\n // the entries of each of the tracks in the the group. If this is a\n // standalone track, then this contains that track's entries only.\n entriesByTrack: Record<string, SyntheticExtensionTrackEntry[]>;\n}\n"]}
1
+ {"version":3,"file":"Extensions.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/Extensions.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAQ7B,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS;IACT,eAAe;IACf,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,OAAO;IACP,SAAS;CACD,CAAC;AAsDX,MAAM,UAAU,wBAAwB,CAAC,OAA4B;IACnE,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,OAA4C;IAEvF,MAAM,QAAQ,GAAG,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,KAAK,aAAa,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC;IAC5F,OAAO,cAAc,IAAI,QAAQ,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAA4C;IAClF,OAAO,wBAAwB,CAAC,OAAO,CAAC,IAAI,4BAA4B,CAAC,OAAO,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAY;IACpD,OAAO,KAAK,CAAC,GAAG,KAAK,oBAAoB,CAAC;AAC5C,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\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 {\n Args, ConsoleTimeStamp, Event, PerformanceMark, PerformanceMeasureBegin, Phase, SyntheticBased} from\n './TraceEvents.js';\n\nexport type ExtensionEntryType = 'track-entry'|'marker';\n\nexport const extensionPalette = [\n 'primary',\n 'primary-light',\n 'primary-dark',\n 'secondary',\n 'secondary-light',\n 'secondary-dark',\n 'tertiary',\n 'tertiary-light',\n 'tertiary-dark',\n 'error',\n 'warning',\n] as const;\n\nexport type ExtensionColorFromPalette = typeof extensionPalette[number];\n\nexport interface ExtensionDataPayloadBase {\n color?: ExtensionColorFromPalette;\n /**\n * We document to users that we support only string values here, but because\n * this is coming from user code the values could be anything, so we ensure we\n * deal with bad data by typing this as unknown.\n */\n properties?: Array<[string, unknown]>;\n tooltipText?: string;\n}\n\nexport type ExtensionDataPayload = ExtensionTrackEntryPayload|ExtensionMarkerPayload;\n\nexport interface ExtensionTrackEntryPayload extends ExtensionDataPayloadBase {\n // Typed as possibly undefined since when no data type is provided\n // the entry is defaulted to a track entry\n dataType?: 'track-entry';\n // The name of the track the entry will be displayed in.\n // Entries intended to be displayed in the same track must contain the\n // same value in this property.\n // If undefined, measurement is added to the Timings track\n track: string;\n // The track group an entry’s track belongs to.\n // Entries intended to be displayed in the same track must contain the\n // same value in this property as well as the same value in the track\n // property.\n trackGroup?: string;\n}\n\nexport interface ExtensionMarkerPayload extends ExtensionDataPayloadBase {\n dataType: 'marker';\n}\n\n/**\n * Synthetic events created for extension tracks.\n */\nexport interface SyntheticExtensionTrackEntry extends\n SyntheticBased<Phase.COMPLETE, PerformanceMeasureBegin|PerformanceMark|ConsoleTimeStamp> {\n args: Args&ExtensionTrackEntryPayload;\n}\n\n/**\n * Synthetic events created for extension marks.\n */\nexport interface SyntheticExtensionMarker extends SyntheticBased<Phase.COMPLETE, PerformanceMark> {\n args: Args&ExtensionMarkerPayload;\n}\n\nexport type SyntheticExtensionEntry = SyntheticExtensionTrackEntry|SyntheticExtensionMarker;\n\nexport function isExtensionPayloadMarker(payload: {dataType?: string}): payload is ExtensionMarkerPayload {\n return payload.dataType === 'marker';\n}\n\nexport function isExtensionPayloadTrackEntry(payload: {track?: string, dataType?: string}):\n payload is ExtensionTrackEntryPayload {\n const hasTrack = 'track' in payload && Boolean(payload.track);\n const validEntryType = payload.dataType === 'track-entry' || payload.dataType === undefined;\n return validEntryType && hasTrack;\n}\n\nexport function isValidExtensionPayload(payload: {track?: string, dataType?: string}): payload is ExtensionDataPayload {\n return isExtensionPayloadMarker(payload) || isExtensionPayloadTrackEntry(payload);\n}\n\nexport function isSyntheticExtensionEntry(entry: Event): entry is SyntheticExtensionEntry {\n return entry.cat === 'devtools.extension';\n}\n\nexport interface ExtensionTrackData {\n // Name of the top level track. If it's a track group then this value\n // has the name of the group, otherwise it has the name of the track.\n name: string;\n isTrackGroup: boolean;\n // If this contains the data of a track group, this property contains\n // the entries of each of the tracks in the the group. If this is a\n // standalone track, then this contains that track's entries only.\n entriesByTrack: Record<string, SyntheticExtensionTrackEntry[]>;\n}\n"]}