@paulirish/trace_engine 0.0.27 → 0.0.29

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 (125) hide show
  1. package/core/platform/SetUtilities.d.ts +0 -1
  2. package/core/platform/SetUtilities.js +0 -14
  3. package/core/platform/SetUtilities.js.map +1 -1
  4. package/generated/protocol.d.ts +61 -6
  5. package/models/trace/LanternComputationData.js +4 -4
  6. package/models/trace/LanternComputationData.js.map +1 -1
  7. package/models/trace/ModelImpl.d.ts +23 -23
  8. package/models/trace/ModelImpl.js +20 -12
  9. package/models/trace/ModelImpl.js.map +1 -1
  10. package/models/trace/Processor.d.ts +6 -7
  11. package/models/trace/Processor.js +102 -29
  12. package/models/trace/Processor.js.map +1 -1
  13. package/models/trace/extras/URLForEntry.js +1 -1
  14. package/models/trace/extras/URLForEntry.js.map +1 -1
  15. package/models/trace/handlers/ExtensionTraceDataHandler.js +2 -6
  16. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
  17. package/models/trace/handlers/InvalidationsHandler.d.ts +1 -1
  18. package/models/trace/handlers/InvalidationsHandler.js +2 -21
  19. package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
  20. package/models/trace/handlers/LayoutShiftsHandler.d.ts +1 -0
  21. package/models/trace/handlers/LayoutShiftsHandler.js +5 -0
  22. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  23. package/models/trace/handlers/NetworkRequestsHandler.d.ts +15 -0
  24. package/models/trace/handlers/NetworkRequestsHandler.js +98 -2
  25. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  26. package/models/trace/handlers/types.d.ts +1 -8
  27. package/models/trace/handlers/types.js +1 -17
  28. package/models/trace/handlers/types.js.map +1 -1
  29. package/models/trace/helpers/Extensions.d.ts +1 -1
  30. package/models/trace/helpers/Extensions.js +22 -8
  31. package/models/trace/helpers/Extensions.js.map +1 -1
  32. package/models/trace/helpers/Network.d.ts +2 -0
  33. package/models/trace/helpers/Network.js +7 -0
  34. package/models/trace/helpers/Network.js.map +1 -0
  35. package/models/trace/helpers/SyntheticEvents.d.ts +3 -8
  36. package/models/trace/helpers/SyntheticEvents.js +16 -25
  37. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  38. package/models/trace/helpers/Timing.d.ts +1 -0
  39. package/models/trace/helpers/Timing.js +3 -0
  40. package/models/trace/helpers/Timing.js.map +1 -1
  41. package/models/trace/helpers/Trace.d.ts +2 -0
  42. package/models/trace/helpers/Trace.js +3 -3
  43. package/models/trace/helpers/Trace.js.map +1 -1
  44. package/models/trace/helpers/helpers-tsconfig.json +1 -0
  45. package/models/trace/helpers/helpers.d.ts +1 -0
  46. package/models/trace/helpers/helpers.js +1 -0
  47. package/models/trace/helpers/helpers.js.map +1 -1
  48. package/models/trace/insights/LargestContentfulPaint.d.ts +2 -8
  49. package/models/trace/insights/LargestContentfulPaint.js +9 -5
  50. package/models/trace/insights/LargestContentfulPaint.js.map +1 -1
  51. package/models/trace/insights/RenderBlocking.d.ts +4 -2
  52. package/models/trace/insights/RenderBlocking.js +76 -1
  53. package/models/trace/insights/RenderBlocking.js.map +1 -1
  54. package/models/trace/insights/insights-tsconfig.json +3 -0
  55. package/models/trace/insights/types.d.ts +27 -19
  56. package/models/trace/insights/types.js.map +1 -1
  57. package/models/trace/lantern/core/NetworkAnalyzer.js +2 -1
  58. package/models/trace/lantern/core/NetworkAnalyzer.js.map +1 -1
  59. package/models/trace/lantern/graph/BaseNode.d.ts +5 -1
  60. package/models/trace/lantern/graph/BaseNode.js +11 -6
  61. package/models/trace/lantern/graph/BaseNode.js.map +1 -1
  62. package/models/trace/lantern/graph/PageDependencyGraph.js +8 -8
  63. package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
  64. package/models/trace/lantern/metrics/Interactive.d.ts +1 -1
  65. package/models/trace/lantern/metrics/Interactive.js +5 -4
  66. package/models/trace/lantern/metrics/Interactive.js.map +1 -1
  67. package/models/trace/lantern/metrics/LargestContentfulPaint.d.ts +1 -1
  68. package/models/trace/lantern/metrics/LargestContentfulPaint.js +3 -3
  69. package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -1
  70. package/models/trace/lantern/metrics/MaxPotentialFID.d.ts +1 -1
  71. package/models/trace/lantern/metrics/MaxPotentialFID.js +3 -2
  72. package/models/trace/lantern/metrics/MaxPotentialFID.js.map +1 -1
  73. package/models/trace/lantern/metrics/Metric.d.ts +1 -1
  74. package/models/trace/lantern/metrics/Metric.js +5 -4
  75. package/models/trace/lantern/metrics/Metric.js.map +1 -1
  76. package/models/trace/lantern/metrics/SpeedIndex.d.ts +1 -1
  77. package/models/trace/lantern/metrics/SpeedIndex.js +6 -5
  78. package/models/trace/lantern/metrics/SpeedIndex.js.map +1 -1
  79. package/models/trace/lantern/metrics/TotalBlockingTime.d.ts +1 -1
  80. package/models/trace/lantern/metrics/TotalBlockingTime.js +6 -5
  81. package/models/trace/lantern/metrics/TotalBlockingTime.js.map +1 -1
  82. package/models/trace/lantern/simulation/ConnectionPool.js +3 -3
  83. package/models/trace/lantern/simulation/ConnectionPool.js.map +1 -1
  84. package/models/trace/lantern/simulation/SimulationTimingMap.d.ts +0 -7
  85. package/models/trace/lantern/simulation/SimulationTimingMap.js +15 -14
  86. package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -1
  87. package/models/trace/lantern/simulation/Simulator.js +10 -9
  88. package/models/trace/lantern/simulation/Simulator.js.map +1 -1
  89. package/models/trace/lantern/simulation/simulation-tsconfig.json +3 -0
  90. package/models/trace/lantern/types/{lantern.d.ts → Lantern.d.ts} +1 -1
  91. package/models/trace/lantern/types/{lantern.js.map → Lantern.js.map} +1 -1
  92. package/models/trace/types/Extensions.d.ts +29 -34
  93. package/models/trace/types/Extensions.js +7 -3
  94. package/models/trace/types/Extensions.js.map +1 -1
  95. package/models/trace/types/File.d.ts +16 -0
  96. package/models/trace/types/File.js.map +1 -1
  97. package/models/trace/types/TraceEvents.d.ts +31 -13
  98. package/models/trace/types/TraceEvents.js +14 -3
  99. package/models/trace/types/TraceEvents.js.map +1 -1
  100. package/package.json +1 -1
  101. package/models/trace/lantern/BaseNode.d.ts +0 -91
  102. package/models/trace/lantern/BaseNode.js +0 -268
  103. package/models/trace/lantern/BaseNode.js.map +0 -1
  104. package/models/trace/lantern/CPUNode.d.ts +0 -24
  105. package/models/trace/lantern/CPUNode.js +0 -64
  106. package/models/trace/lantern/CPUNode.js.map +0 -1
  107. package/models/trace/lantern/LanternError.d.ts +0 -3
  108. package/models/trace/lantern/LanternError.js +0 -7
  109. package/models/trace/lantern/LanternError.js.map +0 -1
  110. package/models/trace/lantern/MetricsModule.d.ts +0 -11
  111. package/models/trace/lantern/MetricsModule.js +0 -14
  112. package/models/trace/lantern/MetricsModule.js.map +0 -1
  113. package/models/trace/lantern/NetworkNode.d.ts +0 -22
  114. package/models/trace/lantern/NetworkNode.js +0 -83
  115. package/models/trace/lantern/NetworkNode.js.map +0 -1
  116. package/models/trace/lantern/PageDependencyGraph.d.ts +0 -43
  117. package/models/trace/lantern/PageDependencyGraph.js +0 -509
  118. package/models/trace/lantern/PageDependencyGraph.js.map +0 -1
  119. package/models/trace/lantern/SimulationModule.d.ts +0 -17
  120. package/models/trace/lantern/SimulationModule.js +0 -13
  121. package/models/trace/lantern/SimulationModule.js.map +0 -1
  122. package/models/trace/lantern/simulation/NetworkAnalyzer.d.ts +0 -112
  123. package/models/trace/lantern/simulation/NetworkAnalyzer.js +0 -486
  124. package/models/trace/lantern/simulation/NetworkAnalyzer.js.map +0 -1
  125. /package/models/trace/lantern/types/{lantern.js → Lantern.js} +0 -0
