@paulirish/trace_engine 0.0.50 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
- package/core/platform/Constructor.d.ts +2 -2
- package/core/platform/Constructor.js.map +1 -1
- package/core/platform/StringUtilities.d.ts +2 -5
- package/core/platform/StringUtilities.js +4 -4
- package/core/platform/StringUtilities.js.map +1 -1
- package/core/platform/TypescriptUtilities.d.ts +1 -1
- package/core/platform/TypescriptUtilities.js +1 -1
- package/core/platform/TypescriptUtilities.js.map +1 -1
- package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/core/platform/platform-tsconfig.json +3 -4
- package/core/platform/platform.d.ts +1 -2
- package/core/platform/platform.js +1 -2
- package/core/platform/platform.js.map +1 -1
- package/generated/protocol.d.ts +306 -62
- package/locales/af.json +63 -3
- package/locales/am.json +63 -3
- package/locales/ar.json +63 -3
- package/locales/as.json +63 -3
- package/locales/az.json +63 -3
- package/locales/be.json +64 -4
- package/locales/bg.json +62 -2
- package/locales/bn.json +63 -3
- package/locales/bs.json +63 -3
- package/locales/ca.json +62 -2
- package/locales/cs.json +62 -2
- package/locales/cy.json +63 -3
- package/locales/da.json +63 -3
- package/locales/de.json +63 -3
- package/locales/el.json +62 -2
- package/locales/en-GB.json +63 -3
- package/locales/en-US.json +58 -22
- package/locales/en-XL.json +58 -22
- package/locales/es-419.json +63 -3
- package/locales/es.json +64 -4
- package/locales/et.json +64 -4
- package/locales/eu.json +79 -19
- package/locales/fa.json +62 -2
- package/locales/fi.json +63 -3
- package/locales/fil.json +63 -3
- package/locales/fr-CA.json +63 -3
- package/locales/fr.json +63 -3
- package/locales/gl.json +62 -2
- package/locales/gu.json +63 -3
- package/locales/he.json +63 -3
- package/locales/hi.json +62 -2
- package/locales/hr.json +63 -3
- package/locales/hu.json +62 -2
- package/locales/hy.json +63 -3
- package/locales/id.json +62 -2
- package/locales/is.json +64 -4
- package/locales/it.json +64 -4
- package/locales/ja.json +63 -3
- package/locales/ka.json +63 -3
- package/locales/kk.json +62 -2
- package/locales/km.json +62 -2
- package/locales/kn.json +63 -3
- package/locales/ko.json +63 -3
- package/locales/ky.json +63 -3
- package/locales/lo.json +63 -3
- package/locales/lt.json +62 -2
- package/locales/lv.json +62 -2
- package/locales/mk.json +62 -2
- package/locales/ml.json +63 -3
- package/locales/mn.json +63 -3
- package/locales/mr.json +64 -4
- package/locales/ms.json +63 -3
- package/locales/my.json +63 -3
- package/locales/ne.json +64 -4
- package/locales/nl.json +63 -3
- package/locales/no.json +62 -2
- package/locales/or.json +63 -3
- package/locales/pa.json +62 -2
- package/locales/pl.json +62 -2
- package/locales/pt-PT.json +62 -2
- package/locales/pt.json +63 -3
- package/locales/ro.json +63 -3
- package/locales/ru.json +63 -3
- package/locales/si.json +63 -3
- package/locales/sk.json +63 -3
- package/locales/sl.json +62 -2
- package/locales/sq.json +63 -3
- package/locales/sr-Latn.json +62 -2
- package/locales/sr.json +62 -2
- package/locales/sv.json +62 -2
- package/locales/sw.json +63 -3
- package/locales/ta.json +66 -6
- package/locales/te.json +63 -3
- package/locales/th.json +63 -3
- package/locales/tr.json +63 -3
- package/locales/uk.json +63 -3
- package/locales/ur.json +64 -4
- package/locales/uz.json +62 -2
- package/locales/vi.json +62 -2
- package/locales/zh-HK.json +63 -3
- package/locales/zh-TW.json +63 -3
- package/locales/zh.json +62 -2
- package/locales/zu.json +63 -3
- package/models/cpu_profile/CPUProfileDataModel.d.ts +8 -0
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
- package/models/cpu_profile/cpu_profile-tsconfig.json +3 -3
- package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/Processor.d.ts +1 -1
- package/models/trace/Processor.js +94 -74
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/TracingManager.js.map +1 -1
- package/models/trace/bundle-tsconfig.json +1 -1
- package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +21 -3
- package/models/trace/extras/ScriptDuplication.d.ts +15 -16
- package/models/trace/extras/ScriptDuplication.js +63 -79
- package/models/trace/extras/ScriptDuplication.js.map +1 -1
- package/models/trace/extras/StackTraceForEvent.js +80 -47
- package/models/trace/extras/StackTraceForEvent.js.map +1 -1
- package/models/trace/extras/ThirdParties.d.ts +14 -20
- package/models/trace/extras/ThirdParties.js +97 -130
- package/models/trace/extras/ThirdParties.js.map +1 -1
- package/models/trace/extras/TraceTree.d.ts +15 -3
- package/models/trace/extras/TraceTree.js +36 -8
- package/models/trace/extras/TraceTree.js.map +1 -1
- package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/extras/extras-tsconfig.json +3 -3
- package/models/trace/extras/extras.d.ts +1029 -844
- package/models/trace/extras/extras.js +1029 -844
- package/models/trace/handlers/AsyncJSCallsHandler.d.ts +5 -0
- package/models/trace/handlers/AsyncJSCallsHandler.js +48 -13
- package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -1
- package/models/trace/handlers/InvalidationsHandler.js +1 -0
- package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
- package/models/trace/handlers/ModelHandlers.d.ts +0 -1
- package/models/trace/handlers/ModelHandlers.js +0 -1
- package/models/trace/handlers/ModelHandlers.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.js +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/RendererHandler.d.ts +1 -1
- package/models/trace/handlers/RendererHandler.js +2 -2
- package/models/trace/handlers/RendererHandler.js.map +1 -1
- package/models/trace/handlers/ScreenshotsHandler.js +4 -1
- package/models/trace/handlers/ScreenshotsHandler.js.map +1 -1
- package/models/trace/handlers/ScriptsHandler.d.ts +12 -0
- package/models/trace/handlers/ScriptsHandler.js +99 -1
- package/models/trace/handlers/ScriptsHandler.js.map +1 -1
- package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/handlers/handlers-tsconfig.json +3 -4
- package/models/trace/handlers/helpers.js +9 -0
- package/models/trace/handlers/helpers.js.map +1 -1
- package/models/trace/helpers/Network.d.ts +5 -0
- package/models/trace/helpers/Network.js +17 -0
- package/models/trace/helpers/Network.js.map +1 -1
- package/models/trace/helpers/SamplesIntegrator.js +19 -23
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
- package/models/trace/helpers/SyntheticEvents.d.ts +0 -1
- package/models/trace/helpers/SyntheticEvents.js +0 -4
- package/models/trace/helpers/SyntheticEvents.js.map +1 -1
- package/models/trace/helpers/Trace.d.ts +2 -1
- package/models/trace/helpers/Trace.js +101 -1
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/helpers/TreeHelpers.d.ts +2 -5
- package/models/trace/helpers/TreeHelpers.js +0 -4
- package/models/trace/helpers/TreeHelpers.js.map +1 -1
- package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/helpers/helpers-tsconfig.json +3 -3
- package/models/trace/insights/CLSCulprits.d.ts +6 -1
- package/models/trace/insights/CLSCulprits.js +11 -2
- package/models/trace/insights/CLSCulprits.js.map +1 -1
- package/models/trace/insights/{UseCache.d.ts → Cache.d.ts} +2 -3
- package/models/trace/insights/{UseCache.js → Cache.js} +12 -6
- package/models/trace/insights/Cache.js.map +1 -0
- package/models/trace/insights/Common.d.ts +21 -2
- package/models/trace/insights/Common.js +89 -2
- package/models/trace/insights/Common.js.map +1 -1
- package/models/trace/insights/DocumentLatency.js +3 -8
- package/models/trace/insights/DocumentLatency.js.map +1 -1
- package/models/trace/insights/DuplicatedJavaScript.d.ts +7 -4
- package/models/trace/insights/DuplicatedJavaScript.js +31 -5
- package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
- package/models/trace/insights/ForcedReflow.d.ts +5 -1
- package/models/trace/insights/ForcedReflow.js +6 -2
- package/models/trace/insights/ForcedReflow.js.map +1 -1
- package/models/trace/insights/ImageDelivery.d.ts +0 -1
- package/models/trace/insights/ImageDelivery.js +1 -1
- package/models/trace/insights/ImageDelivery.js.map +1 -1
- package/models/trace/insights/InteractionToNextPaint.d.ts +1 -0
- package/models/trace/insights/InteractionToNextPaint.js +3 -0
- package/models/trace/insights/InteractionToNextPaint.js.map +1 -1
- package/models/trace/insights/LegacyJavaScript.d.ts +32 -0
- package/models/trace/insights/LegacyJavaScript.js +80 -0
- package/models/trace/insights/LegacyJavaScript.js.map +1 -0
- package/models/trace/insights/Models.d.ts +3 -1
- package/models/trace/insights/Models.js +3 -1
- package/models/trace/insights/Models.js.map +1 -1
- package/models/trace/insights/ModernHTTP.d.ts +51 -0
- package/models/trace/insights/ModernHTTP.js +187 -0
- package/models/trace/insights/ModernHTTP.js.map +1 -0
- package/models/trace/insights/NetworkDependencyTree.js +1 -1
- package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
- package/models/trace/insights/ThirdParties.d.ts +1 -5
- package/models/trace/insights/ThirdParties.js +8 -21
- package/models/trace/insights/ThirdParties.js.map +1 -1
- package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/insights/insights-tsconfig.json +9 -4
- package/models/trace/insights/types.d.ts +10 -0
- package/models/trace/insights/types.js.map +1 -1
- package/models/trace/lantern/core/core-tsconfig.json +3 -3
- package/models/trace/lantern/core/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/lantern/graph/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/lantern/graph/graph-tsconfig.json +3 -3
- package/models/trace/lantern/lantern-tsconfig.json +3 -3
- package/models/trace/lantern/metrics/Metric.d.ts +4 -4
- package/models/trace/lantern/metrics/Metric.js +4 -6
- package/models/trace/lantern/metrics/Metric.js.map +1 -1
- package/models/trace/lantern/metrics/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/lantern/metrics/metrics-tsconfig.json +3 -3
- package/models/trace/lantern/simulation/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/lantern/simulation/simulation-tsconfig.json +3 -3
- package/models/trace/lantern/types/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/lantern/types/types-tsconfig.json +3 -3
- package/models/trace/trace-tsconfig.json +3 -3
- package/models/trace/types/Configuration.d.ts +2 -0
- package/models/trace/types/Configuration.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +30 -54
- package/models/trace/types/TraceEvents.js +8 -23
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +3 -3
- package/models/trace/types/types-tsconfig.json +3 -3
- package/package.json +3 -2
- package/test/test-trace-engine.mjs +19 -17
- package/third_party/legacy-javascript/legacy-javascript.d.ts +1 -0
- package/third_party/legacy-javascript/legacy-javascript.js +1 -0
- package/core/platform/ServerTiming.d.ts +0 -31
- package/core/platform/ServerTiming.js +0 -212
- package/core/platform/ServerTiming.js.map +0 -1
- package/models/trace/handlers/ServerTimingsHandler.d.ts +0 -9
- package/models/trace/handlers/ServerTimingsHandler.js +0 -106
- package/models/trace/handlers/ServerTimingsHandler.js.map +0 -1
- package/models/trace/insights/UseCache.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Network.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Network.ts"],"names":[],"mappings":"AAMA,6DAA6D;AAC7D,oCAAoC;AACpC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,cAAc;AACd,6EAA6E;AAC7E,8EAA8E;AAC9E,0DAA0D;AAC1D,2EAA2E;AAC3E,4EAA4E;AAC5E,iCAAiC;AACjC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAiB;IACzD,cAAc;IACd,mCAAmC;IACnC,sBAAsB;CACvB,CAAC,CAAC;AAEH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,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEnE,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;oBACnB,mBAAmB,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;gBAC1C,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,UAAU;gBACb,mBAAmB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;gBACvC,MAAM;YACR,KAAK,UAAU;gBACb,mBAAmB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;gBACvC,MAAM;YACR,KAAK,iBAAiB;gBACpB,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;gBAC9C,MAAM;YACR,KAAK,SAAS;gBACZ,mBAAmB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;gBACtC,MAAM;YACR;gBACE,4BAA4B;gBAC5B,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,mBAAmB,CAAC;AAC7B,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.\nimport * as Protocol from '../../../generated/protocol.js';\nimport type {RenderBlocking, SyntheticNetworkRequest} from '../types/TraceEvents.js';\n\n// Important: we purposefully treat `potentially_blocking` as\n// non-render-blocking here because:\n// 1. An async script can run on the main thread at any point, including before\n// the page is loaded\n// 2. An async script will never block the parsing and rendering process of the\n// browser.\n// 3. Therefore, from a developer's point of view, there is nothing more they\n// can do if they've put `async` on, and within the context of Insights, we\n// shouldn't report an async script as render blocking.\n// In the future we may want to consider suggesting the use of `defer` over\n// `async`, as it doesn't have this concern, but for now we'll allow `async`\n// and not report it as an issue.\nconst NON_RENDER_BLOCKING_VALUES = new Set<RenderBlocking>([\n 'non_blocking',\n 'dynamically_injected_non_blocking',\n 'potentially_blocking',\n]);\n\nexport function isSyntheticNetworkRequestEventRenderBlocking(event: SyntheticNetworkRequest): boolean {\n return !NON_RENDER_BLOCKING_VALUES.has(event.args.data.renderBlocking);\n}\n\nconst HIGH_NETWORK_PRIORITIES = new Set<Protocol.Network.ResourcePriority>([\n Protocol.Network.ResourcePriority.VeryHigh,\n Protocol.Network.ResourcePriority.High,\n Protocol.Network.ResourcePriority.Medium,\n]);\n\nexport function isSyntheticNetworkRequestHighPriority(event: SyntheticNetworkRequest): boolean {\n return HIGH_NETWORK_PRIORITIES.has(event.args.data.priority);\n}\n\nexport interface CacheControl {\n 'max-age'?: number;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'must-revalidate'?: boolean;\n // eslint-disable-next-line @stylistic/quote-props\n 'private'?: boolean;\n}\n\nexport const CACHEABLE_STATUS_CODES = new Set([200, 203, 206]);\n\n/** @type {Set<LH.Crdp.Network.ResourceType>} */\nexport const STATIC_RESOURCE_TYPES = new Set([\n Protocol.Network.ResourceType.Font,\n Protocol.Network.ResourceType.Image,\n Protocol.Network.ResourceType.Media,\n Protocol.Network.ResourceType.Script,\n Protocol.Network.ResourceType.Stylesheet,\n]);\n\nexport const NON_NETWORK_SCHEMES = [\n 'blob', // @see https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL\n 'data', // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\n 'intent', // @see https://developer.chrome.com/docs/multidevice/android/intents/\n 'file', // @see https://en.wikipedia.org/wiki/File_URI_scheme\n 'filesystem', // @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystem\n 'chrome-extension',\n];\n\n/**\n * Parses Cache-Control directives based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control\n * eg. 'no-cache, no-store, max-age=0, no-transform, private' will return\n * {no-cache: true, no-store: true, max-age: 0, no-transform: true, private: true}\n */\nexport function parseCacheControl(header: string|null): CacheControl|null {\n if (!header) {\n return null;\n }\n\n const directives = header.split(',').map(directive => directive.trim());\n const cacheControlOptions: CacheControl = {};\n\n for (const directive of directives) {\n const [key, value] = directive.split('=').map(part => part.trim());\n\n switch (key) {\n case 'max-age': {\n const maxAge = parseInt(value, 10);\n if (!isNaN(maxAge)) {\n cacheControlOptions['max-age'] = maxAge;\n }\n break;\n }\n case 'no-cache':\n cacheControlOptions['no-cache'] = true;\n break;\n case 'no-store':\n cacheControlOptions['no-store'] = true;\n break;\n case 'must-revalidate':\n cacheControlOptions['must-revalidate'] = true;\n break;\n case 'private':\n cacheControlOptions['private'] = true;\n break;\n default:\n // Ignore unknown directives\n break;\n }\n }\n\n return cacheControlOptions;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Network.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/Network.ts"],"names":[],"mappings":"AAMA,6DAA6D;AAC7D,oCAAoC;AACpC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAC/E,cAAc;AACd,6EAA6E;AAC7E,8EAA8E;AAC9E,0DAA0D;AAC1D,2EAA2E;AAC3E,4EAA4E;AAC5E,iCAAiC;AACjC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAiB;IACzD,cAAc;IACd,mCAAmC;IACnC,sBAAsB;CACvB,CAAC,CAAC;AAEH,MAAM,UAAU,4CAA4C,CAAC,KAA8B;IACzF,OAAO,CAAC,0BAA0B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAoC;;;;CAI1E,CAAC,CAAC;AAEH,MAAM,UAAU,qCAAqC,CAAC,KAA8B;IAClF,OAAO,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAWD,MAAM,CAAC,MAAM,sB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AAI,CAAC;gBACvC,MAAM;YACR,KAAK,UAAU;gBACb,mBAAmB,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;gBACvC,MAAM;YACR,KAAK,iBAAiB;gBACpB,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;gBAC9C,MAAM;YACR,KAAK,SAAS;gBACZ,mBAAmB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;gBACtC,MAAM;YACR;gBACE,4BAA4B;gBAC5B,MAAM;QACV,CAAC;IACH,CAAC;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,MAAM,wBAAwB,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CAAC,KAA8B;IAC/E,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;QACvD,sEAAsE;QACtE,6DAA6D;QAC7D,8FAA8F;QAC9F,OAAO,wBAAwB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,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.\nimport * as Protocol from '../../../generated/protocol.js';\nimport type {RenderBlocking, SyntheticNetworkRequest} from '../types/TraceEvents.js';\n\n// Important: we purposefully treat `potentially_blocking` as\n// non-render-blocking here because:\n// 1. An async script can run on the main thread at any point, including before\n// the page is loaded\n// 2. An async script will never block the parsing and rendering process of the\n// browser.\n// 3. Therefore, from a developer's point of view, there is nothing more they\n// can do if they've put `async` on, and within the context of Insights, we\n// shouldn't report an async script as render blocking.\n// In the future we may want to consider suggesting the use of `defer` over\n// `async`, as it doesn't have this concern, but for now we'll allow `async`\n// and not report it as an issue.\nconst NON_RENDER_BLOCKING_VALUES = new Set<RenderBlocking>([\n 'non_blocking',\n 'dynamically_injected_non_blocking',\n 'potentially_blocking',\n]);\n\nexport function isSyntheticNetworkRequestEventRenderBlocking(event: SyntheticNetworkRequest): boolean {\n return !NON_RENDER_BLOCKING_VALUES.has(event.args.data.renderBlocking);\n}\n\nconst HIGH_NETWORK_PRIORITIES = new Set<Protocol.Network.ResourcePriority>([\n Protocol.Network.ResourcePriority.VeryHigh,\n Protocol.Network.ResourcePriority.High,\n Protocol.Network.ResourcePriority.Medium,\n]);\n\nexport function isSyntheticNetworkRequestHighPriority(event: SyntheticNetworkRequest): boolean {\n return HIGH_NETWORK_PRIORITIES.has(event.args.data.priority);\n}\n\nexport interface CacheControl {\n 'max-age'?: number;\n 'no-cache'?: boolean;\n 'no-store'?: boolean;\n 'must-revalidate'?: boolean;\n // eslint-disable-next-line @stylistic/quote-props\n 'private'?: boolean;\n}\n\nexport const CACHEABLE_STATUS_CODES = new Set([200, 203, 206]);\n\n/** @type {Set<LH.Crdp.Network.ResourceType>} */\nexport const STATIC_RESOURCE_TYPES = new Set([\n Protocol.Network.ResourceType.Font,\n Protocol.Network.ResourceType.Image,\n Protocol.Network.ResourceType.Media,\n Protocol.Network.ResourceType.Script,\n Protocol.Network.ResourceType.Stylesheet,\n]);\n\nexport const NON_NETWORK_SCHEMES = [\n 'blob', // @see https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL\n 'data', // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs\n 'intent', // @see https://developer.chrome.com/docs/multidevice/android/intents/\n 'file', // @see https://en.wikipedia.org/wiki/File_URI_scheme\n 'filesystem', // @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystem\n 'chrome-extension',\n];\n\n/**\n * Parses Cache-Control directives based on https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control\n * eg. 'no-cache, no-store, max-age=0, no-transform, private' will return\n * {no-cache: true, no-store: true, max-age: 0, no-transform: true, private: true}\n */\nexport function parseCacheControl(header: string|null): CacheControl|null {\n if (!header) {\n return null;\n }\n\n const directives = header.split(',').map(directive => directive.trim());\n const cacheControlOptions: CacheControl = {};\n\n for (const directive of directives) {\n const [key, value] = directive.split('=').map(part => part.trim());\n\n switch (key) {\n case 'max-age': {\n const maxAge = parseInt(value, 10);\n if (!isNaN(maxAge)) {\n cacheControlOptions['max-age'] = maxAge;\n }\n break;\n }\n case 'no-cache':\n cacheControlOptions['no-cache'] = true;\n break;\n case 'no-store':\n cacheControlOptions['no-store'] = true;\n break;\n case 'must-revalidate':\n cacheControlOptions['must-revalidate'] = true;\n break;\n case 'private':\n cacheControlOptions['private'] = true;\n break;\n default:\n // Ignore unknown directives\n break;\n }\n }\n\n return cacheControlOptions;\n}\n\nconst SECURE_LOCALHOST_DOMAINS = ['localhost', '127.0.0.1'];\n\n/**\n * Is the host localhost-enough to satisfy the \"secure context\" definition\n * https://github.com/GoogleChrome/lighthouse/pull/11766#discussion_r582340683\n */\nexport function isSyntheticNetworkRequestLocalhost(event: SyntheticNetworkRequest): boolean {\n try {\n const hostname = new URL(event.args.data.url).hostname;\n // Any hostname terminating in `.localhost` is considered to be local.\n // https://w3c.github.io/webappsec-secure-contexts/#localhost\n // This method doesn't consider IPs that resolve to loopback, IPv6 or other loopback edgecases\n return SECURE_LOCALHOST_DOMAINS.includes(hostname) || hostname.endsWith('.localhost');\n } catch {\n return false;\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
import * as Types from '../types/types.js';
|
|
5
5
|
import { milliToMicro } from './Timing.js';
|
|
6
|
-
import { extractSampleTraceId, makeProfileCall, mergeEventsInOrder } from './Trace.js';
|
|
6
|
+
import { extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace } from './Trace.js';
|
|
7
7
|
/**
|
|
8
8
|
* This is a helper that integrates CPU profiling data coming in the
|
|
9
9
|
* shape of samples, with trace events. Samples indicate what the JS
|
|
@@ -65,12 +65,6 @@ export class SamplesIntegrator {
|
|
|
65
65
|
* in the stack before the event came.
|
|
66
66
|
*/
|
|
67
67
|
#lockedJsStackDepth = [];
|
|
68
|
-
/**
|
|
69
|
-
* For samples with a trace id, creates a profile call and keeps it
|
|
70
|
-
* in a record keyed by that id. The value is typed as an union with
|
|
71
|
-
* undefined to avoid nullish accesses when a key is not present.
|
|
72
|
-
*/
|
|
73
|
-
#callsByTraceIds = {};
|
|
74
68
|
/**
|
|
75
69
|
* Used to keep track when samples should be integrated even if they
|
|
76
70
|
* are not children of invocation trace events. This is useful in
|
|
@@ -155,6 +149,7 @@ export class SamplesIntegrator {
|
|
|
155
149
|
this.#onTraceEventEnd(last);
|
|
156
150
|
}
|
|
157
151
|
}
|
|
152
|
+
sortTraceEventsInPlace(this.jsSampleEvents);
|
|
158
153
|
return this.#constructedProfileCalls;
|
|
159
154
|
}
|
|
160
155
|
#onTraceEventStart(event) {
|
|
@@ -220,7 +215,6 @@ export class SamplesIntegrator {
|
|
|
220
215
|
callsFromProfileSamples() {
|
|
221
216
|
const samples = this.#profileModel.samples;
|
|
222
217
|
const timestamps = this.#profileModel.timestamps;
|
|
223
|
-
const debugModeEnabled = this.#engineConfig.debugMode;
|
|
224
218
|
if (!samples) {
|
|
225
219
|
return [];
|
|
226
220
|
}
|
|
@@ -232,17 +226,9 @@ export class SamplesIntegrator {
|
|
|
232
226
|
if (!node) {
|
|
233
227
|
continue;
|
|
234
228
|
}
|
|
235
|
-
const maybeTraceId = this.#profileModel.traceIds?.[i];
|
|
236
229
|
const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (maybeTraceId === undefined) {
|
|
240
|
-
calls.push(call);
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
this.#callsByTraceIds[maybeTraceId] = call;
|
|
244
|
-
}
|
|
245
|
-
if (debugModeEnabled) {
|
|
230
|
+
calls.push(call);
|
|
231
|
+
if (this.#engineConfig.debugMode) {
|
|
246
232
|
const traceId = this.#profileModel.traceIds?.[i];
|
|
247
233
|
this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));
|
|
248
234
|
}
|
|
@@ -299,6 +285,18 @@ export class SamplesIntegrator {
|
|
|
299
285
|
}
|
|
300
286
|
return callFrames;
|
|
301
287
|
}
|
|
288
|
+
#getStackForSampleTraceId(traceId, timestamp) {
|
|
289
|
+
const nodeId = this.#profileModel.traceIds?.[traceId];
|
|
290
|
+
const node = nodeId && this.#profileModel.nodeById(nodeId);
|
|
291
|
+
const maybeCallForTraceId = node && makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);
|
|
292
|
+
if (!maybeCallForTraceId) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
if (this.#engineConfig.debugMode) {
|
|
296
|
+
this.jsSampleEvents.push(this.#makeJSSampleEvent(maybeCallForTraceId, timestamp, traceId));
|
|
297
|
+
}
|
|
298
|
+
return this.#makeProfileCallsForStack(maybeCallForTraceId);
|
|
299
|
+
}
|
|
302
300
|
/**
|
|
303
301
|
* Update tracked stack using this event's call stack.
|
|
304
302
|
*/
|
|
@@ -308,11 +306,9 @@ export class SamplesIntegrator {
|
|
|
308
306
|
stackTrace = this.#makeProfileCallsForStack(event);
|
|
309
307
|
}
|
|
310
308
|
const traceId = extractSampleTraceId(event);
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
stackTrace = this.#makeProfileCallsForStack(maybeCallForTraceId, event.ts);
|
|
315
|
-
}
|
|
309
|
+
const maybeCallForTraceId = traceId && this.#getStackForSampleTraceId(traceId, event.ts);
|
|
310
|
+
if (maybeCallForTraceId) {
|
|
311
|
+
stackTrace = maybeCallForTraceId;
|
|
316
312
|
}
|
|
317
313
|
SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);
|
|
318
314
|
const endTime = event.ts + (event.dur || 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACH,wBAAwB,GAAwC,EAAE,CAAC;IACnE;;;;;;OAMG;IACH,eAAe,GAAwC,EAAE,CAAC;IAC1D;;OAEG;IACH,UAAU,CAAyB;IACnC;;OAEG;IACH,SAAS,CAAwB;IACjC;;;;;;;OAOG;IACH,mBAAmB,GAAa,EAAE,CAAC;IACnC;;;;OAIG;IACH,gBAAgB,GAAgE,EAAE,CAAC;IACnF;;;;;OAKG;IACH,iBAAiB,GAAG,KAAK,CAAC;IAC1B;;;OAGG;IACH,aAAa,CAAqD;IAClE;;;;;;;;OAQG;IACH,UAAU,GAAG,IAAI,GAAG,EAA8E,CAAC;IAEnG,aAAa,CAAoC;IACjD,UAAU,CAAyB;IAEnC;;;OAGG;IACH,cAAc,GAAqC,EAAE,CAAC;IAEtD,YACI,YAAgE,EAAE,SAAiC,EACnG,GAA2B,EAAE,GAA0B,EAAE,aAAiD;QAC5G,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,QAAQ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EAAE,EAAC,UAAU,EAAE,OAAO,EAAC,EAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,wCAA8B,CAAC;QAC1G,OAAO;YACL,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE;gBACR,UAAU,sDAAmC;aAC9C;SACF,CAAC;QAEF,SAAS,WAAW;QAChB,8DAA8D;QAC9D,IAAY,EAAE,IAAS,EAAE,EAAU,EAAE,GAAY,EAAE,EAAuB,EAAE,GAAY;YAC1F,MAAM,KAAK,GAAuB;gBAChC,GAAG,EAAE,GAAG,IAAI,uCAAuC;gBACnD,IAAI;gBACJ,EAAE,EAAE,EAAE,yCAA+B;gBACrC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC9B,GAAG;gBACH,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,IAAI;aACL,CAAC;YAEF,IAAI,GAAG,EAAE,CAAC;gBACR,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtC,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF","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.\n\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {milliToMicro} from './Timing.js';\nimport {extractSampleTraceId, makeProfileCall, mergeEventsInOrder} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficient (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of running the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.Events.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.Events.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.Events.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.Events.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * For samples with a trace id, creates a profile call and keeps it\n * in a record keyed by that id. The value is typed as an union with\n * undefined to avoid nullish accesses when a key is not present.\n */\n #callsByTraceIds: Record<number, Types.Events.SyntheticProfileCall|undefined> = {};\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is useful in\n * cases where we can be missing the start of JS invocation events if\n * we start tracing half-way through.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.Events.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n #profileId: Types.Events.ProfileID;\n\n /**\n * Keeps track of the individual samples from the CPU Profile.\n * Only used with Debug Mode experiment enabled.\n */\n jsSampleEvents: Types.Events.SyntheticJSSample[] = [];\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, profileId: Types.Events.ProfileID,\n pid: Types.Events.ProcessID, tid: Types.Events.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.defaults();\n this.#profileId = profileId;\n }\n\n buildProfileCalls(traceEvents: Types.Events.Event[]): Types.Events.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.Events.Event): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.Events.SyntheticProfileCall, parent?: Types.Events.Event): void {\n if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.Events.Event): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.Events.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n const debugModeEnabled = this.#engineConfig.debugMode;\n if (!samples) {\n return [];\n }\n const calls: Types.Events.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));\n if (!node) {\n continue;\n }\n const maybeTraceId = this.#profileModel.traceIds?.[i];\n const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);\n // Separate samples with trace ids so that they are only used when\n // processing the owner event.\n if (maybeTraceId === undefined) {\n calls.push(call);\n } else {\n this.#callsByTraceIds[maybeTraceId] = call;\n }\n if (debugModeEnabled) {\n const traceId = this.#profileModel.traceIds?.[i];\n this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));\n }\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n /**\n * Given a synthetic profile call, returns an array of profile calls\n * representing the stack trace that profile call belongs to based on\n * its nodeId. The input profile call will be at the top of the\n * returned stack (last position), meaning that any other frames that\n * were effectively above it are omitted.\n * @param profileCall\n * @param overrideTimeStamp a custom timestamp to use for the returned\n * profile calls. If not defined, the timestamp of the input\n * profileCall is used instead. This param is useful for example when\n * creating the profile calls for a sample with a trace id, since the\n * timestamp of the corresponding trace event should be used instead\n * of the sample's.\n */\n\n #makeProfileCallsForStack(profileCall: Types.Events.SyntheticProfileCall, overrideTimeStamp?: Types.Timing.Micro):\n Types.Events.SyntheticProfileCall[] {\n let node = this.#profileModel.nodeById(profileCall.nodeId);\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const callFrames = new Array<Types.Events.SyntheticProfileCall>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = callFrames.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection call frame on top of the stack.\n callFrames[i--] = profileCall;\n }\n\n // Many of these ProfileCalls will be GC'd later when we estimate the frame\n // durations\n while (node) {\n callFrames[i--] = makeProfileCall(\n node, profileCall.profileId, profileCall.sampleIndex, overrideTimeStamp ?? profileCall.ts, this.#processId,\n this.#threadId);\n node = node.parent;\n }\n return callFrames;\n }\n\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.Events.Event): void {\n let stackTrace = this.#currentJSStack;\n if (Types.Events.isProfileCall(event)) {\n stackTrace = this.#makeProfileCallsForStack(event);\n }\n const traceId = extractSampleTraceId(event);\n if (traceId !== null) {\n const maybeCallForTraceId = this.#callsByTraceIds[traceId];\n if (maybeCallForTraceId) {\n stackTrace = this.#makeProfileCallsForStack(maybeCallForTraceId, event.ts);\n }\n }\n\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n this.#truncateJSStack(i, event.ts);\n\n for (; i < stackTrace.length; ++i) {\n const call = stackTrace[i];\n if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id ||\n call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.Micro): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n #makeJSSampleEvent(call: Types.Events.SyntheticProfileCall, timestamp: Types.Timing.Micro, traceId?: number):\n Types.Events.SyntheticJSSample {\n const JSSampleEvent: Types.Events.SyntheticJSSample = {\n name: Types.Events.Name.JS_SAMPLE,\n cat: 'devtools.timeline',\n args: {\n data: {traceId, stackTrace: this.#makeProfileCallsForStack(call).map(e => e.callFrame)},\n },\n ph: Types.Events.Phase.INSTANT,\n ts: timestamp,\n dur: Types.Timing.Micro(0),\n pid: this.#processId,\n tid: this.#threadId,\n };\n return JSSampleEvent;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): SamplesIntegrator.NativeGroups|null {\n if (nativeName.startsWith('Parse')) {\n return SamplesIntegrator.NativeGroups.PARSE;\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return SamplesIntegrator.NativeGroups.COMPILE;\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames(stack: Types.Events.SyntheticProfileCall[], engineConfig: Types.Configuration.Configuration):\n void {\n const showAllEvents = engineConfig.showAllEvents;\n if (showAllEvents) {\n return;\n }\n let previousNativeFrameName: string|null = null;\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame &&\n !SamplesIntegrator.showNativeName(frame.functionName, engineConfig.includeRuntimeCallStats)) {\n continue;\n }\n const nativeFrameName = nativeRuntimeFrame ? SamplesIntegrator.nativeGroup(frame.functionName) : null;\n if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {\n continue;\n }\n previousNativeFrameName = nativeFrameName;\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n\n static createFakeTraceFromCpuProfile(profile: Protocol.Profiler.Profile, tid: Types.Events.ThreadID):\n Types.File.TraceFile {\n const events: Types.Events.Event[] = [];\n\n const threadName = `Thread ${tid}`;\n appendEvent('TracingStartedInPage', {data: {sessionId: '1'}}, 0, 0, Types.Events.Phase.METADATA);\n appendEvent(Types.Events.Name.THREAD_NAME, {name: threadName}, 0, 0, Types.Events.Phase.METADATA, '__metadata');\n if (!profile) {\n return {traceEvents: events, metadata: {}};\n }\n\n // Append a root to show the start time of the profile (which is earlier than first sample), so the Performance\n // panel won't truncate this time period.\n // 'JSRoot' doesn't exist in the new engine and is not the name of an actual trace event, but changing it might break other trace processing tools that rely on this, so we stick with this name.\n // TODO(crbug.com/341234884): consider removing this or clarify why it's required.\n appendEvent(\n 'JSRoot', {}, profile.startTime, profile.endTime - profile.startTime, Types.Events.Phase.COMPLETE, 'toplevel');\n\n // TODO: create a `Profile` event instead, as `cpuProfile` is legacy\n appendEvent('CpuProfile', {data: {cpuProfile: profile}}, profile.endTime, 0, Types.Events.Phase.COMPLETE);\n return {\n traceEvents: events,\n metadata: {\n dataOrigin: Types.File.DataOrigin.CPU_PROFILE,\n }\n };\n\n function appendEvent(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n name: string, args: any, ts: number, dur?: number, ph?: Types.Events.Phase, cat?: string): Types.Events.Event {\n const event: Types.Events.Event = {\n cat: cat || 'disabled-by-default-devtools.timeline',\n name,\n ph: ph || Types.Events.Phase.COMPLETE,\n pid: Types.Events.ProcessID(1),\n tid,\n ts: Types.Timing.Micro(ts),\n args,\n };\n\n if (dur) {\n event.dur = Types.Timing.Micro(dur);\n }\n events.push(event);\n return event;\n }\n }\n}\n\nexport namespace SamplesIntegrator {\n export const enum NativeGroups {\n COMPILE = 'Compile',\n PARSE = 'Parse',\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SamplesIntegrator.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SamplesIntegrator.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;OAIG;IACH,wBAAwB,GAAwC,EAAE,CAAC;IACnE;;;;;;OAMG;IACH,eAAe,GAAwC,EAAE,CAAC;IAC1D;;OAEG;IACH,UAAU,CAAyB;IACnC;;OAEG;IACH,SAAS,CAAwB;IACjC;;;;;;;OAOG;IACH,mBAAmB,GAAa,EAAE,CAAC;IACnC;;;;;OAKG;IACH,iBAAiB,GAAG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BACJ,EAAE,EAAE,EAAE,yCAA+B;gBACrC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC9B,GAAG;gBACH,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,IAAI;aACL,CAAC;YAEF,IAAI,GAAG,EAAE,CAAC;gBACR,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACtC,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF","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.\n\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CPUProfile from '../../cpu_profile/cpu_profile.js';\nimport * as Types from '../types/types.js';\n\nimport {milliToMicro} from './Timing.js';\nimport {extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace} from './Trace.js';\n\n/**\n * This is a helper that integrates CPU profiling data coming in the\n * shape of samples, with trace events. Samples indicate what the JS\n * stack trace looked at a given point in time, but they don't have\n * duration. The SamplesIntegrator task is to make an approximation\n * of what the duration of each JS call was, given the sample data and\n * given the trace events profiled during that time. At the end of its\n * execution, the SamplesIntegrator returns an array of ProfileCalls\n * (under SamplesIntegrator::buildProfileCalls()), which\n * represent JS calls, with a call frame and duration. These calls have\n * the shape of a complete trace events and can be treated as flame\n * chart entries in the timeline.\n *\n * The approach to build the profile calls consists in tracking the\n * current stack as the following events happen (in order):\n * 1. A sample was done.\n * 2. A trace event started.\n * 3. A trace event ended.\n * Depending on the event and on the data that's coming with it the\n * stack is updated by adding or removing JS calls to it and updating\n * the duration of the calls in the tracking stack.\n *\n * note: Although this approach has been implemented since long ago, and\n * is relatively efficient (adds a complexity over the trace parsing of\n * O(n) where n is the number of samples) it has proven to be faulty.\n * It might be worthwhile experimenting with improvements or with a\n * completely different approach. Improving the approach is tracked in\n * crbug.com/1417439\n */\nexport class SamplesIntegrator {\n /**\n * The result of running the samples integrator. Holds the JS calls\n * with their approximated duration after integrating samples into the\n * trace event tree.\n */\n #constructedProfileCalls: Types.Events.SyntheticProfileCall[] = [];\n /**\n * tracks the state of the JS stack at each point in time to update\n * the profile call durations as new events arrive. This doesn't only\n * happen with new profile calls (in which case we would compare the\n * stack in them) but also with trace events (in which case we would\n * update the duration of the events we are tracking at the moment).\n */\n #currentJSStack: Types.Events.SyntheticProfileCall[] = [];\n /**\n * Process holding the CPU profile and trace events.\n */\n #processId: Types.Events.ProcessID;\n /**\n * Thread holding the CPU profile and trace events.\n */\n #threadId: Types.Events.ThreadID;\n /**\n * Tracks the depth of the JS stack at the moment a trace event starts\n * or ends. It is assumed that for the duration of a trace event, the\n * JS stack's depth cannot decrease, since JS calls that started\n * before a trace event cannot end during the trace event. So as trace\n * events arrive, we store the \"locked\" amount of JS frames that were\n * in the stack before the event came.\n */\n #lockedJsStackDepth: number[] = [];\n /**\n * Used to keep track when samples should be integrated even if they\n * are not children of invocation trace events. This is useful in\n * cases where we can be missing the start of JS invocation events if\n * we start tracing half-way through.\n */\n #fakeJSInvocation = false;\n /**\n * The parsed CPU profile, holding the tree hierarchy of JS frames and\n * the sample data.\n */\n #profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;\n /**\n * Because GC nodes don't have a stack, we artificially add a stack to\n * them which corresponds to that of the previous sample. This map\n * tracks which node is used for the stack of a GC call.\n * Note that GC samples are not shown in the flamechart, however they\n * are used during the construction of for profile calls, as we can\n * infer information about the duration of the executed code when a\n * GC node is sampled.\n */\n #nodeForGC = new Map<Types.Events.SyntheticProfileCall, CPUProfile.ProfileTreeModel.ProfileNode>();\n\n #engineConfig: Types.Configuration.Configuration;\n #profileId: Types.Events.ProfileID;\n\n /**\n * Keeps track of the individual samples from the CPU Profile.\n * Only used with Debug Mode experiment enabled.\n */\n jsSampleEvents: Types.Events.SyntheticJSSample[] = [];\n\n constructor(\n profileModel: CPUProfile.CPUProfileDataModel.CPUProfileDataModel, profileId: Types.Events.ProfileID,\n pid: Types.Events.ProcessID, tid: Types.Events.ThreadID, configuration?: Types.Configuration.Configuration) {\n this.#profileModel = profileModel;\n this.#threadId = tid;\n this.#processId = pid;\n this.#engineConfig = configuration || Types.Configuration.defaults();\n this.#profileId = profileId;\n }\n\n buildProfileCalls(traceEvents: Types.Events.Event[]): Types.Events.SyntheticProfileCall[] {\n const mergedEvents = mergeEventsInOrder(traceEvents, this.callsFromProfileSamples());\n const stack = [];\n for (let i = 0; i < mergedEvents.length; i++) {\n const event = mergedEvents[i];\n // Because instant trace events have no duration, they don't provide\n // useful information for possible changes in the duration of calls\n // in the JS stack.\n if (event.ph === Types.Events.Phase.INSTANT && !extractSampleTraceId(event)) {\n continue;\n }\n if (stack.length === 0) {\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event);\n continue;\n }\n stack.push(event);\n this.#onTraceEventStart(event);\n continue;\n }\n\n const parentEvent = stack.at(-1);\n if (parentEvent === undefined) {\n continue;\n }\n const begin = event.ts;\n const parentBegin = parentEvent.ts;\n const parentDuration = parentEvent.dur || 0;\n const parentEnd = parentBegin + parentDuration;\n\n const startsAfterParent = begin >= parentEnd;\n if (startsAfterParent) {\n this.#onTraceEventEnd(parentEvent);\n stack.pop();\n i--;\n continue;\n }\n if (Types.Events.isProfileCall(event)) {\n this.#onProfileCall(event, parentEvent);\n continue;\n }\n this.#onTraceEventStart(event);\n stack.push(event);\n }\n while (stack.length) {\n const last = stack.pop();\n if (last) {\n this.#onTraceEventEnd(last);\n }\n }\n sortTraceEventsInPlace(this.jsSampleEvents);\n return this.#constructedProfileCalls;\n }\n\n #onTraceEventStart(event: Types.Events.Event): void {\n // Top level events cannot be nested into JS frames so we reset\n // the stack when we find one.\n if (event.name === Types.Events.Name.RUN_MICROTASKS || event.name === Types.Events.Name.RUN_TASK) {\n this.#lockedJsStackDepth = [];\n this.#truncateJSStack(0, event.ts);\n this.#fakeJSInvocation = false;\n }\n\n if (this.#fakeJSInvocation) {\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, event.ts);\n this.#fakeJSInvocation = false;\n }\n this.#extractStackTrace(event);\n // Keep track of the call frames in the stack before the event\n // happened. For the duration of this event, these frames cannot\n // change (none can be terminated before this event finishes).\n //\n // Also, every frame that is opened after this event, is considered\n // to be a descendant of the event. So once the event finishes, the\n // frames that were opened after it, need to be closed (see\n // onEndEvent).\n //\n // TODO(crbug.com/1417439):\n // The assumption that every frame opened after an event is a\n // descendant of the event is incorrect. For example, a JS call that\n // parents a trace event might have been sampled after the event was\n // dispatched. In this case the JS call would be discarded if this\n // event isn't an invocation event, otherwise the call will be\n // considered a child of the event. In both cases, the result would\n // be incorrect.\n this.#lockedJsStackDepth.push(this.#currentJSStack.length);\n }\n\n #onProfileCall(event: Types.Events.SyntheticProfileCall, parent?: Types.Events.Event): void {\n if ((parent && Types.Events.isJSInvocationEvent(parent)) || this.#fakeJSInvocation) {\n this.#extractStackTrace(event);\n } else if (Types.Events.isProfileCall(event) && this.#currentJSStack.length === 0) {\n // Force JS Samples to show up even if we are not inside a JS\n // invocation event, because we can be missing the start of JS\n // invocation events if we start tracing half-way through. Pretend\n // we have a top-level JS invocation event.\n this.#fakeJSInvocation = true;\n const stackDepthBefore = this.#currentJSStack.length;\n this.#extractStackTrace(event);\n this.#lockedJsStackDepth.push(stackDepthBefore);\n }\n }\n\n #onTraceEventEnd(event: Types.Events.Event): void {\n // Because the event has ended, any frames that happened after\n // this event are terminated. Frames that are ancestors to this\n // event are extended to cover its ending.\n const endTime = Types.Timing.Micro(event.ts + (event.dur ?? 0));\n this.#truncateJSStack(this.#lockedJsStackDepth.pop() || 0, endTime);\n }\n\n /**\n * Builds the initial calls with no duration from samples. Their\n * purpose is to be merged with the trace event array being parsed so\n * that they can be traversed in order with them and their duration\n * can be updated as the SampleIntegrator callbacks are invoked.\n */\n callsFromProfileSamples(): Types.Events.SyntheticProfileCall[] {\n const samples = this.#profileModel.samples;\n const timestamps = this.#profileModel.timestamps;\n if (!samples) {\n return [];\n }\n const calls: Types.Events.SyntheticProfileCall[] = [];\n let prevNode;\n for (let i = 0; i < samples.length; i++) {\n const node = this.#profileModel.nodeByIndex(i);\n const timestamp = milliToMicro(Types.Timing.Milli(timestamps[i]));\n if (!node) {\n continue;\n }\n const call = makeProfileCall(node, this.#profileId, i, timestamp, this.#processId, this.#threadId);\n calls.push(call);\n\n if (this.#engineConfig.debugMode) {\n const traceId = this.#profileModel.traceIds?.[i];\n this.jsSampleEvents.push(this.#makeJSSampleEvent(call, timestamp, traceId));\n }\n if (node.id === this.#profileModel.gcNode?.id && prevNode) {\n // GC samples have no stack, so we just put GC node on top of the\n // last recorded sample. Cache the previous sample for future\n // reference.\n this.#nodeForGC.set(call, prevNode);\n continue;\n }\n prevNode = node;\n }\n return calls;\n }\n\n /**\n * Given a synthetic profile call, returns an array of profile calls\n * representing the stack trace that profile call belongs to based on\n * its nodeId. The input profile call will be at the top of the\n * returned stack (last position), meaning that any other frames that\n * were effectively above it are omitted.\n * @param profileCall\n * @param overrideTimeStamp a custom timestamp to use for the returned\n * profile calls. If not defined, the timestamp of the input\n * profileCall is used instead. This param is useful for example when\n * creating the profile calls for a sample with a trace id, since the\n * timestamp of the corresponding trace event should be used instead\n * of the sample's.\n */\n\n #makeProfileCallsForStack(profileCall: Types.Events.SyntheticProfileCall, overrideTimeStamp?: Types.Timing.Micro):\n Types.Events.SyntheticProfileCall[] {\n let node = this.#profileModel.nodeById(profileCall.nodeId);\n const isGarbageCollection = node?.id === this.#profileModel.gcNode?.id;\n if (isGarbageCollection) {\n // Because GC don't have a stack, we use the stack of the previous\n // sample.\n node = this.#nodeForGC.get(profileCall) || null;\n }\n if (!node) {\n return [];\n }\n // `node.depth` is 0 based, so to set the size of the array we need\n // to add 1 to its value.\n const callFrames = new Array<Types.Events.SyntheticProfileCall>(node.depth + 1 + Number(isGarbageCollection));\n // Add the stack trace in reverse order (bottom first).\n let i = callFrames.length - 1;\n if (isGarbageCollection) {\n // Place the garbage collection call frame on top of the stack.\n callFrames[i--] = profileCall;\n }\n\n // Many of these ProfileCalls will be GC'd later when we estimate the frame\n // durations\n while (node) {\n callFrames[i--] = makeProfileCall(\n node, profileCall.profileId, profileCall.sampleIndex, overrideTimeStamp ?? profileCall.ts, this.#processId,\n this.#threadId);\n node = node.parent;\n }\n return callFrames;\n }\n\n #getStackForSampleTraceId(traceId: number, timestamp: Types.Timing.Micro): Types.Events.SyntheticProfileCall[]|null {\n const nodeId = this.#profileModel.traceIds?.[traceId];\n const node = nodeId && this.#profileModel.nodeById(nodeId);\n const maybeCallForTraceId =\n node && makeProfileCall(node, this.#profileId, -1, timestamp, this.#processId, this.#threadId);\n if (!maybeCallForTraceId) {\n return null;\n }\n if (this.#engineConfig.debugMode) {\n this.jsSampleEvents.push(this.#makeJSSampleEvent(maybeCallForTraceId, timestamp, traceId));\n }\n return this.#makeProfileCallsForStack(maybeCallForTraceId);\n }\n /**\n * Update tracked stack using this event's call stack.\n */\n #extractStackTrace(event: Types.Events.Event): void {\n let stackTrace = this.#currentJSStack;\n if (Types.Events.isProfileCall(event)) {\n stackTrace = this.#makeProfileCallsForStack(event);\n }\n const traceId = extractSampleTraceId(event);\n const maybeCallForTraceId = traceId && this.#getStackForSampleTraceId(traceId, event.ts);\n if (maybeCallForTraceId) {\n stackTrace = maybeCallForTraceId;\n }\n\n SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);\n\n const endTime = event.ts + (event.dur || 0);\n const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);\n let i;\n // Merge a sample's stack frames with the stack frames we have\n // so far if we detect they are equivalent.\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // ^ t = x1 ^ t = x2\n\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // ^ t = x2\n for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {\n const newFrame = stackTrace[i].callFrame;\n const oldFrame = this.#currentJSStack[i].callFrame;\n if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {\n break;\n }\n // Scoot the right edge of this callFrame to the right\n this.#currentJSStack[i].dur =\n Types.Timing.Micro(Math.max(this.#currentJSStack[i].dur || 0, endTime - this.#currentJSStack[i].ts));\n }\n\n // If there are call frames in the sample that differ with the stack\n // we have, update the stack, but keeping the common frames in place\n // Graphically\n // This:\n // Current stack trace Sample\n // [-------A------] [A]\n // [-------B------] [B]\n // [-------C------] [C]\n // [-------D------] [E]\n // ^ t = x1 ^ t = x2\n // Becomes this:\n // New stack trace after merge\n // [--------A-------]\n // [--------B-------]\n // [--------C-------]\n // [E]\n // ^ t = x2\n this.#truncateJSStack(i, event.ts);\n\n for (; i < stackTrace.length; ++i) {\n const call = stackTrace[i];\n if (call.nodeId === this.#profileModel.programNode?.id || call.nodeId === this.#profileModel.root?.id ||\n call.nodeId === this.#profileModel.idleNode?.id || call.nodeId === this.#profileModel.gcNode?.id) {\n // Skip (root), (program) and (idle) frames, since this are not\n // relevant for web profiling and we don't want to show them in\n // the timeline.\n continue;\n }\n this.#currentJSStack.push(call);\n this.#constructedProfileCalls.push(call);\n }\n }\n\n /**\n * When a call stack that differs from the one we are tracking has\n * been detected in the samples, the latter is \"truncated\" by\n * setting the ending time of its call frames and removing the top\n * call frames that aren't shared with the new call stack. This way,\n * we can update the tracked stack with the new call frames on top.\n * @param depth the amount of call frames from bottom to top that\n * should be kept in the tracking stack trace. AKA amount of shared\n * call frames between two stacks.\n * @param time the new end of the call frames in the stack.\n */\n #truncateJSStack(depth: number, time: Types.Timing.Micro): void {\n if (this.#lockedJsStackDepth.length) {\n const lockedDepth = this.#lockedJsStackDepth.at(-1);\n if (lockedDepth && depth < lockedDepth) {\n console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);\n depth = lockedDepth;\n }\n }\n if (this.#currentJSStack.length < depth) {\n console.error(`Trying to truncate higher than the current stack size at ${time}`);\n depth = this.#currentJSStack.length;\n }\n for (let k = 0; k < this.#currentJSStack.length; ++k) {\n this.#currentJSStack[k].dur = Types.Timing.Micro(Math.max(time - this.#currentJSStack[k].ts, 0));\n }\n this.#currentJSStack.length = depth;\n }\n\n #makeJSSampleEvent(call: Types.Events.SyntheticProfileCall, timestamp: Types.Timing.Micro, traceId?: number):\n Types.Events.SyntheticJSSample {\n const JSSampleEvent: Types.Events.SyntheticJSSample = {\n name: Types.Events.Name.JS_SAMPLE,\n cat: 'devtools.timeline',\n args: {\n data: {traceId, stackTrace: this.#makeProfileCallsForStack(call).map(e => e.callFrame)},\n },\n ph: Types.Events.Phase.INSTANT,\n ts: timestamp,\n dur: Types.Timing.Micro(0),\n pid: this.#processId,\n tid: this.#threadId,\n };\n return JSSampleEvent;\n }\n\n static framesAreEqual(frame1: Protocol.Runtime.CallFrame, frame2: Protocol.Runtime.CallFrame): boolean {\n return frame1.scriptId === frame2.scriptId && frame1.functionName === frame2.functionName &&\n frame1.lineNumber === frame2.lineNumber;\n }\n\n static showNativeName(name: string, runtimeCallStatsEnabled: boolean): boolean {\n return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));\n }\n\n static nativeGroup(nativeName: string): SamplesIntegrator.NativeGroups|null {\n if (nativeName.startsWith('Parse')) {\n return SamplesIntegrator.NativeGroups.PARSE;\n }\n if (nativeName.startsWith('Compile') || nativeName.startsWith('Recompile')) {\n return SamplesIntegrator.NativeGroups.COMPILE;\n }\n return null;\n }\n\n static isNativeRuntimeFrame(frame: Protocol.Runtime.CallFrame): boolean {\n return frame.url === 'native V8Runtime';\n }\n\n static filterStackFrames(stack: Types.Events.SyntheticProfileCall[], engineConfig: Types.Configuration.Configuration):\n void {\n const showAllEvents = engineConfig.showAllEvents;\n if (showAllEvents) {\n return;\n }\n let previousNativeFrameName: string|null = null;\n let j = 0;\n for (let i = 0; i < stack.length; ++i) {\n const frame = stack[i].callFrame;\n const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);\n if (nativeRuntimeFrame &&\n !SamplesIntegrator.showNativeName(frame.functionName, engineConfig.includeRuntimeCallStats)) {\n continue;\n }\n const nativeFrameName = nativeRuntimeFrame ? SamplesIntegrator.nativeGroup(frame.functionName) : null;\n if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {\n continue;\n }\n previousNativeFrameName = nativeFrameName;\n stack[j++] = stack[i];\n }\n stack.length = j;\n }\n\n static createFakeTraceFromCpuProfile(profile: Protocol.Profiler.Profile, tid: Types.Events.ThreadID):\n Types.File.TraceFile {\n const events: Types.Events.Event[] = [];\n\n const threadName = `Thread ${tid}`;\n appendEvent('TracingStartedInPage', {data: {sessionId: '1'}}, 0, 0, Types.Events.Phase.METADATA);\n appendEvent(Types.Events.Name.THREAD_NAME, {name: threadName}, 0, 0, Types.Events.Phase.METADATA, '__metadata');\n if (!profile) {\n return {traceEvents: events, metadata: {}};\n }\n\n // Append a root to show the start time of the profile (which is earlier than first sample), so the Performance\n // panel won't truncate this time period.\n // 'JSRoot' doesn't exist in the new engine and is not the name of an actual trace event, but changing it might break other trace processing tools that rely on this, so we stick with this name.\n // TODO(crbug.com/341234884): consider removing this or clarify why it's required.\n appendEvent(\n 'JSRoot', {}, profile.startTime, profile.endTime - profile.startTime, Types.Events.Phase.COMPLETE, 'toplevel');\n\n // TODO: create a `Profile` event instead, as `cpuProfile` is legacy\n appendEvent('CpuProfile', {data: {cpuProfile: profile}}, profile.endTime, 0, Types.Events.Phase.COMPLETE);\n return {\n traceEvents: events,\n metadata: {\n dataOrigin: Types.File.DataOrigin.CPU_PROFILE,\n }\n };\n\n function appendEvent(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n name: string, args: any, ts: number, dur?: number, ph?: Types.Events.Phase, cat?: string): Types.Events.Event {\n const event: Types.Events.Event = {\n cat: cat || 'disabled-by-default-devtools.timeline',\n name,\n ph: ph || Types.Events.Phase.COMPLETE,\n pid: Types.Events.ProcessID(1),\n tid,\n ts: Types.Timing.Micro(ts),\n args,\n };\n\n if (dur) {\n event.dur = Types.Timing.Micro(dur);\n }\n events.push(event);\n return event;\n }\n }\n}\n\nexport namespace SamplesIntegrator {\n export const enum NativeGroups {\n COMPILE = 'Compile',\n PARSE = 'Parse',\n }\n}\n"]}
|
|
@@ -6,7 +6,6 @@ export declare class SyntheticEventsManager {
|
|
|
6
6
|
static getActiveManager(): SyntheticEventsManager;
|
|
7
7
|
static reset(): void;
|
|
8
8
|
static registerSyntheticEvent<T extends Types.Events.SyntheticBased>(syntheticEvent: Omit<T, '_tag'>): T;
|
|
9
|
-
static registerServerTiming(syntheticEvent: Omit<Types.Events.SyntheticServerTiming, '_tag'>): Types.Events.SyntheticServerTiming;
|
|
10
9
|
private constructor();
|
|
11
10
|
/**
|
|
12
11
|
* Registers and returns a branded synthetic event. Synthetic events need to
|
|
@@ -41,10 +41,6 @@ export class SyntheticEventsManager {
|
|
|
41
41
|
return syntheticEvent;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
static registerServerTiming(syntheticEvent) {
|
|
45
|
-
// TODO(crbug.com/340811171): Implement
|
|
46
|
-
return syntheticEvent;
|
|
47
|
-
}
|
|
48
44
|
constructor(rawEvents) {
|
|
49
45
|
this.#rawTraceEvents = rawEvents;
|
|
50
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyntheticEvents.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SyntheticEvents.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,IAAI,aAAa,GAAgC,IAAI,CAAC;AAEtD,MAAM,OAAO,sBAAsB;IACjC;;;OAGG;IACH,gBAAgB,GAAkC,EAAE,CAAC;IACrD;;OAEG;IACH,eAAe,GAAkC,EAAE,CAAC;IAEpD,MAAM,CAAC,QAAQ,CAAC,OAA+B;QAC7C,aAAa,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,SAAwC;QAC/D,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,SAAS,CAAC,CAAC;QACtD,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,gBAAgB;QACrB,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACpF,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,KAAK;QACV,aAAa,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,sBAAsB,CAAwC,cAA+B;QAClG,IAAI,CAAC;YACH,OAAO,sBAAsB,CAAC,gBAAgB,EAAE,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC;QAC1F,CAAC;QAAC,MAAM,CAAC;YACP,2EAA2E;YAC3E,sEAAsE;YACtE,sEAAsE;YACtE,+BAA+B;YAC/B,OAAO,cAAmB,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"SyntheticEvents.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/helpers/SyntheticEvents.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B,IAAI,aAAa,GAAgC,IAAI,CAAC;AAEtD,MAAM,OAAO,sBAAsB;IACjC;;;OAGG;IACH,gBAAgB,GAAkC,EAAE,CAAC;IACrD;;OAEG;IACH,eAAe,GAAkC,EAAE,CAAC;IAEpD,MAAM,CAAC,QAAQ,CAAC,OAA+B;QAC7C,aAAa,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,SAAwC;QAC/D,MAAM,OAA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E,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,uEAAuE,aAAa,EAAE,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,kBAAkB;QAChB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;CACF","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 Types from '../types/types.js';\n\nlet activeManager: SyntheticEventsManager|null = null;\n\nexport class SyntheticEventsManager {\n /**\n * All synthetic entries created in a trace from a corresponding trace events.\n * (ProfileCalls are excluded because they are not based on a real trace event)\n */\n #syntheticTraces: Types.Events.SyntheticBased[] = [];\n /**\n * All raw entries from a trace.\n */\n #rawTraceEvents: readonly Types.Events.Event[] = [];\n\n static activate(manager: SyntheticEventsManager): void {\n activeManager = manager;\n }\n\n static createAndActivate(rawEvents: readonly Types.Events.Event[]): SyntheticEventsManager {\n const manager = new SyntheticEventsManager(rawEvents);\n SyntheticEventsManager.activate(manager);\n return manager;\n }\n\n static getActiveManager(): SyntheticEventsManager {\n if (!activeManager) {\n throw new Error('Attempted to get a SyntheticEventsManager without initializing');\n }\n return activeManager;\n }\n\n static reset(): void {\n activeManager = null;\n }\n\n static registerSyntheticEvent<T extends Types.Events.SyntheticBased>(syntheticEvent: Omit<T, '_tag'>): T {\n try {\n return SyntheticEventsManager.getActiveManager().registerSyntheticEvent(syntheticEvent);\n } catch {\n // If no active manager has been initialized, we assume the trace engine is\n // not running as part of the Performance panel. In this case we don't\n // register synthetic events because we don't need to support timeline\n // modifications serialization.\n return syntheticEvent as T;\n }\n }\n\n private constructor(rawEvents: readonly Types.Events.Event[]) {\n this.#rawTraceEvents = rawEvents;\n }\n\n /**\n * Registers and returns a branded synthetic event. Synthetic events need to\n * be created with this method to ensure they are registered and made\n * available to load events using serialized keys.\n */\n registerSyntheticEvent<T extends Types.Events.SyntheticBased>(syntheticEvent: Omit<T, '_tag'>): T {\n const rawIndex = this.#rawTraceEvents.indexOf(syntheticEvent.rawSourceEvent);\n if (rawIndex < 0) {\n throw new Error('Attempted to register a synthetic event paired to an unknown raw event.');\n }\n const eventAsSynthetic = syntheticEvent as T;\n this.#syntheticTraces[rawIndex] = eventAsSynthetic;\n return eventAsSynthetic;\n }\n\n syntheticEventForRawEventIndex(rawEventIndex: number): Types.Events.SyntheticBased {\n const syntheticEvent = this.#syntheticTraces.at(rawEventIndex);\n if (!syntheticEvent) {\n throw new Error(`Attempted to get a synthetic event from an unknown raw event index: ${rawEventIndex}`);\n }\n return syntheticEvent;\n }\n\n getSyntheticTraces(): Types.Events.SyntheticBased[] {\n return this.#syntheticTraces;\n }\n\n getRawTraceEvents(): readonly Types.Events.Event[] {\n return this.#rawTraceEvents;\n }\n}\n"]}
|
|
@@ -88,7 +88,7 @@ export declare function getZeroIndexedLineAndColumnForEvent(event: Types.Events.
|
|
|
88
88
|
* stack. If you want to obtain the whole stack trace you might need to
|
|
89
89
|
* use the @see Trace.Extras.StackTraceForEvent util.
|
|
90
90
|
*/
|
|
91
|
-
export declare function
|
|
91
|
+
export declare function getZeroIndexedStackTraceInEventPayload(event: Types.Events.Event): Types.Events.CallFrame[] | null;
|
|
92
92
|
/**
|
|
93
93
|
* Given a 1-based call frame creates a 0-based one.
|
|
94
94
|
*/
|
|
@@ -145,4 +145,5 @@ export declare function eventHasCategory(event: Types.Events.Event, category: st
|
|
|
145
145
|
export declare function isMatchingCallFrame(eventFrame: Types.Events.CallFrame, nodeFrame: Protocol.Runtime.CallFrame): boolean;
|
|
146
146
|
export declare function eventContainsTimestamp(event: Types.Events.Event, ts: Types.Timing.Micro): boolean;
|
|
147
147
|
export declare function extractSampleTraceId(event: Types.Events.Event): number | null;
|
|
148
|
+
export declare const VISIBLE_TRACE_EVENT_TYPES: Set<Types.Events.Name>;
|
|
148
149
|
export {};
|
|
@@ -362,7 +362,7 @@ export function getZeroIndexedLineAndColumnForEvent(event) {
|
|
|
362
362
|
* stack. If you want to obtain the whole stack trace you might need to
|
|
363
363
|
* use the @see Trace.Extras.StackTraceForEvent util.
|
|
364
364
|
*/
|
|
365
|
-
export function
|
|
365
|
+
export function getZeroIndexedStackTraceInEventPayload(event) {
|
|
366
366
|
const stack = stackTraceInEvent(event);
|
|
367
367
|
if (!stack) {
|
|
368
368
|
return null;
|
|
@@ -593,4 +593,104 @@ export function extractSampleTraceId(event) {
|
|
|
593
593
|
}
|
|
594
594
|
return event.args?.sampleTraceId ?? event.args?.data?.sampleTraceId ?? null;
|
|
595
595
|
}
|
|
596
|
+
// This exactly matches EntryStyles.visibleTypes. See the runtime verification in maybeInitSylesMap.
|
|
597
|
+
// TODO(crbug.com/410884528)
|
|
598
|
+
export const VISIBLE_TRACE_EVENT_TYPES = new Set([
|
|
599
|
+
"AbortPostTaskCallback" /* Types.Events.Name.ABORT_POST_TASK_CALLBACK */,
|
|
600
|
+
"Animation" /* Types.Events.Name.ANIMATION */,
|
|
601
|
+
"AsyncTask" /* Types.Events.Name.ASYNC_TASK */,
|
|
602
|
+
"v8.deserializeOnBackground" /* Types.Events.Name.BACKGROUND_DESERIALIZE */,
|
|
603
|
+
"v8.produceModuleCache" /* Types.Events.Name.CACHE_MODULE */,
|
|
604
|
+
"v8.produceCache" /* Types.Events.Name.CACHE_SCRIPT */,
|
|
605
|
+
"CancelAnimationFrame" /* Types.Events.Name.CANCEL_ANIMATION_FRAME */,
|
|
606
|
+
"CancelIdleCallback" /* Types.Events.Name.CANCEL_IDLE_CALLBACK */,
|
|
607
|
+
"Commit" /* Types.Events.Name.COMMIT */,
|
|
608
|
+
"V8.CompileCode" /* Types.Events.Name.COMPILE_CODE */,
|
|
609
|
+
"V8.CompileModule" /* Types.Events.Name.COMPILE_MODULE */,
|
|
610
|
+
"v8.compile" /* Types.Events.Name.COMPILE */,
|
|
611
|
+
"CompositeLayers" /* Types.Events.Name.COMPOSITE_LAYERS */,
|
|
612
|
+
"ComputeIntersections" /* Types.Events.Name.COMPUTE_INTERSECTION */,
|
|
613
|
+
"ConsoleTime" /* Types.Events.Name.CONSOLE_TIME */,
|
|
614
|
+
"CppGC.IncrementalSweep" /* Types.Events.Name.CPPGC_SWEEP */,
|
|
615
|
+
"DoDecryptReply" /* Types.Events.Name.CRYPTO_DO_DECRYPT_REPLY */,
|
|
616
|
+
"DoDecrypt" /* Types.Events.Name.CRYPTO_DO_DECRYPT */,
|
|
617
|
+
"DoDigestReply" /* Types.Events.Name.CRYPTO_DO_DIGEST_REPLY */,
|
|
618
|
+
"DoDigest" /* Types.Events.Name.CRYPTO_DO_DIGEST */,
|
|
619
|
+
"DoEncryptReply" /* Types.Events.Name.CRYPTO_DO_ENCRYPT_REPLY */,
|
|
620
|
+
"DoEncrypt" /* Types.Events.Name.CRYPTO_DO_ENCRYPT */,
|
|
621
|
+
"DoSignReply" /* Types.Events.Name.CRYPTO_DO_SIGN_REPLY */,
|
|
622
|
+
"DoSign" /* Types.Events.Name.CRYPTO_DO_SIGN */,
|
|
623
|
+
"DoVerifyReply" /* Types.Events.Name.CRYPTO_DO_VERIFY_REPLY */,
|
|
624
|
+
"DoVerify" /* Types.Events.Name.CRYPTO_DO_VERIFY */,
|
|
625
|
+
"Decode Image" /* Types.Events.Name.DECODE_IMAGE */,
|
|
626
|
+
"EmbedderCallback" /* Types.Events.Name.EMBEDDER_CALLBACK */,
|
|
627
|
+
"v8.evaluateModule" /* Types.Events.Name.EVALUATE_MODULE */,
|
|
628
|
+
"EvaluateScript" /* Types.Events.Name.EVALUATE_SCRIPT */,
|
|
629
|
+
"EventDispatch" /* Types.Events.Name.EVENT_DISPATCH */,
|
|
630
|
+
"EventTiming" /* Types.Events.Name.EVENT_TIMING */,
|
|
631
|
+
"V8.FinalizeDeserialization" /* Types.Events.Name.FINALIZE_DESERIALIZATION */,
|
|
632
|
+
"FireAnimationFrame" /* Types.Events.Name.FIRE_ANIMATION_FRAME */,
|
|
633
|
+
"FireIdleCallback" /* Types.Events.Name.FIRE_IDLE_CALLBACK */,
|
|
634
|
+
"FunctionCall" /* Types.Events.Name.FUNCTION_CALL */,
|
|
635
|
+
"BlinkGC.AtomicPhase" /* Types.Events.Name.GC_COLLECT_GARBARGE */,
|
|
636
|
+
"GCEvent" /* Types.Events.Name.GC */,
|
|
637
|
+
"GPUTask" /* Types.Events.Name.GPU_TASK */,
|
|
638
|
+
"HandlePostMessage" /* Types.Events.Name.HANDLE_POST_MESSAGE */,
|
|
639
|
+
"HitTest" /* Types.Events.Name.HIT_TEST */,
|
|
640
|
+
"JSSample" /* Types.Events.Name.JS_SAMPLE */,
|
|
641
|
+
"Layerize" /* Types.Events.Name.LAYERIZE */,
|
|
642
|
+
"Layout" /* Types.Events.Name.LAYOUT */,
|
|
643
|
+
"MajorGC" /* Types.Events.Name.MAJOR_GC */,
|
|
644
|
+
"MinorGC" /* Types.Events.Name.MINOR_GC */,
|
|
645
|
+
"V8.OptimizeCode" /* Types.Events.Name.OPTIMIZE_CODE */,
|
|
646
|
+
"PaintSetup" /* Types.Events.Name.PAINT_SETUP */,
|
|
647
|
+
"Paint" /* Types.Events.Name.PAINT */,
|
|
648
|
+
"ParseAuthorStyleSheet" /* Types.Events.Name.PARSE_AUTHOR_STYLE_SHEET */,
|
|
649
|
+
"ParseHTML" /* Types.Events.Name.PARSE_HTML */,
|
|
650
|
+
"PrePaint" /* Types.Events.Name.PRE_PAINT */,
|
|
651
|
+
"ProfileCall" /* Types.Events.Name.PROFILE_CALL */,
|
|
652
|
+
"Program" /* Types.Events.Name.PROGRAM */,
|
|
653
|
+
"RasterTask" /* Types.Events.Name.RASTER_TASK */,
|
|
654
|
+
"RequestAnimationFrame" /* Types.Events.Name.REQUEST_ANIMATION_FRAME */,
|
|
655
|
+
"RequestIdleCallback" /* Types.Events.Name.REQUEST_IDLE_CALLBACK */,
|
|
656
|
+
"ResourceFinish" /* Types.Events.Name.RESOURCE_FINISH */,
|
|
657
|
+
"ResourceReceivedData" /* Types.Events.Name.RESOURCE_RECEIVE_DATA */,
|
|
658
|
+
"ResourceReceiveResponse" /* Types.Events.Name.RESOURCE_RECEIVE_RESPONSE */,
|
|
659
|
+
"ResourceSendRequest" /* Types.Events.Name.RESOURCE_SEND_REQUEST */,
|
|
660
|
+
"ResourceWillSendRequest" /* Types.Events.Name.RESOURCE_WILL_SEND_REQUEST */,
|
|
661
|
+
"RunMicrotasks" /* Types.Events.Name.RUN_MICROTASKS */,
|
|
662
|
+
"RunPostTaskCallback" /* Types.Events.Name.RUN_POST_TASK_CALLBACK */,
|
|
663
|
+
"RunTask" /* Types.Events.Name.RUN_TASK */,
|
|
664
|
+
"SchedulePostMessage" /* Types.Events.Name.SCHEDULE_POST_MESSAGE */,
|
|
665
|
+
"SchedulePostTaskCallback" /* Types.Events.Name.SCHEDULE_POST_TASK_CALLBACK */,
|
|
666
|
+
"ScheduleStyleRecalculation" /* Types.Events.Name.SCHEDULE_STYLE_RECALCULATION */,
|
|
667
|
+
"ScrollLayer" /* Types.Events.Name.SCROLL_LAYER */,
|
|
668
|
+
"CpuProfiler::StartProfiling" /* Types.Events.Name.START_PROFILING */,
|
|
669
|
+
"v8.parseOnBackgroundParsing" /* Types.Events.Name.STREAMING_COMPILE_SCRIPT_PARSING */,
|
|
670
|
+
"v8.parseOnBackgroundWaiting" /* Types.Events.Name.STREAMING_COMPILE_SCRIPT_WAITING */,
|
|
671
|
+
"v8.parseOnBackground" /* Types.Events.Name.STREAMING_COMPILE_SCRIPT */,
|
|
672
|
+
"SyntheticLayoutShiftCluster" /* Types.Events.Name.SYNTHETIC_LAYOUT_SHIFT_CLUSTER */,
|
|
673
|
+
"SyntheticLayoutShift" /* Types.Events.Name.SYNTHETIC_LAYOUT_SHIFT */,
|
|
674
|
+
"TimeStamp" /* Types.Events.Name.TIME_STAMP */,
|
|
675
|
+
"TimerFire" /* Types.Events.Name.TIMER_FIRE */,
|
|
676
|
+
"TimerInstall" /* Types.Events.Name.TIMER_INSTALL */,
|
|
677
|
+
"TimerRemove" /* Types.Events.Name.TIMER_REMOVE */,
|
|
678
|
+
"UpdateLayerTree" /* Types.Events.Name.UPDATE_LAYER_TREE */,
|
|
679
|
+
"UpdateLayoutTree" /* Types.Events.Name.UPDATE_LAYOUT_TREE */,
|
|
680
|
+
"UserTiming" /* Types.Events.Name.USER_TIMING */,
|
|
681
|
+
"V8Console::runTask" /* Types.Events.Name.V8_CONSOLE_RUN_TASK */,
|
|
682
|
+
"v8.wasm.cachedModule" /* Types.Events.Name.WASM_CACHED_MODULE */,
|
|
683
|
+
"v8.wasm.compiledModule" /* Types.Events.Name.WASM_COMPILED_MODULE */,
|
|
684
|
+
"v8.wasm.moduleCacheHit" /* Types.Events.Name.WASM_MODULE_CACHE_HIT */,
|
|
685
|
+
"v8.wasm.moduleCacheInvalid" /* Types.Events.Name.WASM_MODULE_CACHE_INVALID */,
|
|
686
|
+
"v8.wasm.streamFromResponseCallback" /* Types.Events.Name.WASM_STREAM_FROM_RESPONSE_CALLBACK */,
|
|
687
|
+
"WebSocketCreate" /* Types.Events.Name.WEB_SOCKET_CREATE */,
|
|
688
|
+
"WebSocketDestroy" /* Types.Events.Name.WEB_SOCKET_DESTROY */,
|
|
689
|
+
"WebSocketReceiveHandshakeResponse" /* Types.Events.Name.WEB_SOCKET_RECEIVE_HANDSHAKE_REQUEST */,
|
|
690
|
+
"WebSocketReceive" /* Types.Events.Name.WEB_SOCKET_RECEIVE */,
|
|
691
|
+
"WebSocketSendHandshakeRequest" /* Types.Events.Name.WEB_SOCKET_SEND_HANDSHAKE_REQUEST */,
|
|
692
|
+
"WebSocketSend" /* Types.Events.Name.WEB_SOCKET_SEND */,
|
|
693
|
+
"XHRLoad" /* Types.Events.Name.XHR_LOAD */,
|
|
694
|
+
"XHRReadyStateChange" /* Types.Events.Name.XHR_READY_STATE_CHANGED */,
|
|
695
|
+
]);
|
|
596
696
|
//# sourceMappingURL=Trace.js.map
|