@@ -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,KAAK,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAC,cAAc,EA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,CAAC,UAAU,CAAC;QACzE,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,UAAU,GAAG,WAAW,GAAG,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,IAAI,CAAC;QAEnD,6EAA6E;QAC7E,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;IACxC,CAAC;IAED,MAAM,KAAK,cAAc;QACvB,OAAO,2BAA2B,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,yBAAyB,CAAC,IAAgB;QAC/C,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 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 Error(`Invalid rtt ${this._rtt}`);\n }\n if (!Number.isFinite(this._throughput)) {\n throw new Error(`Invalid rtt ${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 Error('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 condidtions 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 Error('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 durin 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 Error('Unsupported');\n }\n if (!('bytesDownloaded' in timingData)) {\n throw new Error('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]> =\n 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 Error('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 Error('Failed to start a node');\n }\n\n // set the available throughput for all connections based on # inflight\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 Error('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 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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AIG;IACH,MAAM,CAAC,yBAAyB,CAAC,IAAgB;QAC/C,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 rtt ${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 condidtions 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 durin 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]> =\n 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 # inflight\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 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"]}
@@ -40,6 +40,9 @@
40
40
  "../../../../../../../../node_modules/@types/filesystem/index.d.ts"
41
41
  ],
42
42
  "references": [
43
+ {
44
+ "path": "../core/bundle-tsconfig.json"
45
+ },
43
46
  {
44
47
  "path": "../graph/bundle-tsconfig.json"
45
48
  },
@@ -170,7 +170,7 @@ export declare namespace Simulation {
170
170
  /** The method used to throttle the network. */
171
171
  throttlingMethod: 'devtools' | 'simulate' | 'provided';
172
172
  /** The throttling config settings. */
173
- throttling: Required<ThrottlingSettings>;
173
+ throttling?: Required<ThrottlingSettings>;
174
174
  /** Precomputed lantern estimates to use instead of observed analysis. */
175
175
  precomputedLanternData?: PrecomputedLanternData | null;
176
176
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Lantern.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/types/Lantern.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IACxB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,cAAc,EAAE,gBAAgB;IAChC,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,WAAW;IACtB,kBAAkB,EAAE,oBAAoB;IACxC,QAAQ,EAAE,UAAU;CACZ,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 * as Protocol from '../../../../generated/protocol.js';\n\nexport const NetworkRequestTypes = {\n XHR: 'XHR',\n Fetch: 'Fetch',\n EventSource: 'EventSource',\n Script: 'Script',\n Stylesheet: 'Stylesheet',\n Image: 'Image',\n Media: 'Media',\n Font: 'Font',\n Document: 'Document',\n TextTrack: 'TextTrack',\n WebSocket: 'WebSocket',\n Other: 'Other',\n Manifest: 'Manifest',\n SignedExchange: 'SignedExchange',\n Ping: 'Ping',\n Preflight: 'Preflight',\n CSPViolationReport: 'CSPViolationReport',\n Prefetch: 'Prefetch',\n} as const;\n\nexport type TraceEvent = {\n name: string,\n args: {\n name?: string,\n data?: {\n frame?: string,\n readyState?: number,\n stackTrace?: {\n url: string,\n }[],\n url?: string,\n },\n },\n pid: number,\n tid: number,\n /** Timestamp of the event in microseconds. */\n ts: number,\n dur: number,\n};\nexport type Trace = {\n traceEvents: TraceEvent[],\n};\nexport type ResourcePriority = ('VeryLow'|'Low'|'Medium'|'High'|'VeryHigh');\nexport type ResourceType = keyof typeof NetworkRequestTypes;\ntype InitiatorType = ('parser'|'script'|'preload'|'SignedExchange'|'preflight'|'other');\nexport type ResourceTiming = Protocol.Network.ResourceTiming;\ntype CallStack = {\n callFrames: Array<{\n scriptId: string,\n url: string,\n lineNumber: number,\n columnNumber: number,\n functionName: string,\n }>,\n parent?: CallStack,\n};\n\nexport type ParsedURL = {\n /**\n * Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)\n */\n scheme: string,\n /**\n * Equivalent to a `new URL(url).hostname`\n */\n host: string,\n securityOrigin: string,\n};\n\n// When Lantern NetworkRequests are constructed, the source-of-truth of the network record is given as `rawRequest`.\n// Internally Lantern doesn't care about the type of this field, so a default type is given to simplify internal code\n// by avoiding unnecessary typescript overhead.\n// If callers want to access the underlying network record, they are expected to make use of this generic on top-level\n// interfaces like Simulator.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyNetworkObject = any;\n\nexport type NetworkRequest<T = AnyNetworkObject> = {\n requestId: string,\n connectionId: number,\n connectionReused: boolean,\n url: string,\n protocol: string,\n parsedURL: ParsedURL,\n documentURL: string,\n /** When the renderer process initially discovers a network request, in milliseconds. */\n rendererStartTime: number,\n /**\n * When the network service is about to handle a request, ie. just before going to the\n * HTTP cache or going to the network for DNS/connection setup, in milliseconds.\n */\n networkRequestTime: number,\n /**\n * When the last byte of the response headers is received, in milliseconds.\n * Equal to networkRequestTime if no data is recieved over the\n * network (ex: cached requests or data urls).\n */\n responseHeadersEndTime: number,\n /** When the last byte of the response body is received, in milliseconds. */\n networkEndTime: number,\n transferSize: number,\n resourceSize: number,\n fromDiskCache: boolean,\n fromMemoryCache: boolean,\n isLinkPreload: boolean,\n finished: boolean,\n failed: boolean,\n statusCode: number,\n /** The network request that redirected to this one */\n redirectSource: NetworkRequest<T>|undefined,\n /** The network request that this one redirected to */\n redirectDestination: NetworkRequest<T>|undefined,\n // TODO: can't use Protocol.Network.Initiator because of type mismatch in Lighthouse initiator.\n initiator: {\n type: InitiatorType,\n url?: string,\n stack?: CallStack,\n },\n initiatorRequest: NetworkRequest<T>|undefined,\n /** The chain of network requests that redirected to this one */\n redirects: NetworkRequest[]|undefined,\n timing: Protocol.Network.ResourceTiming|undefined,\n resourceType: ResourceType|undefined,\n mimeType: string,\n priority: ResourcePriority,\n frameId: string|undefined,\n fromWorker: boolean,\n /**\n * Optional value for how long the server took to respond to this request.\n * When not provided, the server response time is derived from the timing object.\n */\n serverResponseTime?: number,\n /**\n * Implementation-specific canoncial data structure that this Lantern NetworkRequest\n * was derived from.\n * Users of Lantern create a NetworkRequest matching this interface,\n * but can store the source-of-truth for their network model in this property.\n * This is then accessible as a read-only property on NetworkNode.\n */\n rawRequest?: T,\n};\n\nexport namespace Simulation {\n export interface URL {\n /** URL of the initially requested URL */\n requestedUrl?: string;\n /** URL of the last document request */\n mainDocumentUrl?: string;\n }\n\n /** Simulation settings that control the amount of network & cpu throttling in the run. */\n export interface ThrottlingSettings {\n /** The round trip time in milliseconds. */\n rttMs?: number;\n /** The network throughput in kilobits per second. */\n throughputKbps?: number;\n // devtools settings\n /** The network request latency in milliseconds. */\n requestLatencyMs?: number;\n /** The network download throughput in kilobits per second. */\n downloadThroughputKbps?: number;\n /** The network upload throughput in kilobits per second. */\n uploadThroughputKbps?: number;\n // used by both\n /** The amount of slowdown applied to the cpu (1/<cpuSlowdownMultiplier>). */\n cpuSlowdownMultiplier?: number;\n }\n\n export interface PrecomputedLanternData {\n additionalRttByOrigin: {[origin: string]: number};\n serverResponseTimeByOrigin: {[origin: string]: number};\n }\n\n export interface Settings {\n networkAnalysis: {\n rtt: number,\n additionalRttByOrigin: Map<string, number>,\n serverResponseTimeByOrigin: Map<string, number>,\n throughput: number,\n };\n /** The method used to throttle the network. */\n throttlingMethod: 'devtools'|'simulate'|'provided';\n /** The throttling config settings. */\n throttling: Required<ThrottlingSettings>;\n /** Precomputed lantern estimates to use instead of observed analysis. */\n precomputedLanternData?: PrecomputedLanternData|null;\n }\n\n export interface Options {\n rtt?: number;\n throughput?: number;\n observedThroughput: number;\n maximumConcurrentRequests?: number;\n cpuSlowdownMultiplier?: number;\n layoutTaskMultiplier?: number;\n additionalRttByOrigin?: Map<string, number>;\n serverResponseTimeByOrigin?: Map<string, number>;\n }\n\n export interface ProcessedNavigation {\n timestamps: {\n firstContentfulPaint: number,\n largestContentfulPaint?: number,\n };\n }\n\n export interface NodeTiming {\n startTime: number;\n endTime: number;\n duration: number;\n }\n}\n"]}
1
+ {"version":3,"file":"Lantern.js","sourceRoot":"","sources":["../../../../../../../../front_end/models/trace/lantern/types/Lantern.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IACxB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,cAAc,EAAE,gBAAgB;IAChC,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,WAAW;IACtB,kBAAkB,EAAE,oBAAoB;IACxC,QAAQ,EAAE,UAAU;CACZ,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 * as Protocol from '../../../../generated/protocol.js';\n\nexport const NetworkRequestTypes = {\n XHR: 'XHR',\n Fetch: 'Fetch',\n EventSource: 'EventSource',\n Script: 'Script',\n Stylesheet: 'Stylesheet',\n Image: 'Image',\n Media: 'Media',\n Font: 'Font',\n Document: 'Document',\n TextTrack: 'TextTrack',\n WebSocket: 'WebSocket',\n Other: 'Other',\n Manifest: 'Manifest',\n SignedExchange: 'SignedExchange',\n Ping: 'Ping',\n Preflight: 'Preflight',\n CSPViolationReport: 'CSPViolationReport',\n Prefetch: 'Prefetch',\n} as const;\n\nexport type TraceEvent = {\n name: string,\n args: {\n name?: string,\n data?: {\n frame?: string,\n readyState?: number,\n stackTrace?: {\n url: string,\n }[],\n url?: string,\n },\n },\n pid: number,\n tid: number,\n /** Timestamp of the event in microseconds. */\n ts: number,\n dur: number,\n};\nexport type Trace = {\n traceEvents: TraceEvent[],\n};\nexport type ResourcePriority = ('VeryLow'|'Low'|'Medium'|'High'|'VeryHigh');\nexport type ResourceType = keyof typeof NetworkRequestTypes;\ntype InitiatorType = ('parser'|'script'|'preload'|'SignedExchange'|'preflight'|'other');\nexport type ResourceTiming = Protocol.Network.ResourceTiming;\ntype CallStack = {\n callFrames: Array<{\n scriptId: string,\n url: string,\n lineNumber: number,\n columnNumber: number,\n functionName: string,\n }>,\n parent?: CallStack,\n};\n\nexport type ParsedURL = {\n /**\n * Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)\n */\n scheme: string,\n /**\n * Equivalent to a `new URL(url).hostname`\n */\n host: string,\n securityOrigin: string,\n};\n\n// When Lantern NetworkRequests are constructed, the source-of-truth of the network record is given as `rawRequest`.\n// Internally Lantern doesn't care about the type of this field, so a default type is given to simplify internal code\n// by avoiding unnecessary typescript overhead.\n// If callers want to access the underlying network record, they are expected to make use of this generic on top-level\n// interfaces like Simulator.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyNetworkObject = any;\n\nexport type NetworkRequest<T = AnyNetworkObject> = {\n requestId: string,\n connectionId: number,\n connectionReused: boolean,\n url: string,\n protocol: string,\n parsedURL: ParsedURL,\n documentURL: string,\n /** When the renderer process initially discovers a network request, in milliseconds. */\n rendererStartTime: number,\n /**\n * When the network service is about to handle a request, ie. just before going to the\n * HTTP cache or going to the network for DNS/connection setup, in milliseconds.\n */\n networkRequestTime: number,\n /**\n * When the last byte of the response headers is received, in milliseconds.\n * Equal to networkRequestTime if no data is recieved over the\n * network (ex: cached requests or data urls).\n */\n responseHeadersEndTime: number,\n /** When the last byte of the response body is received, in milliseconds. */\n networkEndTime: number,\n transferSize: number,\n resourceSize: number,\n fromDiskCache: boolean,\n fromMemoryCache: boolean,\n isLinkPreload: boolean,\n finished: boolean,\n failed: boolean,\n statusCode: number,\n /** The network request that redirected to this one */\n redirectSource: NetworkRequest<T>|undefined,\n /** The network request that this one redirected to */\n redirectDestination: NetworkRequest<T>|undefined,\n // TODO: can't use Protocol.Network.Initiator because of type mismatch in Lighthouse initiator.\n initiator: {\n type: InitiatorType,\n url?: string,\n stack?: CallStack,\n },\n initiatorRequest: NetworkRequest<T>|undefined,\n /** The chain of network requests that redirected to this one */\n redirects: NetworkRequest[]|undefined,\n timing: Protocol.Network.ResourceTiming|undefined,\n resourceType: ResourceType|undefined,\n mimeType: string,\n priority: ResourcePriority,\n frameId: string|undefined,\n fromWorker: boolean,\n /**\n * Optional value for how long the server took to respond to this request.\n * When not provided, the server response time is derived from the timing object.\n */\n serverResponseTime?: number,\n /**\n * Implementation-specific canoncial data structure that this Lantern NetworkRequest\n * was derived from.\n * Users of Lantern create a NetworkRequest matching this interface,\n * but can store the source-of-truth for their network model in this property.\n * This is then accessible as a read-only property on NetworkNode.\n */\n rawRequest?: T,\n};\n\nexport namespace Simulation {\n export interface URL {\n /** URL of the initially requested URL */\n requestedUrl?: string;\n /** URL of the last document request */\n mainDocumentUrl?: string;\n }\n\n /** Simulation settings that control the amount of network & cpu throttling in the run. */\n export interface ThrottlingSettings {\n /** The round trip time in milliseconds. */\n rttMs?: number;\n /** The network throughput in kilobits per second. */\n throughputKbps?: number;\n // devtools settings\n /** The network request latency in milliseconds. */\n requestLatencyMs?: number;\n /** The network download throughput in kilobits per second. */\n downloadThroughputKbps?: number;\n /** The network upload throughput in kilobits per second. */\n uploadThroughputKbps?: number;\n // used by both\n /** The amount of slowdown applied to the cpu (1/<cpuSlowdownMultiplier>). */\n cpuSlowdownMultiplier?: number;\n }\n\n export interface PrecomputedLanternData {\n additionalRttByOrigin: {[origin: string]: number};\n serverResponseTimeByOrigin: {[origin: string]: number};\n }\n\n export interface Settings {\n networkAnalysis: {\n rtt: number,\n additionalRttByOrigin: Map<string, number>,\n serverResponseTimeByOrigin: Map<string, number>,\n throughput: number,\n };\n /** The method used to throttle the network. */\n throttlingMethod: 'devtools'|'simulate'|'provided';\n /** The throttling config settings. */\n throttling?: Required<ThrottlingSettings>;\n /** Precomputed lantern estimates to use instead of observed analysis. */\n precomputedLanternData?: PrecomputedLanternData|null;\n }\n\n export interface Options {\n rtt?: number;\n throughput?: number;\n observedThroughput: number;\n maximumConcurrentRequests?: number;\n cpuSlowdownMultiplier?: number;\n layoutTaskMultiplier?: number;\n additionalRttByOrigin?: Map<string, number>;\n serverResponseTimeByOrigin?: Map<string, number>;\n }\n\n export interface ProcessedNavigation {\n timestamps: {\n firstContentfulPaint: number,\n largestContentfulPaint?: number,\n };\n }\n\n export interface NodeTiming {\n startTime: number;\n endTime: number;\n duration: number;\n }\n}\n"]}
@@ -1,49 +1,29 @@
1
1
  import { type SyntheticTraceEntry, type TraceEventArgs, type TraceEventData } from './TraceEvents.js';
2
- export declare const enum ExtensionEntryType {
3
- TRACK_ENTRY = "track-entry",
4
- MARKER = "marker"
5
- }
2
+ export type ExtensionEntryType = 'track-entry' | 'marker';
6
3
  declare const extensionPalette: readonly ["primary", "primary-light", "primary-dark", "secondary", "secondary-light", "secondary-dark", "tertiary", "tertiary-light", "tertiary-dark", "error"];
7
4
  export type ExtensionColorFromPalette = typeof extensionPalette[number];
8
5
  export declare function colorIsValid(color: string): boolean;
9
6
  export interface ExtensionDataPayload {
10
- metadata: {
11
- dataType: ExtensionEntryType;
12
- extensionName: string;
13
- };
14
- }
15
- export interface ExtensionFlameChartEntryPayload extends ExtensionDataPayload {
16
- metadata: ExtensionDataPayload['metadata'] & {
17
- dataType: ExtensionEntryType.TRACK_ENTRY;
18
- };
19
- color?: ExtensionColorFromPalette;
20
- track: string;
21
- detailsPairs?: [string, string][];
22
- hintText?: string;
23
- }
24
- export interface ExtensionMarkerPayload extends ExtensionDataPayload {
25
- metadata: ExtensionDataPayload['metadata'] & {
26
- dataType: ExtensionEntryType.MARKER;
27
- };
7
+ dataType?: 'track-entry' | 'marker';
28
8
  color?: ExtensionColorFromPalette;
9
+ track?: string;
29
10
  detailsPairs?: [string, string][];
30
11
  hintText?: string;
31
12
  }
32
- export interface SyntheticExtensionFlameChartEntry extends SyntheticTraceEntry {
33
- args: TraceEventArgs & ExtensionFlameChartEntryPayload;
13
+ export interface ExtensionTrackEntryPayload extends ExtensionDataPayload {
14
+ dataType?: 'track-entry';
15
+ track: string;
16
+ trackGroup?: string;
34
17
  }
35
- export interface SyntheticExtensionMarker extends SyntheticTraceEntry {
36
- args: TraceEventArgs & ExtensionMarkerPayload;
18
+ export interface ExtensionMarkerPayload extends ExtensionDataPayload {
19
+ dataType: 'marker';
20
+ track: undefined;
37
21
  }
38
- export type SyntheticExtensionEntry = SyntheticExtensionFlameChartEntry | SyntheticExtensionMarker;
39
- export declare function isExtensionPayloadMarker(payload: ExtensionDataPayload): payload is ExtensionMarkerPayload;
40
- export declare function isExtensionPayloadFlameChartEntry(payload: ExtensionDataPayload): payload is ExtensionFlameChartEntryPayload;
41
- export declare function isSyntheticExtensionEntry(entry: TraceEventData): entry is SyntheticExtensionEntry;
42
22
  /**
43
23
  * Synthetic events created for extension tracks.
44
24
  */
45
- export interface SyntheticExtensionFlameChartEntry extends SyntheticTraceEntry {
46
- args: TraceEventArgs & ExtensionFlameChartEntryPayload;
25
+ export interface SyntheticExtensionTrackChartEntry extends SyntheticTraceEntry {
26
+ args: TraceEventArgs & ExtensionTrackEntryPayload;
47
27
  cat: 'devtools.extension';
48
28
  }
49
29
  /**
@@ -53,9 +33,24 @@ export interface SyntheticExtensionMarker extends SyntheticTraceEntry {
53
33
  args: TraceEventArgs & ExtensionMarkerPayload;
54
34
  cat: 'devtools.extension';
55
35
  }
36
+ export type SyntheticExtensionEntry = SyntheticExtensionTrackChartEntry | SyntheticExtensionMarker;
37
+ export declare function isExtensionPayloadMarker(payload: {
38
+ dataType?: string;
39
+ }): payload is ExtensionMarkerPayload;
40
+ export declare function isExtensionPayloadTrackEntry(payload: {
41
+ track?: string;
42
+ dataType?: string;
43
+ }): payload is ExtensionTrackEntryPayload;
44
+ export declare function isValidExtensionPayload(payload: {
45
+ track?: string;
46
+ dataType?: string;
47
+ }): payload is ExtensionDataPayload;
48
+ export declare function isSyntheticExtensionEntry(entry: TraceEventData): entry is SyntheticExtensionEntry;
56
49
  export interface ExtensionTrackData {
57
50
  name: string;
58
- extensionName: string;
59
- flameChartEntries: SyntheticExtensionFlameChartEntry[];
51
+ isTrackGroup: boolean;
52
+ entriesByTrack: {
53
+ [x: string]: SyntheticExtensionTrackChartEntry[];
54
+ };
60
55
  }
61
56
  export {};
@@ -17,11 +17,15 @@ export function colorIsValid(color) {
17
17
  return extensionPalette.includes(color);
18
18
  }
19
19
  export function isExtensionPayloadMarker(payload) {
20
- return payload.metadata.dataType === "marker" /* ExtensionEntryType.MARKER */;
20
+ return payload.dataType === 'marker';
21
21
  }
22
- export function isExtensionPayloadFlameChartEntry(payload) {
22
+ export function isExtensionPayloadTrackEntry(payload) {
23
23
  const hasTrack = 'track' in payload && Boolean(payload.track);
24
- return payload.metadata.dataType === "track-entry" /* ExtensionEntryType.TRACK_ENTRY */ && hasTrack;
24
+ const validEntryType = payload.dataType === 'track-entry' || payload.dataType === undefined;
25
+ return validEntryType && hasTrack;
26
+ }
27
+ export function isValidExtensionPayload(payload) {
28
+ return isExtensionPayloadMarker(payload) || isExtensionPayloadTrackEntry(payload);
25
29
  }
26
30
  export function isSyntheticExtensionEntry(entry) {
27
31
  return entry.cat === 'devtools.extension';
@@ -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;AAa7B,MAAM,gBAAgB,GAAG;IACvB,SAAS;IACT,eAAe;IACf,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,OAAO;CACC,CAAC;AAIX,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AA8BD,MAAM,UAAU,wBAAwB,CAAC,OAA6B;IACpE,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,6CAA8B,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,OAA6B;IAE7E,MAAM,QAAQ,GAAG,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC,QAAQ,CAAC,QAAQ,uDAAmC,IAAI,QAAQ,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAAqB;IAC7D,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 {\n type SyntheticTraceEntry,\n type TraceEventArgs,\n type TraceEventData,\n} from './TraceEvents.js';\n\nexport const enum ExtensionEntryType {\n TRACK_ENTRY = 'track-entry',\n MARKER = 'marker',\n}\n\nconst 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] as const;\n\nexport type ExtensionColorFromPalette = typeof extensionPalette[number];\n\nexport function colorIsValid(color: string): boolean {\n return (extensionPalette as readonly string[]).includes(color);\n}\n\nexport interface ExtensionDataPayload {\n metadata: {dataType: ExtensionEntryType, extensionName: string};\n}\nexport interface ExtensionFlameChartEntryPayload extends ExtensionDataPayload {\n metadata: ExtensionDataPayload['metadata']&{dataType: ExtensionEntryType.TRACK_ENTRY};\n color?: ExtensionColorFromPalette;\n track: string;\n detailsPairs?: [string, string][];\n hintText?: string;\n}\n\nexport interface ExtensionMarkerPayload extends ExtensionDataPayload {\n metadata: ExtensionDataPayload['metadata']&{dataType: ExtensionEntryType.MARKER};\n color?: ExtensionColorFromPalette;\n detailsPairs?: [string, string][];\n hintText?: string;\n}\n\nexport interface SyntheticExtensionFlameChartEntry extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionFlameChartEntryPayload;\n}\n\nexport interface SyntheticExtensionMarker extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionMarkerPayload;\n}\n\nexport type SyntheticExtensionEntry = SyntheticExtensionFlameChartEntry|SyntheticExtensionMarker;\n\nexport function isExtensionPayloadMarker(payload: ExtensionDataPayload): payload is ExtensionMarkerPayload {\n return payload.metadata.dataType === ExtensionEntryType.MARKER;\n}\n\nexport function isExtensionPayloadFlameChartEntry(payload: ExtensionDataPayload):\n payload is ExtensionFlameChartEntryPayload {\n const hasTrack = 'track' in payload && Boolean(payload.track);\n return payload.metadata.dataType === ExtensionEntryType.TRACK_ENTRY && hasTrack;\n}\n\nexport function isSyntheticExtensionEntry(entry: TraceEventData): entry is SyntheticExtensionEntry {\n return entry.cat === 'devtools.extension';\n}\n\n/**\n * Synthetic events created for extension tracks.\n */\nexport interface SyntheticExtensionFlameChartEntry extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionFlameChartEntryPayload;\n cat: 'devtools.extension';\n}\n\n/**\n * Synthetic events created for extension marks.\n */\nexport interface SyntheticExtensionMarker extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionMarkerPayload;\n cat: 'devtools.extension';\n}\n\nexport interface ExtensionTrackData {\n name: string;\n extensionName: string;\n flameChartEntries: SyntheticExtensionFlameChartEntry[];\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;AAU7B,MAAM,gBAAgB,GAAG;IACvB,SAAS;IACT,eAAe;IACf,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,OAAO;CACC,CAAC;AAIX,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAiDD,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,KAAqB;IAC7D,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 {\n type SyntheticTraceEntry,\n type TraceEventArgs,\n type TraceEventData,\n} from './TraceEvents.js';\n\nexport type ExtensionEntryType = 'track-entry'|'marker';\n\nconst 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] as const;\n\nexport type ExtensionColorFromPalette = typeof extensionPalette[number];\n\nexport function colorIsValid(color: string): boolean {\n return (extensionPalette as readonly string[]).includes(color);\n}\n\nexport interface ExtensionDataPayload {\n dataType?: 'track-entry'|'marker';\n color?: ExtensionColorFromPalette;\n track?: string;\n detailsPairs?: [string, string][];\n hintText?: string;\n}\n\nexport interface ExtensionTrackEntryPayload extends ExtensionDataPayload {\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 ExtensionDataPayload {\n dataType: 'marker';\n track: undefined;\n}\n\n/**\n * Synthetic events created for extension tracks.\n */\nexport interface SyntheticExtensionTrackChartEntry extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionTrackEntryPayload;\n cat: 'devtools.extension';\n}\n\n/**\n * Synthetic events created for extension marks.\n */\nexport interface SyntheticExtensionMarker extends SyntheticTraceEntry {\n args: TraceEventArgs&ExtensionMarkerPayload;\n cat: 'devtools.extension';\n}\n\nexport type SyntheticExtensionEntry = SyntheticExtensionTrackChartEntry|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: TraceEventData): 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: {\n [x: string]: SyntheticExtensionTrackChartEntry[],\n };\n}\n"]}
@@ -18,6 +18,22 @@ export declare const enum EventKeyType {
18
18
  SyntheticEvent = "s",
19
19
  ProfileCall = "p"
20
20
  }
21
+ /**
22
+ * Represents an object that is saved in the file when a user creates a label for an entry in the timeline.
23
+ */
24
+ export interface EntryLabelAnnotation {
25
+ type: 'ENTRY_LABEL';
26
+ entry: TraceEventData;
27
+ label: string;
28
+ }
29
+ /**
30
+ * `Annotation` are the user-created annotations that are saved into the metadata.
31
+ * Those annotations are rendered on the timeline by `Overlays.ts`
32
+ *
33
+ * TODO: Implement other OverlayAnnotations (annotated time ranges, links between entries).
34
+ * TODO: Save/load overlay annotations to/from the trace file.
35
+ */
36
+ export type Annotation = EntryLabelAnnotation;
21
37
  export type RawEventKey = `${EventKeyType.RawEvent}-${number}`;
22
38
  export type SyntheticEventKey = `${EventKeyType.SyntheticEvent}-${number}`;
23
39
  export type ProfileCallKey = `${EventKeyType.ProfileCall}-${ProcessID}-${ThreadID}-${SampleIndex}-${Protocol.integer}`;
@@ -1 +1 @@
1
- {"version":3,"file":"File.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/File.ts"],"names":[],"mappings":"AAuFA,MAAM,UAAU,qBAAqB,CAAC,GAA8B;IAClE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEtB,QAAQ,IAAI,EAAE,CAAC;QACb;YACE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAClB,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnG,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;YACpD,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;gBACd,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,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2023 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.\nimport type * as Protocol from '../../../generated/protocol.js';\n\nimport {type TraceWindowMicroSeconds} from './Timing.js';\nimport {type ProcessID, type SampleIndex, type ThreadID, type TraceEventData} from './TraceEvents.js';\n\nexport type TraceFile = {\n traceEvents: readonly TraceEventData[],\n metadata: MetaData,\n};\n\nexport interface Breadcrumb {\n window: TraceWindowMicroSeconds;\n child: Breadcrumb|null;\n}\n\nexport const enum DataOrigin {\n CPUProfile = 'CPUProfile',\n TraceEvents = 'TraceEvents',\n}\n\nexport const enum EventKeyType {\n RawEvent = 'r',\n SyntheticEvent = 's',\n ProfileCall = 'p',\n}\n\n// Serializable keys are created for trace events to be able to save\n// references to timeline events in a trace file. These keys enable\n// user modifications that can be saved. See go/cpq:event-data-json for\n// more details on the key format.\nexport type RawEventKey = `${EventKeyType.RawEvent}-${number}`;\nexport type SyntheticEventKey = `${EventKeyType.SyntheticEvent}-${number}`;\nexport type ProfileCallKey = `${EventKeyType.ProfileCall}-${ProcessID}-${ThreadID}-${SampleIndex}-${Protocol.integer}`;\nexport type TraceEventSerializableKey = RawEventKey|ProfileCallKey|SyntheticEventKey;\n\n// Serializable keys values objects contain data that maps the keys to original Trace Events\nexport type RawEventKeyValues = {\n type: EventKeyType.RawEvent,\n rawIndex: number,\n};\n\nexport type SyntheticEventKeyValues = {\n type: EventKeyType.SyntheticEvent,\n rawIndex: number,\n};\n\nexport type ProfileCallKeyValues = {\n type: EventKeyType.ProfileCall,\n processID: ProcessID,\n threadID: ThreadID,\n sampleIndex: SampleIndex,\n protocol: Protocol.integer,\n};\n\nexport type TraceEventSerializableKeyValues = RawEventKeyValues|ProfileCallKeyValues|SyntheticEventKeyValues;\n\nexport interface Modifications {\n entriesModifications: {\n // Entries hidden by the user\n hiddenEntries: TraceEventSerializableKey[],\n // Entries that parent a hiddenEntry\n expandableEntries: TraceEventSerializableKey[],\n };\n initialBreadcrumb: Breadcrumb;\n}\n\n/**\n * Trace metadata that we persist to the file. This will allow us to\n * store specifics for the trace, e.g., which tracks should be visible\n * on load.\n */\nexport interface MetaData {\n source?: 'DevTools';\n startTime?: string;\n networkThrottling?: string;\n cpuThrottling?: number;\n hardwareConcurrency?: number;\n dataOrigin?: DataOrigin;\n modifications?: Modifications;\n enhancedTraceVersion?: number;\n}\n\nexport type Contents = TraceFile|TraceEventData[];\n\nexport function traceEventKeyToValues(key: TraceEventSerializableKey): TraceEventSerializableKeyValues {\n const parts = key.split('-');\n const type = parts[0];\n\n switch (type) {\n case EventKeyType.ProfileCall:\n if (parts.length !== 5 ||\n !(parts.every((part, i) => i === 0 || typeof part === 'number' || !isNaN(parseInt(part, 10))))) {\n throw new Error(`Invalid ProfileCallKey: ${key}`);\n }\n return {\n type: parts[0],\n processID: parseInt(parts[1], 10),\n threadID: parseInt(parts[2], 10),\n sampleIndex: parseInt(parts[3], 10),\n protocol: parseInt(parts[4], 10),\n } as ProfileCallKeyValues;\n case EventKeyType.RawEvent:\n if (parts.length !== 2 || !(typeof parts[1] === 'number' || !isNaN(parseInt(parts[1], 10)))) {\n throw new Error(`Invalid RawEvent Key: ${key}`);\n }\n return {\n type: parts[0],\n rawIndex: parseInt(parts[1], 10),\n } as RawEventKeyValues;\n case EventKeyType.SyntheticEvent:\n if (parts.length !== 2 || !(typeof parts[1] === 'number' || !isNaN(parseInt(parts[1], 10)))) {\n throw new Error(`Invalid SyntheticEvent Key: ${key}`);\n }\n return {\n type: parts[0],\n rawIndex: parseInt(parts[1], 10),\n } as SyntheticEventKeyValues;\n default:\n throw new Error(`Unknown trace event key: ${key}`);\n }\n}\n"]}
1
+ {"version":3,"file":"File.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/File.ts"],"names":[],"mappings":"AAyGA,MAAM,UAAU,qBAAqB,CAAC,GAA8B;IAClE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,IAAI,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CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5F,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;gBACd,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;aACN,CAAC;QAC/B;YACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2023 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.\nimport type * as Protocol from '../../../generated/protocol.js';\n\nimport {type TraceWindowMicroSeconds} from './Timing.js';\nimport {type ProcessID, type SampleIndex, type ThreadID, type TraceEventData} from './TraceEvents.js';\n\nexport type TraceFile = {\n traceEvents: readonly TraceEventData[],\n metadata: MetaData,\n};\n\nexport interface Breadcrumb {\n window: TraceWindowMicroSeconds;\n child: Breadcrumb|null;\n}\n\nexport const enum DataOrigin {\n CPUProfile = 'CPUProfile',\n TraceEvents = 'TraceEvents',\n}\n\nexport const enum EventKeyType {\n RawEvent = 'r',\n SyntheticEvent = 's',\n ProfileCall = 'p',\n}\n\n/**\n * Represents an object that is saved in the file when a user creates a label for an entry in the timeline.\n */\nexport interface EntryLabelAnnotation {\n type: 'ENTRY_LABEL';\n entry: TraceEventData;\n label: string;\n}\n\n/**\n * `Annotation` are the user-created annotations that are saved into the metadata.\n * Those annotations are rendered on the timeline by `Overlays.ts`\n *\n * TODO: Implement other OverlayAnnotations (annotated time ranges, links between entries).\n * TODO: Save/load overlay annotations to/from the trace file.\n */\nexport type Annotation = EntryLabelAnnotation;\n\n// Serializable keys are created for trace events to be able to save\n// references to timeline events in a trace file. These keys enable\n// user modifications that can be saved. See go/cpq:event-data-json for\n// more details on the key format.\nexport type RawEventKey = `${EventKeyType.RawEvent}-${number}`;\nexport type SyntheticEventKey = `${EventKeyType.SyntheticEvent}-${number}`;\nexport type ProfileCallKey = `${EventKeyType.ProfileCall}-${ProcessID}-${ThreadID}-${SampleIndex}-${Protocol.integer}`;\nexport type TraceEventSerializableKey = RawEventKey|ProfileCallKey|SyntheticEventKey;\n\n// Serializable keys values objects contain data that maps the keys to original Trace Events\nexport type RawEventKeyValues = {\n type: EventKeyType.RawEvent,\n rawIndex: number,\n};\n\nexport type SyntheticEventKeyValues = {\n type: EventKeyType.SyntheticEvent,\n rawIndex: number,\n};\n\nexport type ProfileCallKeyValues = {\n type: EventKeyType.ProfileCall,\n processID: ProcessID,\n threadID: ThreadID,\n sampleIndex: SampleIndex,\n protocol: Protocol.integer,\n};\n\nexport type TraceEventSerializableKeyValues = RawEventKeyValues|ProfileCallKeyValues|SyntheticEventKeyValues;\n\nexport interface Modifications {\n entriesModifications: {\n // Entries hidden by the user\n hiddenEntries: TraceEventSerializableKey[],\n // Entries that parent a hiddenEntry\n expandableEntries: TraceEventSerializableKey[],\n };\n initialBreadcrumb: Breadcrumb;\n}\n\n/**\n * Trace metadata that we persist to the file. This will allow us to\n * store specifics for the trace, e.g., which tracks should be visible\n * on load.\n */\nexport interface MetaData {\n source?: 'DevTools';\n startTime?: string;\n networkThrottling?: string;\n cpuThrottling?: number;\n hardwareConcurrency?: number;\n dataOrigin?: DataOrigin;\n modifications?: Modifications;\n enhancedTraceVersion?: number;\n}\n\nexport type Contents = TraceFile|TraceEventData[];\n\nexport function traceEventKeyToValues(key: TraceEventSerializableKey): TraceEventSerializableKeyValues {\n const parts = key.split('-');\n const type = parts[0];\n\n switch (type) {\n case EventKeyType.ProfileCall:\n if (parts.length !== 5 ||\n !(parts.every((part, i) => i === 0 || typeof part === 'number' || !isNaN(parseInt(part, 10))))) {\n throw new Error(`Invalid ProfileCallKey: ${key}`);\n }\n return {\n type: parts[0],\n processID: parseInt(parts[1], 10),\n threadID: parseInt(parts[2], 10),\n sampleIndex: parseInt(parts[3], 10),\n protocol: parseInt(parts[4], 10),\n } as ProfileCallKeyValues;\n case EventKeyType.RawEvent:\n if (parts.length !== 2 || !(typeof parts[1] === 'number' || !isNaN(parseInt(parts[1], 10)))) {\n throw new Error(`Invalid RawEvent Key: ${key}`);\n }\n return {\n type: parts[0],\n rawIndex: parseInt(parts[1], 10),\n } as RawEventKeyValues;\n case EventKeyType.SyntheticEvent:\n if (parts.length !== 2 || !(typeof parts[1] === 'number' || !isNaN(parseInt(parts[1], 10)))) {\n throw new Error(`Invalid SyntheticEvent Key: ${key}`);\n }\n return {\n type: parts[0],\n rawIndex: parseInt(parts[1], 10),\n } as SyntheticEventKeyValues;\n default:\n throw new Error(`Unknown trace event key: ${key}`);\n }\n}\n"]}
@@ -302,6 +302,24 @@ export interface SyntheticNetworkRequest extends TraceEventComplete, SyntheticBa
302
302
  pid: ProcessID;
303
303
  tid: ThreadID;
304
304
  }
305
+ export interface SyntheticWebSocketConnectionEvent extends TraceEventComplete, SyntheticBasedEvent<Phase.COMPLETE> {
306
+ rawSourceEvent: TraceEventData;
307
+ args: TraceEventArgs & {
308
+ data: TraceEventArgsData & {
309
+ identifier: number;
310
+ priority: Protocol.Network.ResourcePriority;
311
+ url: string;
312
+ };
313
+ };
314
+ cat: string;
315
+ name: 'SyntheticWebSocketConnectionEvent';
316
+ ph: Phase.COMPLETE;
317
+ dur: MicroSeconds;
318
+ ts: MicroSeconds;
319
+ pid: ProcessID;
320
+ tid: ThreadID;
321
+ s: TraceEventScope;
322
+ }
305
323
  export declare const enum AuctionWorkletType {
306
324
  BIDDER = "bidder",
307
325
  SELLER = "seller",
@@ -428,6 +446,10 @@ export interface TraceEventNavigationStart extends TraceEventMark {
428
446
  isLoadingMainFrame: boolean;
429
447
  isOutermostMainFrame?: boolean;
430
448
  navigationId: string;
449
+ /**
450
+ * @deprecated use documentLoaderURL for navigation events URLs
451
+ */
452
+ url?: string;
431
453
  };
432
454
  frame: string;
433
455
  };
@@ -1246,16 +1268,8 @@ export interface TraceEventActivateLayerTree extends TraceEventInstant {
1246
1268
  };
1247
1269
  }
1248
1270
  export declare function isTraceEventActivateLayerTree(event: TraceEventData): event is TraceEventActivateLayerTree;
1249
- export interface SyntheticInvalidation extends TraceEventInstant {
1250
- name: 'SyntheticInvalidation';
1251
- nodeName?: string;
1252
- rawEvent: TraceEventScheduleStyleInvalidationTracking | TraceEventStyleRecalcInvalidationTracking | TraceEventStyleInvalidatorInvalidationTracking | TraceEventLayoutInvalidationTracking;
1253
- nodeId: Protocol.DOM.BackendNodeId;
1254
- frame: string;
1255
- reason?: string;
1256
- stackTrace?: TraceEventCallFrame[];
1257
- }
1258
- export declare function isSyntheticInvalidation(event: TraceEventData): event is SyntheticInvalidation;
1271
+ export type InvalidationTrackingEvent = TraceEventScheduleStyleInvalidationTracking | TraceEventStyleRecalcInvalidationTracking | TraceEventStyleInvalidatorInvalidationTracking | TraceEventLayoutInvalidationTracking;
1272
+ export declare function isTraceEventInvalidationTracking(event: TraceEventData): event is InvalidationTrackingEvent;
1259
1273
  export interface TraceEventDrawLazyPixelRef extends TraceEventInstant {
1260
1274
  name: KnownEventName.DrawLazyPixelRef;
1261
1275
  args?: TraceEventArgs & {
@@ -1406,7 +1420,9 @@ export declare function isTraceEventResourceMarkAsCached(traceEventData: TraceEv
1406
1420
  export declare function isTraceEventResourceFinish(traceEventData: TraceEventData): traceEventData is TraceEventResourceFinish;
1407
1421
  export declare function isTraceEventResourceWillSendRequest(traceEventData: TraceEventData): traceEventData is TraceEventResourceWillSendRequest;
1408
1422
  export declare function isTraceEventResourceReceivedData(traceEventData: TraceEventData): traceEventData is TraceEventResourceReceivedData;
1409
- export declare function isSyntheticNetworkRequestDetailsEvent(traceEventData: TraceEventData): traceEventData is SyntheticNetworkRequest;
1423
+ export declare function isSyntheticNetworkRequestEvent(traceEventData: TraceEventData): traceEventData is SyntheticNetworkRequest;
1424
+ export declare function isSyntheticWebSocketConnectionEvent(traceEventData: TraceEventData): traceEventData is SyntheticWebSocketConnectionEvent;
1425
+ export declare function isNetworkTrackEntry(traceEventData: TraceEventData): traceEventData is SyntheticWebSocketConnectionEvent | SyntheticNetworkRequest;
1410
1426
  export declare function isTraceEventPrePaint(traceEventData: TraceEventData): traceEventData is TraceEventPrePaint;
1411
1427
  export declare function isTraceEventNavigationStartWithURL(event: TraceEventData): event is TraceEventNavigationStart;
1412
1428
  export declare function isTraceEventMainFrameViewport(traceEventData: TraceEventData): traceEventData is TraceEventMainFrameViewport;
@@ -1697,8 +1713,10 @@ export interface TraceEventWebSocketDestroy extends TraceEventInstant {
1697
1713
  };
1698
1714
  }
1699
1715
  export declare function isTraceEventWebSocketDestroy(event: TraceEventData): event is TraceEventWebSocketDestroy;
1700
- export declare function isWebSocketTraceEvent(event: TraceEventData): event is TraceEventWebSocketCreate | TraceEventWebSocketInfo | TraceEventWebSocketTransfer;
1701
- export type WebSocketEvent = TraceEventWebSocketCreate | TraceEventWebSocketInfo | TraceEventWebSocketTransfer;
1716
+ export type WebSocketTraceEvent = TraceEventWebSocketCreate | TraceEventWebSocketInfo | TraceEventWebSocketTransfer;
1717
+ export declare function isWebSocketTraceEvent(event: TraceEventData): event is WebSocketTraceEvent;
1718
+ export type WebSocketEvent = WebSocketTraceEvent | SyntheticWebSocketConnectionEvent;
1719
+ export declare function isWebSocketEvent(event: TraceEventData): event is WebSocketTraceEvent | SyntheticWebSocketConnectionEvent;
1702
1720
  export interface TraceEventV8Compile extends TraceEventComplete {
1703
1721
  name: KnownEventName.Compile;
1704
1722
  args: TraceEventArgs & {
@@ -153,8 +153,9 @@ export function isTraceEventCompositeLayers(event) {
153
153
  export function isTraceEventActivateLayerTree(event) {
154
154
  return event.name === "ActivateLayerTree" /* KnownEventName.ActivateLayerTree */;
155
155
  }
156
- export function isSyntheticInvalidation(event) {
157
- return event.name === 'SyntheticInvalidation';
156
+ export function isTraceEventInvalidationTracking(event) {
157
+ return isTraceEventScheduleStyleInvalidationTracking(event) || isTraceEventStyleRecalcInvalidationTracking(event) ||
158
+ isTraceEventStyleInvalidatorInvalidationTracking(event) || isTraceEventLayoutInvalidationTracking(event);
158
159
  }
159
160
  export function isTraceEventDrawLazyPixelRef(event) {
160
161
  return event.name === "Draw LazyPixelRef" /* KnownEventName.DrawLazyPixelRef */;
@@ -343,9 +344,16 @@ export function isTraceEventResourceWillSendRequest(traceEventData) {
343
344
  export function isTraceEventResourceReceivedData(traceEventData) {
344
345
  return traceEventData.name === 'ResourceReceivedData';
345
346
  }
346
- export function isSyntheticNetworkRequestDetailsEvent(traceEventData) {
347
+ export function isSyntheticNetworkRequestEvent(traceEventData) {
347
348
  return traceEventData.name === 'SyntheticNetworkRequest';
348
349
  }
350
+ export function isSyntheticWebSocketConnectionEvent(traceEventData) {
351
+ return traceEventData.name === 'SyntheticWebSocketConnectionEvent';
352
+ }
353
+ export function isNetworkTrackEntry(traceEventData) {
354
+ return isSyntheticNetworkRequestEvent(traceEventData) || isSyntheticWebSocketConnectionEvent(traceEventData) ||
355
+ isWebSocketTraceEvent(traceEventData);
356
+ }
349
357
  export function isTraceEventPrePaint(traceEventData) {
350
358
  return traceEventData.name === 'PrePaint';
351
359
  }
@@ -478,6 +486,9 @@ export function isTraceEventWebSocketDestroy(event) {
478
486
  export function isWebSocketTraceEvent(event) {
479
487
  return isTraceEventWebSocketCreate(event) || isTraceEventWebSocketInfo(event) || isTraceEventWebSocketTransfer(event);
480
488
  }
489
+ export function isWebSocketEvent(event) {
490
+ return isWebSocketTraceEvent(event) || isSyntheticWebSocketConnectionEvent(event);
491
+ }
481
492
  export function isTraceEventV8Compile(event) {
482
493
  return event.name === "v8.compile" /* KnownEventName.Compile */;
483
494
  }