diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-29 10:46:47 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-02 12:02:10 +0000 |
commit | 99677208ff3b216fdfec551fbe548da5520cd6fb (patch) | |
tree | 476a4865c10320249360e859d8fdd3e01833b03a /chromium/third_party/catapult | |
parent | c30a6232df03e1efbd9f3b226777b07e087a1122 (diff) | |
download | qtwebengine-chromium-99677208ff3b216fdfec551fbe548da5520cd6fb.tar.gz |
BASELINE: Update Chromium to 86.0.4240.124
Change-Id: Ide0ff151e94cd665ae6521a446995d34a9d1d644
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/catapult')
25 files changed, 905 insertions, 329 deletions
diff --git a/chromium/third_party/catapult/BUILD.gn b/chromium/third_party/catapult/BUILD.gn index 059400fb60f..aa6e5d059a4 100644 --- a/chromium/third_party/catapult/BUILD.gn +++ b/chromium/third_party/catapult/BUILD.gn @@ -62,6 +62,7 @@ group("telemetry_chrome_test_support") { "third_party/cloudstorage/", "third_party/coverage/", "third_party/d3/", + "third_party/depot_tools/", "third_party/flot/", "third_party/gae_ts_mon/", "third_party/google-auth/", diff --git a/chromium/third_party/catapult/catapult_build/run_dev_server_tests.py b/chromium/third_party/catapult/catapult_build/run_dev_server_tests.py index 10bce608cd6..59509398017 100644 --- a/chromium/third_party/catapult/catapult_build/run_dev_server_tests.py +++ b/chromium/third_party/catapult/catapult_build/run_dev_server_tests.py @@ -206,6 +206,7 @@ def RunTests(args, chrome_path): '--enable-features=ForceWebRequestProxyForTest', '--enable-blink-features=CustomElementsV0,' 'HTMLImports,ShadowDOMV0', + '--force-device-scale-factor=1', ('http://localhost:%s/%s/tests.html?' % (port, args.tests)) + 'headless=true&testTypeToRun=all', ] diff --git a/chromium/third_party/catapult/common/py_utils/py_utils/discover.py b/chromium/third_party/catapult/common/py_utils/py_utils/discover.py index ae8ba87d9fc..a9333e2d7dd 100644 --- a/chromium/third_party/catapult/common/py_utils/py_utils/discover.py +++ b/chromium/third_party/catapult/common/py_utils/py_utils/discover.py @@ -101,20 +101,18 @@ def DiscoverClasses(start_dir, for module in modules: new_classes = DiscoverClassesInModule( module, base_class, index_by_class_name, directly_constructable) - # TODO(nednguyen): we should remove index_by_class_name once + # TODO(crbug.com/548652): we should remove index_by_class_name once # benchmark_smoke_unittest in chromium/src/tools/perf no longer relied # naming collisions to reduce the number of smoked benchmark tests. - # crbug.com/548652 if index_by_class_name: AssertNoKeyConflicts(classes, new_classes) classes = dict(list(classes.items()) + list(new_classes.items())) return classes -# TODO(nednguyen): we should remove index_by_class_name once +# TODO(crbug.com/548652): we should remove index_by_class_name once # benchmark_smoke_unittest in chromium/src/tools/perf no longer relied # naming collisions to reduce the number of smoked benchmark tests. -# crbug.com/548652 def DiscoverClassesInModule(module, base_class, index_by_class_name=False, diff --git a/chromium/third_party/catapult/common/py_utils/py_utils/webpagereplay_go_server.py b/chromium/third_party/catapult/common/py_utils/py_utils/webpagereplay_go_server.py index 950e8adcb79..26b462dc4e3 100644 --- a/chromium/third_party/catapult/common/py_utils/py_utils/webpagereplay_go_server.py +++ b/chromium/third_party/catapult/common/py_utils/py_utils/webpagereplay_go_server.py @@ -102,16 +102,9 @@ class ReplayServer(object): # subprocess. self._temp_log_file_path = None - # Assign the downloader func and binary_manager - downloader = None - if binary_downloader: - downloader = binary_downloader - else: - configs = [CHROME_BINARY_CONFIG, TELEMETRY_PROJECT_CONFIG] - downloader = binary_manager.BinaryManager(configs).FetchPath - + self._downloader = binary_downloader self._cmd_line = self._GetCommandLine( - self._GetGoBinaryPath(downloader=downloader), http_port, https_port, + self._GetGoBinaryPath(), http_port, https_port, replay_options, archive_path) if RECORD in replay_options or 'record' in replay_options: @@ -122,19 +115,44 @@ class ReplayServer(object): self.replay_process = None - @classmethod - def _GetGoBinaryPath(cls, downloader): - if not cls._go_binary_path: - cls._go_binary_path = downloader( + def _GetDownloader(self): + """Gets the downloader used to download wpr_go binary from GCS.""" + if ReplayServer._go_binary_path: + # If the _go_binary_path was already set, then no need to use downloader + # to download via binary_manager. + self._downloader = None + elif not self._downloader: + configs = [CHROME_BINARY_CONFIG, TELEMETRY_PROJECT_CONFIG] + self._downloader = binary_manager.BinaryManager(configs).FetchPath + return self._downloader + + def _GetGoBinaryPath(self): + """Gets the _go_binary_path if it already set, or downloads it.""" + if not ReplayServer._go_binary_path: + downloader = self._GetDownloader() + if not downloader: + raise RuntimeError('downloader should not be None ' + 'while _go_binary_path is None') + ReplayServer._go_binary_path = downloader( 'wpr_go', py_utils.GetHostOsName(), py_utils.GetHostArchName()) - return cls._go_binary_path + return ReplayServer._go_binary_path @classmethod def SetGoBinaryPath(cls, go_binary_path): """Overrides the _go_binary_path. This allows the server to use WPRGO files retrieved from somewhere - other than GCS, such as CIPD.""" + other than GCS via binary_manager, such as test isolation. + + For chromium project to use WPR, it is encourage to use test isolation, + and therefore should call SetGoBinaryPath to set _go_binary_path. + + For Catapult/Telemetry project, the tradition is to download wpr_go + binary via binary_manager. So do not call SetGoBinaryPath. + """ + if not os.path.exists(go_binary_path): + raise ValueError('SetGoBinaryPath could not set {} as it does not exist' + .format(go_binary_path)) cls._go_binary_path = go_binary_path @property diff --git a/chromium/third_party/catapult/tracing/PRESUBMIT.py b/chromium/third_party/catapult/tracing/PRESUBMIT.py index b087f658fb4..90442392078 100644 --- a/chromium/third_party/catapult/tracing/PRESUBMIT.py +++ b/chromium/third_party/catapult/tracing/PRESUBMIT.py @@ -41,7 +41,7 @@ def _CheckRegisteredDiagnostics(input_api, output_api): def _WarnOnReservedInfosChanges(input_api, output_api): source_file_filter = lambda x: input_api.FilterSourceFile( - x, white_list=[r'.*reserved_infos\.(py|cc)$']) + x, files_to_check=[r'.*reserved_infos\.(py|cc)$']) count = len(input_api.AffectedSourceFiles(source_file_filter)) results = [] @@ -55,7 +55,7 @@ def _WarnOnReservedInfosChanges(input_api, output_api): def _CheckHistogramProtoIsGated(input_api, output_api): source_file_filter = lambda x: input_api.FilterSourceFile( - x, white_list=[r'.*\.py$'], black_list=['.*PRESUBMIT.py$']) + x, files_to_check=[r'.*\.py$'], block_list=['.*PRESUBMIT.py$']) files = [] for f in input_api.AffectedSourceFiles(source_file_filter): @@ -76,7 +76,7 @@ def _CheckHistogramProtoIsGated(input_api, output_api): def _CheckProtoNamespace(input_api, output_api): source_file_filter = lambda x: input_api.FilterSourceFile( - x, white_list=[r'.*\.(cc|h)$']) + x, files_to_check=[r'.*\.(cc|h)$']) files = [] for f in input_api.AffectedSourceFiles(source_file_filter): @@ -117,10 +117,10 @@ def _CheckChange(input_api, output_api): sys.path = original_sys_path - black_list = input_api.DEFAULT_BLACK_LIST + (".*_pb2.py$",) + files_to_skip = input_api.DEFAULT_FILES_TO_SKIP + (".*_pb2.py$",) results += input_api.RunTests(input_api.canned_checks.GetPylint( input_api, output_api, extra_paths_list=_GetPathsToPrepend(input_api), - pylintrc='../pylintrc', black_list=black_list)) + pylintrc='../pylintrc', files_to_skip=files_to_skip)) results += _CheckRegisteredMetrics(input_api, output_api) results += _CheckRegisteredDiagnostics(input_api, output_api) diff --git a/chromium/third_party/catapult/tracing/trace_viewer.gni b/chromium/third_party/catapult/tracing/trace_viewer.gni index f82c66eb418..18d64554a28 100644 --- a/chromium/third_party/catapult/tracing/trace_viewer.gni +++ b/chromium/third_party/catapult/tracing/trace_viewer.gni @@ -140,6 +140,7 @@ tracing_js_html_files = [ "tracing/extras/importer/linux_perf/rss_parser.html", "tracing/extras/importer/linux_perf/sched_parser.html", "tracing/extras/importer/linux_perf/sync_parser.html", + "tracing/extras/importer/linux_perf/thermal_parser.html", "tracing/extras/importer/linux_perf/workqueue_parser.html", "tracing/extras/importer/oboe.html", "tracing/extras/importer/pako.html", @@ -239,6 +240,7 @@ tracing_js_html_files = [ "tracing/metrics/v8/runtime_stats_metric.html", "tracing/metrics/v8/utils.html", "tracing/metrics/v8/v8_metrics.html", + "tracing/metrics/v8/wasm_metric.html", "tracing/metrics/vr/frame_cycle_duration_metric.html", "tracing/metrics/vr/webvr_metric.html", "tracing/metrics/vr/webxr_metric.html", diff --git a/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/ftrace_importer.html b/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/ftrace_importer.html index 664b0a6bfa1..048869e22d0 100644 --- a/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/ftrace_importer.html +++ b/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/ftrace_importer.html @@ -30,6 +30,7 @@ found in the LICENSE file. <link rel="import" href="/tracing/extras/importer/linux_perf/rss_parser.html"> <link rel="import" href="/tracing/extras/importer/linux_perf/sched_parser.html"> <link rel="import" href="/tracing/extras/importer/linux_perf/sync_parser.html"> +<link rel="import" href="/tracing/extras/importer/linux_perf/thermal_parser.html"> <link rel="import" href="/tracing/extras/importer/linux_perf/workqueue_parser.html"> <link rel="import" href="/tracing/importer/importer.html"> <link rel="import" href="/tracing/importer/simple_line_reader.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/thermal_parser.html b/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/thermal_parser.html new file mode 100644 index 00000000000..93818c74b82 --- /dev/null +++ b/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/thermal_parser.html @@ -0,0 +1,80 @@ +<!DOCTYPE html> +<!-- +Copyright (c) 2020 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<link rel="import" href="/tracing/extras/importer/linux_perf/parser.html"> +<link rel="import" href="/tracing/model/counter_series.html"> + +<script> +'use strict'; + +/** + * @fileoverview Parses trace_marker events that were inserted in the trace by + * userland. + */ +tr.exportTo('tr.e.importer.linux_perf', function() { + const ColorScheme = tr.b.ColorScheme; + const Parser = tr.e.importer.linux_perf.Parser; + + /** + * Parses linux trace mark events that were inserted in the trace by userland. + * @constructor + */ + function ThermalParser(importer) { + Parser.call(this, importer); + + importer.registerEventHandler('thermal_temperature', + ThermalParser.prototype.traceMarkWriteTemperatureEvent.bind(this)); + importer.registerEventHandler('cdev_update', + ThermalParser.prototype.traceMarkWriteCdevEvent.bind(this)); + this.model_ = importer.model_; + this.ppids_ = {}; + } + + ThermalParser.prototype = { + __proto__: Parser.prototype, + + thermalMark(name, subName, value, ts) { + const ctr = this.model_.kernel + .getOrCreateCounter(null, name + ' ' + subName); + // Initialize the counter's series fields if needed. + if (ctr.numSeries === 0) { + ctr.addSeries(new tr.model.CounterSeries('value', + ColorScheme.getColorIdForGeneralPurposeString( + ctr.name + '.' + 'value'))); + } + ctr.series.forEach(function(series) { + series.addCounterSample(ts, value); + }); + }, + + traceMarkWriteTemperatureEvent(eventName, cpuNumber, pid, ts, + eventBase, threadName) { + const event = /thermal_zone=(\S+) id=(\d+) temp_prev=(\d+) temp=(\d+)/ + .exec(eventBase.details); + const name = event[1]; + const temp = parseInt(event[4]); + this.thermalMark(name, 'Temperature', temp, ts); + return true; + }, + + traceMarkWriteCdevEvent(eventName, cpuNumber, pid, ts, + eventBase, threadName) { + const event = /type=(\S+) target=(\d+)/.exec(eventBase.details); + const name = event[1]; + const rate = parseInt(event[2]); + this.thermalMark(name, 'CoolingDevice', rate, ts); + return true; + } + }; + + Parser.register(ThermalParser); + + return { + ThermalParser, + }; +}); +</script> diff --git a/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/thermal_parser_test.html b/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/thermal_parser_test.html new file mode 100644 index 00000000000..f0f37ad042c --- /dev/null +++ b/chromium/third_party/catapult/tracing/tracing/extras/importer/linux_perf/thermal_parser_test.html @@ -0,0 +1,64 @@ +<!DOCTYPE html> +<!-- +Copyright (c) 2020 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<link rel="import" href="/tracing/core/test_utils.html"> +<link rel="import" href="/tracing/extras/importer/linux_perf/ftrace_importer.html"> + +<script> +'use strict'; + +tr.b.unittest.testSuite(function() { + test('temperature', function() { + const lines = [ + 'kworker/u17:2-13403 (13403) [000] .... 6083.392723: ' + + 'thermal_temperature: thermal_zone=tz1 id=0 temp_prev=40000 ' + + 'temp=39000', + + 'kworker/u17:3-18821 (18821) [000] .... 6086.464415: ' + + 'thermal_temperature: thermal_zone=tz1 id=0 temp_prev=39000 ' + + 'temp=58000', + + 'kworker/u19:3-20316 (20316) [000] .... 6086.551408: ' + + 'thermal_temperature: thermal_zone=tz1 id=0 temp_prev=60000 ' + + 'temp=52000', + ]; + + const m = tr.c.TestUtils.newModelWithEvents([lines.join('\n')], { + shiftWorldToZero: false + }); + assert.isFalse(m.hasImportWarnings); + + const counters = m.getAllCounters(); + assert.strictEqual(counters.length, 1); + + assert.strictEqual(counters[0].series[0].samples.length, 3); + }); + + test('cdev', function() { + const lines = [ + 'kworker/u17:2-13403 (13403) [000] .... 6083.457060: cdev_update: ' + + 'type=cpu0 target=0', + + 'kworker/u17:2-13403 (13403) [000] .... 6083.458060: cdev_update: ' + + 'type=cpu0 target=1', + + 'kworker/u17:2-13403 (13403) [000] .... 6083.459060: cdev_update: ' + + 'type=cpu0 target=0', + ]; + + const m = tr.c.TestUtils.newModelWithEvents([lines.join('\n')], { + shiftWorldToZero: false + }); + assert.isFalse(m.hasImportWarnings); + + const counters = m.getAllCounters(); + assert.strictEqual(counters.length, 1); + + assert.strictEqual(counters[0].series[0].samples.length, 3); + }); +}); +</script> diff --git a/chromium/third_party/catapult/tracing/tracing/extras/importer/trace_event_importer.html b/chromium/third_party/catapult/tracing/tracing/extras/importer/trace_event_importer.html index 00918705bf7..54f4dcbaa15 100644 --- a/chromium/third_party/catapult/tracing/tracing/extras/importer/trace_event_importer.html +++ b/chromium/third_party/catapult/tracing/tracing/extras/importer/trace_event_importer.html @@ -127,6 +127,7 @@ tr.exportTo('tr.e.importer', function() { 'powerTraceAsString', 'systemTraceEvents', 'androidProcessDump', + 'cgroupDump', ]); // The complete list of fields on the trace that should not be treated as diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/all_metrics.html b/chromium/third_party/catapult/tracing/tracing/metrics/all_metrics.html index 80696a7a243..694f443fab7 100644 --- a/chromium/third_party/catapult/tracing/tracing/metrics/all_metrics.html +++ b/chromium/third_party/catapult/tracing/tracing/metrics/all_metrics.html @@ -40,6 +40,7 @@ found in the LICENSE file. <link rel="import" href="/tracing/metrics/v8/gc_metric.html"> <link rel="import" href="/tracing/metrics/v8/runtime_stats_metric.html"> <link rel="import" href="/tracing/metrics/v8/v8_metrics.html"> +<link rel="import" href="/tracing/metrics/v8/wasm_metric.html"> <link rel="import" href="/tracing/metrics/vr/frame_cycle_duration_metric.html"> <link rel="import" href="/tracing/metrics/vr/webvr_metric.html"> <link rel="import" href="/tracing/metrics/vr/webxr_metric.html"> diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/blink/gc_metric.html b/chromium/third_party/catapult/tracing/tracing/metrics/blink/gc_metric.html index a9fbe9cd589..aaa772d8a62 100644 --- a/chromium/third_party/catapult/tracing/tracing/metrics/blink/gc_metric.html +++ b/chromium/third_party/catapult/tracing/tracing/metrics/blink/gc_metric.html @@ -31,6 +31,32 @@ tr.exportTo('tr.metrics.blink', function() { 'blink-gc-atomic-pause-sweep-and-compact' }; + // Maps non-aggregated Blink GC events in timeline to telemetry friendly + // names using the new naming scheme. This map contains events that occur + // only on the main thread. + const BLINK_NON_AGGREGATED_GC_EVENTS_NEW_NAMES_MAP = { + 'BlinkGC.AtomicPauseMarkEpilogue': + 'blink:gc:main_thread:cycle:full:atomic:mark:epilogue', + 'BlinkGC.AtomicPauseMarkPrologue': + 'blink:gc:main_thread:cycle:full:atomic:mark:prologue', + 'BlinkGC.AtomicPauseMarkRoots': + 'blink:gc:main_thread:cycle:full:atomic:mark:roots', + 'BlinkGC.IncrementalMarkingStartMarking': + 'blink:gc:main_thread:cycle:full:incremental:mark:start', + 'BlinkGC.IncrementalMarkingStep': + 'blink:gc:main_thread:cycle:full:incremental:mark:step', + 'BlinkGC.UnifiedMarkingStep': + 'unified:gc:main_thread:cycle:full:mark:step', + 'BlinkGC.CompleteSweep': + 'blink:gc:main_thread:cycle:full:sweep:complete', + 'BlinkGC.LazySweepInIdle': + 'blink:gc:main_thread:cycle:full:sweep:idle', + 'BlinkGC.LazySweepOnAllocation': + 'blink:gc:main_thread:cycle:full:sweep:on_allocation', + 'BlinkGC.AtomicPauseSweepAndCompact': + 'blink:gc:main_thread:cycle:full:atomic:sweep:compact' + }; + // All events that should be summed up to 'blink-gc-mark-roots'. const BLINK_TOP_GC_ROOTS_MARKING_EVENTS = [ 'BlinkGC.VisitRoots' @@ -57,6 +83,17 @@ tr.exportTo('tr.metrics.blink', function() { 'BlinkGC.IncrementalMarkingStartMarking', ].concat(BLINK_GC_FOREGROUND_MARKING_TRANSITIVE_CLOSURE_EVENTS); + // Names of Blink GC foreground marking events in timeline. + const BLINK_GC_FORCED_FOREGROUND_MARKING_EVENTS = [ + 'BlinkGC.AtomicPauseMarkEpilogue', + 'BlinkGC.AtomicPauseMarkPrologue', + 'BlinkGC.AtomicPauseMarkRoots', + 'BlinkGC.IncrementalMarkingStartMarking', + 'BlinkGC.MarkBailOutObjects', + 'BlinkGC.MarkFlushV8References', + 'BlinkGC.MarkFlushEphemeronPairs', + ]; + // Names of Blink GC background marking events in timeline. const BLINK_TOP_GC_BACKGROUND_MARKING_EVENTS = [ 'BlinkGC.ConcurrentMarkingStep' @@ -97,6 +134,14 @@ tr.exportTo('tr.metrics.blink', function() { return Object.values(BLINK_NON_AGGREGATED_GC_EVENTS_NAMES_MAP); } + function blinkGarbageCollectionEventNewName(event) { + return BLINK_NON_AGGREGATED_GC_EVENTS_NEW_NAMES_MAP[event.title]; + } + + function blinkGarbageCollectionEventNewNames() { + return Object.values(BLINK_NON_AGGREGATED_GC_EVENTS_NEW_NAMES_MAP); + } + function isNonForcedEvent(event) { return (!event.args || !event.args.forced) && !tr.metrics.v8.utils.isForcedGarbageCollectionEvent(event); @@ -123,8 +168,7 @@ tr.exportTo('tr.metrics.blink', function() { function isNonForcedBlinkGarbageCollectionMarkingTransitiveColsureEvent(event) { return BLINK_GC_FOREGROUND_MARKING_TRANSITIVE_CLOSURE_EVENTS.includes( - event.title) && - isNonForcedEvent(event); + event.title) && isNonForcedEvent(event); } function @@ -138,6 +182,12 @@ tr.exportTo('tr.metrics.blink', function() { isNonForcedEvent(event); } + function isNonForcedBlinkGarbageCollectionForcedForegroundMarkEvent(event) { + return BLINK_GC_FORCED_FOREGROUND_MARKING_EVENTS.includes( + event.title) && + isNonForcedEvent(event); + } + function isNonForcedBlinkGarbageCollectionBackgroundMarkingEvent(event) { return BLINK_TOP_GC_BACKGROUND_MARKING_EVENTS.includes(event.title) && isNonForcedEvent(event); @@ -168,98 +218,115 @@ tr.exportTo('tr.metrics.blink', function() { addTotalDurationOfRootsMarking(histograms, model); addTotalDurationOfMarkingTransitiveClosure(histograms, model); addTotalDurationOfForegroundMarking(histograms, model); + addTotalDurationOfForcedForegroundMarking(histograms, model); addTotalDurationOfBackgroundMarking(histograms, model); addTotalDurationOfForegroundSweeping(histograms, model); addTotalDurationOfBackgroundSweeping(histograms, model); } - tr.metrics.MetricRegistry.register(blinkGcMetric); + function getEventEpochUniqueId(event) { + // event.parentContainer.parent.stableId return the event's process id. + return event.parentContainer.parent.stableId + ':' + event.args.epoch; + } - const timeDurationInMs_smallerIsBetter = - tr.b.Unit.byName.timeDurationInMs_smallerIsBetter; + tr.metrics.MetricRegistry.register(blinkGcMetric); // 0.1 steps from 0 to 20 since it is the most common range. // Exponentially increasing steps from 20 to 200. const CUSTOM_BOUNDARIES = tr.v.HistogramBinBoundaries.createLinear(0, 20, 200) .addExponentialBins(200, 100); - function createNumericForTopEventTime(name) { + function createNumericForEventTime(name) { const n = new tr.v.Histogram(name, - timeDurationInMs_smallerIsBetter, CUSTOM_BOUNDARIES); + tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, CUSTOM_BOUNDARIES); n.customizeSummaryOptions({ avg: true, count: true, max: true, - min: false, + min: true, std: true, sum: true, percentile: [0.90]}); return n; } - function createNumericForTotalEventTime(name) { - const n = new tr.v.Histogram(name, - timeDurationInMs_smallerIsBetter, CUSTOM_BOUNDARIES); - n.customizeSummaryOptions({ - avg: false, - count: true, - max: false, - min: false, - std: false, - sum: true, - percentile: [0.90]}); - return n; - } - - function createNumericForUnifiedEventTime(name) { - const n = new tr.v.Histogram(name, - timeDurationInMs_smallerIsBetter, CUSTOM_BOUNDARIES); - n.customizeSummaryOptions({ - avg: false, - count: true, - max: true, - min: false, - std: false, - sum: true, - percentile: [0.90]}); - return n; - } - /** * Example output: * - blink-gc-incremental-start */ function addDurationOfTopEvents(histograms, model) { + const nameToNumeric = {}; + const nameToEpochNumeric = {}; + for (const name of blinkGarbageCollectionEventNames()) { + nameToNumeric[name] = createNumericForEventTime(name); + } + for (const name of blinkGarbageCollectionEventNewNames()) { + nameToEpochNumeric[name] = createNumericForEventTime(name); + } tr.metrics.v8.utils.groupAndProcessEvents(model, isNonForcedNonAggregatedBlinkGarbageCollectionEvent, - blinkGarbageCollectionEventName, - function(name, events) { - const cpuDuration = createNumericForTopEventTime(name); + getEventEpochUniqueId, + function(epoch, events) { + const namesToPerEpochDurations = {}; + for (const event of events) { + nameToNumeric[blinkGarbageCollectionEventName(event)] + .addSample(event.cpuDuration); + const name = blinkGarbageCollectionEventNewName(event); + namesToPerEpochDurations[name] = + (namesToPerEpochDurations[name] || 0) + event.cpuDuration; + } + for (const name in namesToPerEpochDurations) { + nameToEpochNumeric[name].addSample(namesToPerEpochDurations[name]); + } + } + ); + for (const name of blinkGarbageCollectionEventNames()) { + histograms.addHistogram(nameToNumeric[name]); + } + for (const name of blinkGarbageCollectionEventNewNames()) { + histograms.addHistogram(nameToEpochNumeric[name]); + } + } + + function addIndividualDurationsOfEvents(histograms, model, name, filter) { + const cpuDuration = createNumericForEventTime(name); + tr.metrics.v8.utils.groupAndProcessEvents(model, + filter, + event => name, + function(group, events) { for (const event of events) { cpuDuration.addSample(event.cpuDuration); } - histograms.addHistogram(cpuDuration); }, - blinkGarbageCollectionEventNames() + [name] ); + histograms.addHistogram(cpuDuration); } - /** - * Example output: - * - blink-gc-atomic-pause - */ - function addDurationOfAtomicPause(histograms, model) { + function addPerEpochDurationsOfEvents(histograms, model, name, filter) { + const cpuDuration = createNumericForEventTime(name); tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionAtomicPauseEvent, - event => event.args.epoch, - function(group, events) { - const cpuDuration = createNumericForTopEventTime( - 'blink-gc-atomic-pause'); + filter, + getEventEpochUniqueId, + function(epoch, events) { cpuDuration.addSample( events.reduce((acc, current) => acc + current.cpuDuration, 0)); - histograms.addHistogram(cpuDuration); } ); + histograms.addHistogram(cpuDuration); + } + + /** + * Example output: + * - blink-gc-atomic-pause + */ + function addDurationOfAtomicPause(histograms, model) { + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-atomic-pause', + isNonForcedBlinkGarbageCollectionAtomicPauseEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:main_thread:cycle:full:atomic', + isNonForcedBlinkGarbageCollectionAtomicPauseEvent); } /** @@ -267,17 +334,12 @@ tr.exportTo('tr.metrics.blink', function() { * - blink-gc-atomic-pause-mark-transitive-closure */ function addDurationOfAtomicPauseTransitiveClosure(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionAtomicPauseTransitiveColsureEvent, - event => event.args.epoch, - function(group, events) { - const cpuDuration = createNumericForTopEventTime( - 'blink-gc-atomic-pause-mark-transitive-closure'); - cpuDuration.addSample( - events.reduce((acc, current) => acc + current.cpuDuration, 0)); - histograms.addHistogram(cpuDuration); - } - ); + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-atomic-pause-mark-transitive-closure', + isNonForcedBlinkGarbageCollectionAtomicPauseTransitiveColsureEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:main_thread:cycle:full:atomic:mark:transitive_closure', + isNonForcedBlinkGarbageCollectionAtomicPauseTransitiveColsureEvent); } /** @@ -285,18 +347,12 @@ tr.exportTo('tr.metrics.blink', function() { * - blink-gc-total */ function addTotalDurationOfTopEvents(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionEvent, - event => 'blink-gc-total', - function(name, events) { - const cpuDuration = createNumericForTotalEventTime(name); - for (const event of events) { - cpuDuration.addSample(event.cpuDuration); - } - histograms.addHistogram(cpuDuration); - }, - ['blink-gc-total'] - ); + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-total', + isNonForcedBlinkGarbageCollectionEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:main_thread:cycle:full', + isNonForcedBlinkGarbageCollectionEvent); } /** @@ -304,18 +360,12 @@ tr.exportTo('tr.metrics.blink', function() { * - blink-gc-mark-roots */ function addTotalDurationOfRootsMarking(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionRootsMarkingEvent, - event => 'blink-gc-mark-roots', - function(name, events) { - const cpuDuration = createNumericForTotalEventTime(name); - for (const event of events) { - cpuDuration.addSample(event.cpuDuration); - } - histograms.addHistogram(cpuDuration); - }, - ['blink-gc-mark-roots'] - ); + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-mark-roots', + isNonForcedBlinkGarbageCollectionRootsMarkingEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:main_thread:cycle:full:mark:roots', + isNonForcedBlinkGarbageCollectionRootsMarkingEvent); } /** @@ -323,18 +373,12 @@ tr.exportTo('tr.metrics.blink', function() { * - blink-gc-mark-transitive-closure */ function addTotalDurationOfMarkingTransitiveClosure(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionMarkingTransitiveColsureEvent, - event => 'blink-gc-mark-transitive-closure', - function(name, events) { - const cpuDuration = createNumericForTotalEventTime(name); - for (const event of events) { - cpuDuration.addSample(event.cpuDuration); - } - histograms.addHistogram(cpuDuration); - }, - ['blink-gc-mark-transitive-closure'] - ); + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-mark-transitive-closure', + isNonForcedBlinkGarbageCollectionMarkingTransitiveColsureEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:main_thread:cycle:full:mark:transitive_closure', + isNonForcedBlinkGarbageCollectionMarkingTransitiveColsureEvent); } /** @@ -342,18 +386,25 @@ tr.exportTo('tr.metrics.blink', function() { * - blink-gc-mark-foreground */ function addTotalDurationOfForegroundMarking(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionForegroundMarkingEvent, - event => 'blink-gc-mark-foreground', - function(name, events) { - const cpuDuration = createNumericForTotalEventTime(name); - for (const event of events) { - cpuDuration.addSample(event.cpuDuration); - } - histograms.addHistogram(cpuDuration); - }, - ['blink-gc-mark-foreground'] - ); + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-mark-foreground', + isNonForcedBlinkGarbageCollectionForegroundMarkingEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:main_thread:cycle:full:mark', + isNonForcedBlinkGarbageCollectionForegroundMarkingEvent); + } + + /** + * Example output: + * - blink-gc-mark-foreground-forced + */ + function addTotalDurationOfForcedForegroundMarking(histograms, model) { + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-mark-foreground-forced', + isNonForcedBlinkGarbageCollectionForcedForegroundMarkEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:main_thread:cycle:full:mark:forced', + isNonForcedBlinkGarbageCollectionForcedForegroundMarkEvent); } /** @@ -361,18 +412,12 @@ tr.exportTo('tr.metrics.blink', function() { * - blink-gc-mark-background */ function addTotalDurationOfBackgroundMarking(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionBackgroundMarkingEvent, - event => 'blink-gc-mark-background', - function(name, events) { - const cpuDuration = createNumericForTotalEventTime(name); - for (const event of events) { - cpuDuration.addSample(event.cpuDuration); - } - histograms.addHistogram(cpuDuration); - }, - ['blink-gc-mark-background'] - ); + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-mark-background', + isNonForcedBlinkGarbageCollectionBackgroundMarkingEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:concurrent_thread:cycle:full:mark', + isNonForcedBlinkGarbageCollectionBackgroundMarkingEvent); } /** @@ -380,18 +425,12 @@ tr.exportTo('tr.metrics.blink', function() { * - blink-gc-sweep-foreground */ function addTotalDurationOfForegroundSweeping(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionForegroundSweepingEvent, - event => 'blink-gc-sweep-foreground', - function(name, events) { - const cpuDuration = createNumericForTotalEventTime(name); - for (const event of events) { - cpuDuration.addSample(event.cpuDuration); - } - histograms.addHistogram(cpuDuration); - }, - ['blink-gc-sweep-foreground'] - ); + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-sweep-foreground', + isNonForcedBlinkGarbageCollectionForegroundSweepingEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:main_thread:cycle:full:sweep', + isNonForcedBlinkGarbageCollectionForegroundSweepingEvent); } /** @@ -399,18 +438,12 @@ tr.exportTo('tr.metrics.blink', function() { * - blink-gc-sweep-background */ function addTotalDurationOfBackgroundSweeping(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isNonForcedBlinkGarbageCollectionBackgroundSweepingEvent, - event => 'blink-gc-sweep-background', - function(name, events) { - const cpuDuration = createNumericForTotalEventTime(name); - for (const event of events) { - cpuDuration.addSample(event.cpuDuration); - } - histograms.addHistogram(cpuDuration); - }, - ['blink-gc-sweep-background'] - ); + addIndividualDurationsOfEvents(histograms, model, + 'blink-gc-sweep-background', + isNonForcedBlinkGarbageCollectionBackgroundSweepingEvent); + addPerEpochDurationsOfEvents(histograms, model, + 'blink:gc:concurrent_thread:cycle:full:sweep', + isNonForcedBlinkGarbageCollectionBackgroundSweepingEvent); } function isV8OrBlinkTopLevelGarbageCollectionEvent(event) { @@ -420,23 +453,13 @@ tr.exportTo('tr.metrics.blink', function() { /** * Example output: - * - unified-gc-total_sum - * - unified-gc-total_max - * - unified-gc-total_count + * - unified-gc-total */ function addTotalDurationOfBlinkAndV8TopEvents(histograms, model) { - tr.metrics.v8.utils.groupAndProcessEvents(model, - isV8OrBlinkTopLevelGarbageCollectionEvent, - event => 'unified-gc-total', - function(name, events) { - const cpuDuration = createNumericForUnifiedEventTime(name); - for (const event of events) { - cpuDuration.addSample(event.cpuDuration); - } - histograms.addHistogram(cpuDuration); - }, - ['unified-gc-total'] - ); + addIndividualDurationsOfEvents(histograms, model, + 'unified-gc-total', + isV8OrBlinkTopLevelGarbageCollectionEvent); + // No epoch durations because v8 events don't provide an epoch id. } return { diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/blink/gc_metric_test.html b/chromium/third_party/catapult/tracing/tracing/metrics/blink/gc_metric_test.html index 4e0b9da923f..0c20030edc1 100644 --- a/chromium/third_party/catapult/tracing/tracing/metrics/blink/gc_metric_test.html +++ b/chromium/third_party/catapult/tracing/tracing/metrics/blink/gc_metric_test.html @@ -78,59 +78,112 @@ tr.b.unittest.testSuite(function() { } }); + test('topEventsPerEpoch', function() { + const events = { + 'BlinkGC.AtomicPauseMarkEpilogue': + 'blink:gc:main_thread:cycle:full:atomic:mark:epilogue', + 'BlinkGC.AtomicPauseMarkPrologue': + 'blink:gc:main_thread:cycle:full:atomic:mark:prologue', + 'BlinkGC.AtomicPauseMarkRoots': + 'blink:gc:main_thread:cycle:full:atomic:mark:roots', + 'BlinkGC.IncrementalMarkingStartMarking': + 'blink:gc:main_thread:cycle:full:incremental:mark:start', + 'BlinkGC.IncrementalMarkingStep': + 'blink:gc:main_thread:cycle:full:incremental:mark:step', + 'BlinkGC.UnifiedMarkingStep': + 'unified:gc:main_thread:cycle:full:mark:step', + 'BlinkGC.CompleteSweep': + 'blink:gc:main_thread:cycle:full:sweep:complete', + 'BlinkGC.LazySweepInIdle': + 'blink:gc:main_thread:cycle:full:sweep:idle', + 'BlinkGC.LazySweepOnAllocation': + 'blink:gc:main_thread:cycle:full:sweep:on_allocation', + 'BlinkGC.AtomicPauseSweepAndCompact': + 'blink:gc:main_thread:cycle:full:atomic:sweep:compact', + 'BlinkGC.AtomicPauseMarkTransitiveClosure': + 'blink:gc:main_thread:cycle:full:atomic:mark:transitive_closure', + 'BlinkGC.VisitRoots': + 'blink:gc:main_thread:cycle:full:mark:roots' + }; + for (const [timelineName, telemetryName] of Object.entries(events)) { + const slices = [ + { + title: timelineName, args: {'epoch': 0}, start: 100, end: 150, + cpuStart: 100, cpuEnd: 150 + }, + { + title: timelineName, args: {'epoch': 0}, start: 150, end: 200, + cpuStart: 150, cpuEnd: 200 + }, + { + title: timelineName, args: {'epoch': 1}, start: 200, end: 300, + cpuStart: 200, cpuEnd: 300 + } + ]; + const actual = run(slices); + + const value = actual.getHistogramNamed(telemetryName); + assert.strictEqual(value.running.sum, 200); + assert.strictEqual(value.numValues, 2); + assert.strictEqual(value.average, 100); + assert.strictEqual(value.running.max, 100); + assert.closeTo(value.getApproximatePercentile(0.90), 100, 1); + } + }); + test('totalTimeForBlinkGC', function() { const histograms = new tr.v.HistogramSet(); const slices = [ { - title: 'BlinkGC.AtomicPauseMarkPrologue', args: {}, + title: 'BlinkGC.AtomicPauseMarkPrologue', args: {'epoch': 0}, start: 100, end: 110, cpuStart: 100, cpuEnd: 110 }, { - title: 'BlinkGC.AtomicPauseMarkRoots', args: {}, + title: 'BlinkGC.AtomicPauseMarkRoots', args: {'epoch': 0}, start: 110, end: 120, cpuStart: 110, cpuEnd: 120 }, { - title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {}, + title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {'epoch': 0}, start: 120, end: 130, cpuStart: 120, cpuEnd: 130 }, { - title: 'BlinkGC.AtomicPauseMarkEpilogue', args: {}, + title: 'BlinkGC.AtomicPauseMarkEpilogue', args: {'epoch': 0}, start: 130, end: 140, cpuStart: 130, cpuEnd: 140 }, { - title: 'BlinkGC.AtomicPauseSweepAndCompact', args: {}, + title: 'BlinkGC.AtomicPauseSweepAndCompact', args: {'epoch': 0}, start: 140, end: 200, cpuStart: 140, cpuEnd: 200 }, { - title: 'BlinkGC.LazySweepInIdle', args: {}, start: 210, + title: 'BlinkGC.LazySweepInIdle', args: {'epoch': 0}, start: 210, end: 290, cpuStart: 210, cpuEnd: 290 }, { - title: 'BlinkGC.IncrementalMarkingStartMarking', args: {}, start: 500, - end: 550, cpuStart: 500, cpuEnd: 550 + title: 'BlinkGC.IncrementalMarkingStartMarking', args: {'epoch': 1}, + start: 500, end: 550, cpuStart: 500, cpuEnd: 550 }, { - title: 'BlinkGC.IncrementalMarkingStep', args: {}, start: 550, + title: 'BlinkGC.IncrementalMarkingStep', args: {'epoch': 1}, start: 550, end: 600, cpuStart: 550, cpuEnd: 600 }, { - title: 'BlinkGC.UnifiedMarkingStep', args: {}, start: 600, + title: 'BlinkGC.UnifiedMarkingStep', args: {'epoch': 1}, start: 600, end: 650, cpuStart: 600, cpuEnd: 650 }, // Background events shouldn't contribute to total time. { - title: 'BlinkGC.ConcurrentSweepingStep', args: {}, start: 300, + title: 'BlinkGC.ConcurrentSweepingStep', args: {'epoch': 1}, start: 300, end: 390, cpuStart: 300, cpuEnd: 390 }, { - title: 'BlinkGC.ConcurrentMarkingStep', args: {}, start: 400, + title: 'BlinkGC.ConcurrentMarkingStep', args: {'epoch': 1}, start: 400, end: 450, cpuStart: 400, cpuEnd: 450 }, // Explicit roots marking should also not contribute to total time // (this is already encompassed by BlinkGC.AtomicPauseMarkRoots and // BlinkGC.IncrementalMarkingStartMarking). { - title: 'BlinkGC.VisitRoots', args: {}, start: 450, + title: 'BlinkGC.VisitRoots', args: {'epoch': 1}, start: 450, end: 500, cpuStart: 450, cpuEnd: 500 } ]; @@ -140,41 +193,47 @@ tr.b.unittest.testSuite(function() { assert.strictEqual(value.running.sum, 330); assert.strictEqual(value.numValues, 9); assert.strictEqual(value.running.max, 80); + + const valuePerEpoch = actual.getHistogramNamed( + 'blink:gc:main_thread:cycle:full'); + assert.strictEqual(valuePerEpoch.running.sum, 330); + assert.strictEqual(valuePerEpoch.numValues, 2); + assert.strictEqual(valuePerEpoch.running.max, 180); }); test('totalForegroundSweepingTimeForBlinkGC', function() { const histograms = new tr.v.HistogramSet(); const slices = [ { - title: 'BlinkGC.AtomicPauseMarkPrologue', args: {}, + title: 'BlinkGC.AtomicPauseMarkPrologue', args: {'epoch': 0}, start: 100, end: 110, cpuStart: 100, cpuEnd: 110 }, { - title: 'BlinkGC.AtomicPauseMarkRoots', args: {}, + title: 'BlinkGC.AtomicPauseMarkRoots', args: {'epoch': 0}, start: 110, end: 120, cpuStart: 110, cpuEnd: 120 }, { - title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {}, + title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {'epoch': 0}, start: 120, end: 130, cpuStart: 120, cpuEnd: 130 }, { - title: 'BlinkGC.AtomicPauseMarkEpilogue', args: {}, + title: 'BlinkGC.AtomicPauseMarkEpilogue', args: {'epoch': 0}, start: 130, end: 140, cpuStart: 130, cpuEnd: 140 }, { - title: 'BlinkGC.AtomicPauseSweepAndCompact', args: {}, + title: 'BlinkGC.AtomicPauseSweepAndCompact', args: {'epoch': 0}, start: 140, end: 200, cpuStart: 140, cpuEnd: 200 }, { - title: 'BlinkGC.LazySweepInIdle', args: {}, + title: 'BlinkGC.LazySweepInIdle', args: {'epoch': 0}, start: 210, end: 300, cpuStart: 210, cpuEnd: 300 }, { - title: 'BlinkGC.LazySweepOnAllocation', args: {}, + title: 'BlinkGC.LazySweepOnAllocation', args: {'epoch': 0}, start: 310, end: 400, cpuStart: 310, cpuEnd: 400 }, { - title: 'BlinkGC.CompleteSweep', args: {}, + title: 'BlinkGC.CompleteSweep', args: {'epoch': 1}, start: 410, end: 500, cpuStart: 410, cpuEnd: 500 } ]; @@ -185,25 +244,32 @@ tr.b.unittest.testSuite(function() { assert.strictEqual(value.numValues, 3); assert.strictEqual(value.average, 90); assert.strictEqual(value.running.max, 90); + + const valuePerEpoch = actual.getHistogramNamed( + 'blink:gc:main_thread:cycle:full:sweep'); + assert.strictEqual(valuePerEpoch.running.sum, 270); + assert.strictEqual(valuePerEpoch.numValues, 2); + assert.strictEqual(valuePerEpoch.average, 135); + assert.strictEqual(valuePerEpoch.running.max, 180); }); test('totalBackgroundSweepingTimeForBlinkGC', function() { const histograms = new tr.v.HistogramSet(); const slices = [ { - title: 'BlinkGC.ConcurrentSweepingStep', args: {}, + title: 'BlinkGC.ConcurrentSweepingStep', args: {'epoch': 0}, start: 100, end: 200, cpuStart: 100, cpuEnd: 200 }, { - title: 'BlinkGC.LazySweepInIdle', args: {}, + title: 'BlinkGC.LazySweepInIdle', args: {'epoch': 0}, start: 210, end: 300, cpuStart: 210, cpuEnd: 300 }, { - title: 'BlinkGC.ConcurrentSweepingStep', args: {}, + title: 'BlinkGC.ConcurrentSweepingStep', args: {'epoch': 1}, start: 250, end: 300, cpuStart: 250, cpuEnd: 300 }, { - title: 'BlinkGC.CompleteSweep', args: {}, + title: 'BlinkGC.CompleteSweep', args: {'epoch': 1}, start: 300, end: 400, cpuStart: 310, cpuEnd: 400 } ]; @@ -214,49 +280,56 @@ tr.b.unittest.testSuite(function() { assert.strictEqual(value.numValues, 2); assert.strictEqual(value.average, 75); assert.strictEqual(value.running.max, 100); + + const valuePerEpoch = actual.getHistogramNamed( + 'blink:gc:concurrent_thread:cycle:full:sweep'); + assert.strictEqual(valuePerEpoch.running.sum, 150); + assert.strictEqual(valuePerEpoch.numValues, 2); + assert.strictEqual(valuePerEpoch.average, 75); + assert.strictEqual(valuePerEpoch.running.max, 100); }); test('totalMarkingTimeForBlinkGC', function() { const histograms = new tr.v.HistogramSet(); const slices = [ { - title: 'BlinkGC.IncrementalMarkingStartMarking', args: {}, start: 0, - end: 10, cpuStart: 0, cpuEnd: 10 + title: 'BlinkGC.IncrementalMarkingStartMarking', args: {'epoch': 0}, + start: 0, end: 10, cpuStart: 0, cpuEnd: 10 }, { - title: 'BlinkGC.VisitRoots', args: {}, start: 10, + title: 'BlinkGC.VisitRoots', args: {'epoch': 0}, start: 10, end: 20, cpuStart: 10, cpuEnd: 20 }, { - title: 'BlinkGC.ConcurrentMarkingStep', args: {}, + title: 'BlinkGC.ConcurrentMarkingStep', args: {'epoch': 0}, start: 20, end: 30, cpuStart: 20, cpuEnd: 30 }, { - title: 'BlinkGC.IncrementalMarkingStep', args: {}, + title: 'BlinkGC.IncrementalMarkingStep', args: {'epoch': 0}, start: 30, end: 40, cpuStart: 30, cpuEnd: 40 }, { - title: 'BlinkGC.ConcurrentMarkingStep', args: {}, + title: 'BlinkGC.ConcurrentMarkingStep', args: {'epoch': 1}, start: 40, end: 44, cpuStart: 40, cpuEnd: 44 }, { - title: 'BlinkGC.UnifiedMarkingStep', args: {}, + title: 'BlinkGC.UnifiedMarkingStep', args: {'epoch': 0}, start: 50, end: 60, cpuStart: 50, cpuEnd: 60 }, { - title: 'BlinkGC.AtomicPauseMarkPrologue', args: {}, + title: 'BlinkGC.AtomicPauseMarkPrologue', args: {'epoch': 1}, start: 60, end: 66, cpuStart: 60, cpuEnd: 66 }, { - title: 'BlinkGC.AtomicPauseMarkRoots', args: {}, + title: 'BlinkGC.AtomicPauseMarkRoots', args: {'epoch': 0}, start: 70, end: 80, cpuStart: 70, cpuEnd: 80 }, { - title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {}, + title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {'epoch': 1}, start: 80, end: 87, cpuStart: 80, cpuEnd: 87 }, { - title: 'BlinkGC.AtomicPauseMarkEpilogue', args: {}, + title: 'BlinkGC.AtomicPauseMarkEpilogue', args: {'epoch': 2}, start: 90, end: 100, cpuStart: 90, cpuEnd: 100 } ]; @@ -288,6 +361,34 @@ tr.b.unittest.testSuite(function() { assert.strictEqual(closueValue.numValues, 3); assert.closeTo(closueValue.average, 9, 1e-6); assert.strictEqual(closueValue.running.max, 10); + + const foregroundValuePerEpoch = actual.getHistogramNamed( + 'blink:gc:main_thread:cycle:full:mark'); + assert.strictEqual(foregroundValuePerEpoch.running.sum, 63); + assert.strictEqual(foregroundValuePerEpoch.numValues, 3); + assert.closeTo(foregroundValuePerEpoch.average, 21, 1e-6); + assert.strictEqual(foregroundValuePerEpoch.running.max, 40); + + const backgroundValuePerEpoch = actual.getHistogramNamed( + 'blink:gc:concurrent_thread:cycle:full:mark'); + assert.strictEqual(backgroundValuePerEpoch.running.sum, 14); + assert.strictEqual(backgroundValuePerEpoch.numValues, 2); + assert.closeTo(backgroundValuePerEpoch.average, 7, 1e-6); + assert.strictEqual(backgroundValuePerEpoch.running.max, 10); + + const rootsValuePerEpoch = actual.getHistogramNamed( + 'blink:gc:main_thread:cycle:full:mark:roots'); + assert.strictEqual(rootsValuePerEpoch.running.sum, 10); + assert.strictEqual(rootsValuePerEpoch.numValues, 1); + assert.closeTo(rootsValuePerEpoch.average, 10, 1e-6); + assert.strictEqual(rootsValuePerEpoch.running.max, 10); + + const closueValuePerEpoch = actual.getHistogramNamed( + 'blink:gc:main_thread:cycle:full:mark:transitive_closure'); + assert.strictEqual(closueValuePerEpoch.running.sum, 27); + assert.strictEqual(closueValuePerEpoch.numValues, 2); + assert.closeTo(closueValuePerEpoch.average, 13.5, 1e-6); + assert.strictEqual(closueValuePerEpoch.running.max, 20); }); test('totalTimeForUnifiedGC', function() { @@ -512,15 +613,15 @@ tr.b.unittest.testSuite(function() { const histograms = new tr.v.HistogramSet(); const slices = [ { - title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {}, + title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {'epoch': 0}, start: 10, end: 20, cpuStart: 10, cpuEnd: 20 }, { - title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {}, + title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {'epoch': 0}, start: 40, end: 60, cpuStart: 40, cpuEnd: 60 }, { - title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {}, + title: 'BlinkGC.AtomicPauseMarkTransitiveClosure', args: {'epoch': 1}, start: 70, end: 75, cpuStart: 70, cpuEnd: 75 }, ]; @@ -529,7 +630,12 @@ tr.b.unittest.testSuite(function() { const value = actual.getHistogramNamed( 'blink-gc-atomic-pause-mark-transitive-closure'); assert.strictEqual(value.running.sum, 35); - assert.strictEqual(value.numValues, 1); + assert.strictEqual(value.numValues, 3); + + const valuePerEpoch = actual.getHistogramNamed( + 'blink:gc:main_thread:cycle:full:atomic:mark:transitive_closure'); + assert.strictEqual(valuePerEpoch.running.sum, 35); + assert.strictEqual(valuePerEpoch.numValues, 2); }); }); </script> diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/console_error_metric.html b/chromium/third_party/catapult/tracing/tracing/metrics/console_error_metric.html index 5ed27d0f6be..13e1fef405f 100644 --- a/chromium/third_party/catapult/tracing/tracing/metrics/console_error_metric.html +++ b/chromium/third_party/catapult/tracing/tracing/metrics/console_error_metric.html @@ -7,6 +7,7 @@ found in the LICENSE file. <link rel="import" href="/tracing/base/unit.html"> <link rel="import" href="/tracing/metrics/metric_registry.html"> +<link rel="import" href="/tracing/value/diagnostics/generic_set.html"> <link rel="import" href="/tracing/value/histogram.html"> <script> @@ -33,32 +34,43 @@ tr.exportTo('tr.metrics.console', function() { function consoleErrorMetric(histograms, model) { const counts = {}; for (const source of SOURCES) { - counts[source] = 0; + counts[source] = {count: 0, details: []}; } for (const slice of model.getDescendantEvents()) { if (slice.category === 'blink.console' && slice.title === 'ConsoleMessage::Error') { const source = slice.args.source.toLowerCase(); - counts.all++; + counts.all.count++; + if (slice.args.message) { + counts.all.details.push( + {pid: slice.getProcess().pid, ...slice.args.message}); + } if (source in counts) { - counts[source]++; + counts[source].count++; + if (slice.args.message) { + counts[source].details.push( + {pid: slice.getProcess().pid, ...slice.args.message}); + } } } if (slice.category === 'v8.console' && ( slice.title === 'V8ConsoleMessage::Exception' || slice.title === 'V8ConsoleMessage::Error' || slice.title === 'V8ConsoleMessage::Assert')) { - counts.all++; - counts.js++; + counts.all.count++; + counts.js.count++; } } for (const source of SOURCES) { - histograms.createHistogram( + const hist = histograms.createHistogram( `console:error:${source}`, - tr.b.Unit.byName.count_smallerIsBetter, - counts[source], { + tr.b.Unit.byName.count_smallerIsBetter, { + value: counts[source].count, diagnostics: { + details: new tr.v.d.GenericSet(counts[source].details) + } + }, { description: `Number of ${source} console error messages`, - summaryOptions: SUMMARY_OPTIONS + summaryOptions: SUMMARY_OPTIONS, }); } } diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/rendering/cpu_utilization.html b/chromium/third_party/catapult/tracing/tracing/metrics/rendering/cpu_utilization.html index fae33a37994..16e185c172e 100644 --- a/chromium/third_party/catapult/tracing/tracing/metrics/rendering/cpu_utilization.html +++ b/chromium/third_party/catapult/tracing/tracing/metrics/rendering/cpu_utilization.html @@ -7,7 +7,6 @@ found in the LICENSE file. <link rel="import" href="/tracing/base/math/statistics.html"> <link rel="import" href="/tracing/base/unit.html"> -<link rel="import" href="/tracing/value/diagnostics/breakdown.html"> <link rel="import" href="/tracing/value/histogram.html"> <script> @@ -67,8 +66,10 @@ tr.exportTo('tr.metrics.rendering', function() { map.set(key, oldValue + value); } - function categoryShouldHaveBreakdown(category) { - return category === 'total_all' || category === 'total_rendering'; + function addToArrayInMap_(map, key, value) { + const arr = map.get(key) || []; + arr.push(value); + map.set(key, arr); } function* getCategories_(threadName) { @@ -85,46 +86,10 @@ tr.exportTo('tr.metrics.rendering', function() { if (isOther) yield 'other'; } - function isSubset_(regexps1, regexps2) { - for (const r1 of regexps1) { - if (regexps2.find(r2 => r2.toString() === r1.toString()) === undefined) { - return false; - } - } - return true; - } - function addCpuUtilizationHistograms( histograms, model, segments, segmentCostFunc, histogramNameFunc, - description, unit) { - if (!unit) unit = tr.b.Unit.byName.unitlessNumber; - const histogramMap = new Map(); - for (const category of ALL_CATEGORIES) { - const histogram = histograms.createHistogram( - histogramNameFunc(category), unit, [], { - binBoundaries: - tr.v.HistogramBinBoundaries.createExponential(1, 50, 20), - description, - summaryOptions: tr.metrics.rendering.SUMMARY_OPTIONS, - }); - histogramMap.set(category, histogram); - } - - // Add histogram breakdowns. - for (const [category, regexps] of CATEGORY_THREAD_MAP) { - const relatedCategories = new tr.v.d.RelatedNameMap(); - const histogram = histogramMap.get(category); - for (const [otherCategory, otherRegexps] of CATEGORY_THREAD_MAP) { - if (otherCategory === category) continue; - if (category !== 'all' && !isSubset_(otherRegexps, regexps)) continue; - const otherHistogram = histogramMap.get(otherCategory); - relatedCategories.set(otherCategory, otherHistogram.name); - } - if ([...relatedCategories.values()].length > 0) { - histogram.diagnostics.set('breakdown', relatedCategories); - } - } - + description) { + const categoryValues = new Map(); for (const segment of segments) { const threadValues = new Map(); // Compute and store CPU times per categories and thread name. @@ -134,36 +99,24 @@ tr.exportTo('tr.metrics.rendering', function() { thread.name || UNKNOWN_THREAD_NAME, segmentCostFunc(thread, segment)); } - const categoryValues = new Map(); - const breakdowns = new Map(); + for (const [threadName, coresPerSec] of threadValues) { for (const category of getCategories_(threadName)) { - addValueToMap_(categoryValues, category, coresPerSec); - if (!categoryShouldHaveBreakdown(category)) continue; - if (!breakdowns.has(category)) { - breakdowns.set(category, new tr.v.d.Breakdown()); - } - // TODO(chiniforooshan): We break down the CPU usage of each category - // by the thread name here. It will be more useful if we could add - // task names too. On the other hand, breaking down at task level may - // be too granular and we may end up with a ton of tiny slices that - // will not be that useful. Maybe we can break down by just top x - // tasks, or top x (thread, task) pairs? - // - // Another possbility to investigate is to break down by initiator - // type of the animation expectation. - breakdowns.get(category).set(threadName, coresPerSec); + addToArrayInMap_(categoryValues, category, coresPerSec); } } + } - for (const category of ALL_CATEGORIES) { - const value = categoryValues.get(category) || 0; - const diagnostics = new tr.v.d.DiagnosticMap(); - const breakdown = breakdowns.get(category); - if (breakdown) diagnostics.set('breakdown', breakdown); - const histogram = histogramMap.get(category); - histogram.addSample(value, diagnostics); - } + const unit = tr.b.Unit.byName.unitlessNumber_smallerIsBetter; + for (const category of ALL_CATEGORIES) { + const values = categoryValues.get(category) || 0; + if (!values) continue; + const avg = values.reduce((sum, e) => sum + e, 0) / segments.length; + histograms.createHistogram( + histogramNameFunc(category), unit, avg, { + description, + summaryOptions: {}, + }); } } diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/rendering/cpu_utilization_test.html b/chromium/third_party/catapult/tracing/tracing/metrics/rendering/cpu_utilization_test.html index 2ab92a1165b..9c3e0d21def 100644 --- a/chromium/third_party/catapult/tracing/tracing/metrics/rendering/cpu_utilization_test.html +++ b/chromium/third_party/catapult/tracing/tracing/metrics/rendering/cpu_utilization_test.html @@ -49,27 +49,23 @@ tr.b.unittest.testSuite(function() { assert.closeTo(2, hist.min, 1e-6); assert.closeTo(2, hist.max, 1e-6); assert.closeTo(2, hist.average, 1e-6); - assert.strictEqual(hist.diagnostics.size, 0); hist = histograms.getHistogramNamed( 'thread_renderer_main_cpu_time_per_frame'); assert.closeTo(4, hist.min, 1e-6); assert.closeTo(4, hist.max, 1e-6); assert.closeTo(4, hist.average, 1e-6); - assert.strictEqual(hist.diagnostics.size, 0); hist = histograms.getHistogramNamed('thread_IO_cpu_time_per_frame'); assert.closeTo(1, hist.min, 1e-6); assert.closeTo(1, hist.max, 1e-6); assert.closeTo(1, hist.average, 1e-6); - assert.strictEqual(hist.diagnostics.size, 0); hist = histograms.getHistogramNamed( 'thread_total_rendering_cpu_time_per_frame'); assert.closeTo(7, hist.min, 1e-6); assert.closeTo(7, hist.max, 1e-6); assert.closeTo(7, hist.average, 1e-6); - assert.strictEqual(hist.diagnostics.size, 1); // Verify sum of all threads. hist = histograms.getHistogramNamed('thread_total_all_cpu_time_per_frame'); @@ -109,8 +105,8 @@ tr.b.unittest.testSuite(function() { // in the second segment, using 1 + 4 + 1 = 6ms of CPU. const hist = histograms.getHistogramNamed( 'thread_total_all_cpu_time_per_frame'); - assert.closeTo(2, hist.min, 1e-6); - assert.closeTo(6, hist.max, 1e-6); + assert.closeTo(4, hist.min, 1e-6); + assert.closeTo(4, hist.max, 1e-6); assert.closeTo(4, hist.average, 1e-6); }); diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/rendering/frame_time.html b/chromium/third_party/catapult/tracing/tracing/metrics/rendering/frame_time.html index 4141fba45a8..1942934bb6e 100644 --- a/chromium/third_party/catapult/tracing/tracing/metrics/rendering/frame_time.html +++ b/chromium/third_party/catapult/tracing/tracing/metrics/rendering/frame_time.html @@ -288,15 +288,13 @@ tr.exportTo('tr.metrics.rendering', function() { histograms, model, frameSegments, (thread, segment) => thread.getCpuTimeForRange(segment.boundsRange), category => `thread_${category}_cpu_time_per_frame`, - 'CPU cores of a thread group per frame', - tr.b.Unit.byName.timeDurationInMs_smallerIsBetter); + 'CPU cores of a thread group per frame'); tr.metrics.rendering.addCpuUtilizationHistograms( histograms, model, frameSegments, (thread, segment) => thread.getNumToplevelSlicesForRange(segment.boundsRange), category => `tasks_per_frame_${category}`, - 'Number of tasks of a thread group per frame', - tr.b.Unit.byName.unitlessNumber_smallerIsBetter); + 'Number of tasks of a thread group per frame'); let totalWallTime = 0; let totalCpuTime = 0; diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/v8/utils.html b/chromium/third_party/catapult/tracing/tracing/metrics/v8/utils.html index cf2a608ae32..cb5e9fe2f3a 100644 --- a/chromium/third_party/catapult/tracing/tracing/metrics/v8/utils.html +++ b/chromium/third_party/catapult/tracing/tracing/metrics/v8/utils.html @@ -238,6 +238,7 @@ tr.exportTo('tr.metrics.v8.utils', function() { if (rendererHelper.isChromeTracingUI) continue; threads.push(rendererHelper.mainThread); threads = threads.concat(rendererHelper.dedicatedWorkerThreads); + threads = threads.concat(rendererHelper.serviceWorkerThreads); threads = threads.concat(rendererHelper.foregroundWorkerThreads); } return threads; @@ -300,6 +301,29 @@ tr.exportTo('tr.metrics.v8.utils', function() { } /** + * Returns a map of events that pass the |filterCallback| filter. The keys + * for the map are produced by |keyCallback|. + * @param {Function} filterCallback Takes an event and returns a boolean. + * @param {Function} keyCallback Takes an event and returns a string. + */ + function filterAndOrderEvents(model, filterCallback, keyCallback) { + const threads = jsExecutionThreads(model); + const events = {}; + for (const thread of threads) { + for (const event of thread.sliceGroup.childEvents()) { + if (!filterCallback(event)) continue; + const key = keyCallback(event); + if (events[key]) { + events[key].push(event); + } else { + events[key] = [event]; + } + } + } + return events; + } + + /** * Given a list of intervals, returns a new list with all overalapping * intervals merged into a single interval. */ @@ -517,6 +541,7 @@ tr.exportTo('tr.metrics.v8.utils', function() { findParent, forcedGCEventName, filterEvents, + filterAndOrderEvents, groupAndProcessEvents, isForcedGarbageCollectionEvent, isFullMarkCompactorEvent, diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/v8/wasm_metric.html b/chromium/third_party/catapult/tracing/tracing/metrics/v8/wasm_metric.html new file mode 100644 index 00000000000..b9e500c50fd --- /dev/null +++ b/chromium/third_party/catapult/tracing/tracing/metrics/v8/wasm_metric.html @@ -0,0 +1,104 @@ +<!DOCTYPE html> +<!-- +Copyright 2020 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<link rel="import" href="/tracing/base/math/range.html"> +<link rel="import" href="/tracing/base/unit.html"> +<link rel="import" href="/tracing/metrics/metric_registry.html"> +<link rel="import" href="/tracing/metrics/v8/utils.html"> +<link rel="import" href="/tracing/value/histogram.html"> + +<script> +'use strict'; + +tr.exportTo('tr.metrics.v8', function() { + function computeSyncInstantiationTimeMetric(histograms, wasmEvents) { + if (!wasmEvents.hasOwnProperty('wasm.SyncInstantiate')) return; + + const wasmSyncInstantiationTimeCPU = new tr.v.Histogram( + 'v8:wasm:sync_instantiate:cpu_time', + tr.b.Unit.byName.timeDurationInMs_smallerIsBetter); + wasmSyncInstantiationTimeCPU.description = + 'cpu time spent instantiating a WebAssembly module'; + const wasmSyncInstantiationTimeWall = new tr.v.Histogram( + 'v8:wasm:sync_instantiate:wall_time', + tr.b.Unit.byName.timeDurationInMs_smallerIsBetter); + wasmSyncInstantiationTimeWall.description = + 'wall time spent instantiating a WebAssembly module'; + + for (const e of wasmEvents['wasm.SyncInstantiate']) { + wasmSyncInstantiationTimeCPU.addSample(e.cpuDuration); + wasmSyncInstantiationTimeWall.addSample(e.duration); + } + + histograms.addHistogram(wasmSyncInstantiationTimeCPU); + histograms.addHistogram(wasmSyncInstantiationTimeWall); + } + + function computeStreamingBaselineCompileTimeMetric(histograms, wasmEvents) { + // With streaming compilation, baseline compilation happens from when the + // first bytes get received until when baseline compilation finishes. If + // compilation speed is faster than download speed, then this metric also + // includes the time compilation is waiting for additional bytes. + if (!wasmEvents.hasOwnProperty('wasm.StartStreamingCompilation') || + !wasmEvents.hasOwnProperty('wasm.BaselineFinished')) { + return; + } + const histogram = new tr.v.Histogram( + 'v8:wasm:streaming_baseline_compilation:wall_time', + tr.b.Unit.byName.timeDurationInMs_smallerIsBetter); + + const compilationStart = + wasmEvents['wasm.StartStreamingCompilation'][0].start; + + const compilationEnd = wasmEvents['wasm.BaselineFinished'][0].end; + + histogram.addSample(compilationEnd - compilationStart); + histograms.addHistogram(histogram); + } + + function computeCompilationTierupWallTimeMetric(histograms, wasmEvents) { + if (!wasmEvents.hasOwnProperty('wasm.BaselineFinished') || + !wasmEvents.hasOwnProperty('wasm.TopTierFinished')) { + return; + } + + const histogram = new tr.v.Histogram( + 'v8:wasm:compilation_tierup:wall_time', + tr.b.Unit.byName.timeDurationInMs_smallerIsBetter); + + const tierupStart = wasmEvents['wasm.BaselineFinished'][0].start; + const tierupEnd = wasmEvents['wasm.TopTierFinished'][0].end; + + histogram.addSample(tierupEnd - tierupStart); + + histograms.addHistogram(histogram); + } + + function collectWasmEvents(model) { + const wasmEvents = tr.metrics.v8.utils.filterAndOrderEvents(model, + event => event.title.startsWith('wasm.'), + event => event.title); + + return wasmEvents; + } + + function wasmMetric(histograms, model) { + const wasmEvents = collectWasmEvents(model); + + computeSyncInstantiationTimeMetric(histograms, wasmEvents); + computeStreamingBaselineCompileTimeMetric(histograms, wasmEvents); + computeCompilationTierupWallTimeMetric(histograms, wasmEvents); + } + + tr.metrics.MetricRegistry.register(wasmMetric); + + return { + wasmMetric, + }; +}); + +</script> diff --git a/chromium/third_party/catapult/tracing/tracing/metrics/v8/wasm_metric_test.html b/chromium/third_party/catapult/tracing/tracing/metrics/v8/wasm_metric_test.html new file mode 100644 index 00000000000..0681b6ddf3b --- /dev/null +++ b/chromium/third_party/catapult/tracing/tracing/metrics/v8/wasm_metric_test.html @@ -0,0 +1,169 @@ +<!DOCTYPE html> +<!-- +Copyright 2020 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<link rel="import" href="/tracing/core/test_utils.html"> +<link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> +<link rel="import" href="/tracing/metrics/v8/wasm_metric.html"> +<link rel="import" href="/tracing/value/histogram_set.html"> + +<script> +'use strict'; + +tr.b.unittest.testSuite(function() { + function createModel(start, end, slices) { + return tr.e.chrome.ChromeTestUtils.newChromeModel(function(model) { + const rendererProcess = model.rendererProcess; + const mainThread = model.rendererMain; + const group = mainThread.sliceGroup; + for (const slice of slices) { + group.pushSlice(tr.c.TestUtils.newSliceEx(slice)); + } + group.createSubSlices(); + mainThread.updateBounds(); + }); + } + + function runMetrics(slices) { + // There has to be at least one slice, so that `reduce` below works. + assert.isAbove(slices.length, 0); + const histograms = new tr.v.HistogramSet(); + const startTime = slices.reduce( + (acc, slice) => (Math.min(acc, slice.start))); + const endTime = slices.reduce((acc, slice) => (Math.max(acc, slice.end))); + const model = createModel(startTime - 1, endTime + 1, slices); + tr.metrics.v8.wasmMetric(histograms, model, {include_sub_events: true}); + return histograms; + } + + test('testInstantiateMetric', function() { + const slices = [ + { + title: 'wasm.SyncInstantiate', args: {}, start: 10, end: 20, + cpuStart: 100, cpuEnd: 200 + }, + { + title: 'wasm.SyncInstantiate', args: {}, start: 30, end: 60, + cpuStart: 300, cpuEnd: 600 + } + ]; + const histograms = runMetrics(slices); + + const cpuValue = + histograms.getHistogramNamed('v8:wasm:sync_instantiate:cpu_time'); + assert.strictEqual(cpuValue.running.sum, 400); + assert.strictEqual(cpuValue.numValues, 2); + assert.strictEqual(cpuValue.average, 200); + assert.strictEqual(cpuValue.running.max, 300); + + const wallValue = + histograms.getHistogramNamed('v8:wasm:sync_instantiate:wall_time'); + assert.strictEqual(wallValue.running.sum, 40); + assert.strictEqual(wallValue.numValues, 2); + assert.strictEqual(wallValue.average, 20); + assert.strictEqual(wallValue.running.max, 30); + }); + + test('testStreamingBaselineCompileTime', function() { + const slices = [ + { + title: 'wasm.StartStreamingCompilation', args: {}, start: 10, end: 20, + cpuStart: 10, cpuEnd: 20 + }, + { + title: 'wasm.BaselineFinished', args: {}, start: 100, end: 110, + cpuStart: 100, cpuEnd: 110 + }, + ]; + const histograms = runMetrics(slices); + + const compileTime = histograms.getHistogramNamed( + 'v8:wasm:streaming_baseline_compilation:wall_time'); + assert.strictEqual(compileTime.numValues, 1); + assert.strictEqual(compileTime.average, 100); + assert.strictEqual(compileTime.running.max, 100); + }); + + test('testStreamingBaselineCompileTimeNoStartEvent', function() { + const slices = [ + { + title: 'wasm.BaselineFinished', args: {}, start: 100, end: 110, + cpuStart: 100, cpuEnd: 110 + }, + ]; + const histograms = runMetrics(slices); + + const compileTime = histograms.getHistogramNamed( + 'v8:wasm:streaming_baseline_compilation:wall_time'); + assert.strictEqual(compileTime, undefined); + }); + + test('testStreamingBaselineCompileTimeNoEndEvent', function() { + const slices = [ + { + title: 'wasm.StartStreamingCompilation', args: {}, start: 100, end: 110, + cpuStart: 100, cpuEnd: 110 + }, + ]; + const histograms = runMetrics(slices); + + const compileTime = histograms.getHistogramNamed( + 'v8:wasm:streaming_baseline_compilation:wall_time'); + assert.strictEqual(compileTime, undefined); + }); + + test('testTierupWallTime', function() { + const slices = [ + { + title: 'wasm.BaselineFinished', args: {}, start: 100, end: 110, + cpuStart: 100, cpuEnd: 110 + }, + { + title: 'wasm.TopTierFinished', args: {}, start: 200, end: 210, + cpuStart: 200, cpuEnd: 210 + }, + ]; + + const histograms = runMetrics(slices); + + const tierupTime = histograms.getHistogramNamed( + 'v8:wasm:compilation_tierup:wall_time'); + assert.strictEqual(tierupTime.numValues, 1); + assert.strictEqual(tierupTime.average, 110); + assert.strictEqual(tierupTime.running.max, 110); + }); + + test('testTierupNoStartEvent', function() { + const slices = [ + { + title: 'wasm.TopTierFinished', args: {}, start: 200, end: 210, + cpuStart: 200, cpuEnd: 210 + }, + ]; + + const histograms = runMetrics(slices); + + const tierupTime = histograms.getHistogramNamed( + 'v8:wasm:compilation_tierup:wall_time'); + assert.strictEqual(tierupTime, undefined); + }); + + test('testTierupNoEndEvent', function() { + const slices = [ + { + title: 'wasm.BaselineFinished', args: {}, start: 100, end: 110, + cpuStart: 100, cpuEnd: 110 + }, + ]; + + const histograms = runMetrics(slices); + + const tierupTime = histograms.getHistogramNamed( + 'v8:wasm:compilation_tierup:wall_time'); + assert.strictEqual(tierupTime, undefined); + }); +}); +</script> diff --git a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_renderer_helper.html b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_renderer_helper.html index e5eda52721f..bf3abe52814 100644 --- a/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_renderer_helper.html +++ b/chromium/third_party/catapult/tracing/tracing/model/helpers/chrome_renderer_helper.html @@ -28,6 +28,9 @@ tr.exportTo('tr.model.helpers', function() { this.dedicatedWorkerThreads_ = process.findAllThreadsMatching(function(t) { return t.name && t.name.startsWith('DedicatedWorker'); }); + this.serviceWorkerThreads_ = process.findAllThreadsMatching(function(t) { + return t.name && t.name.startsWith('ServiceWorker'); + }); this.foregroundWorkerThreads_ = process.findAllThreadsMatching(function(t) { return t.name && t.name.startsWith('ThreadPoolForegroundWorker'); }); @@ -74,6 +77,10 @@ tr.exportTo('tr.model.helpers', function() { return this.dedicatedWorkerThreads_; }, + get serviceWorkerThreads() { + return this.serviceWorkerThreads_; + }, + get foregroundWorkerThreads() { return this.foregroundWorkerThreads_; }, diff --git a/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers.html b/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers.html index c0324f96335..7e4b80cf950 100644 --- a/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers.html +++ b/chromium/third_party/catapult/tracing/tracing/ui/base/dom_helpers.html @@ -61,7 +61,11 @@ tr.exportTo('tr.ui.b', function() { } const linkEl = ownerDocument.createElement('a'); if (opt_args) { - if (opt_args.href) linkEl.href = opt_args.href; + if (opt_args.href) { + linkEl.href = opt_args.href; + // Open link in a new tab so people don't lose their Trace Viewer state. + linkEl.target = '_blank'; + } if (opt_args.tooltip) linkEl.title = opt_args.tooltip; if (opt_args.color) linkEl.style.color = opt_args.color; if (opt_args.bold) linkEl.style.fontWeight = 'bold'; diff --git a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view.html b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view.html index 3590c525407..26d01ad27cf 100644 --- a/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view.html +++ b/chromium/third_party/catapult/tracing/tracing/ui/extras/about_tracing/profiling_view.html @@ -295,27 +295,32 @@ tr.exportTo('tr.ui.e.about_tracing', function() { this.saveButton_.disabled = true; }, + detectFileExtension_(filename) { + let fileExtension = /[.]pftrace/.test(filename) ? '.pftrace' : '.json'; + if (/[.]gz$/.test(filename)) { + fileExtension += '.gz'; + } else if (/[.]zip$/.test(filename)) { + fileExtension += '.zip'; + } + return fileExtension; + }, + requestFilename_() { // unsafe filename patterns: const illegalRe = /[\/\?<>\\:\*\|":]/g; const controlRe = /[\x00-\x1f\x80-\x9f]/g; const reservedRe = /^\.+$/; - const defaultName = this.activeTrace_.filename; - let fileExtension = '.json'; - let fileRegex = /\.json$/; - if (/[.]pftrace/.test(defaultName)) { - fileExtension = '.pftrace'; - fileRegex = /\.pftrace$/; - } - if (/[.]gz$/.test(defaultName)) { - fileExtension += '.gz'; - fileRegex = new RegExp(fileExtension + '[.]gz$'); - } else if (/[.]zip$/.test(defaultName)) { - fileExtension = '.zip'; - fileRegex = /\.zip$/; - } + const fileExtension = this.detectFileExtension_(defaultName); + const escapedExtension = fileExtension.replace('.', '\\.'); + const extensionRegex = new RegExp(escapedExtension + '$'); + // |defaultName| is usually trace.json.gz, so |defaultNameWithoutExt| + // becomes 'trace'. + const defaultNameWithoutExt = defaultName.replace(extensionRegex, ''); + + // If |custom| is 'foo', the final name eventually becomes + // something like 'trace_foo.json.gz'. const custom = prompt('Filename? (' + fileExtension + ' appended) Or leave blank:'); if (custom === null) { @@ -324,15 +329,20 @@ tr.exportTo('tr.ui.e.about_tracing', function() { let name; if (custom) { - name = ' ' + custom; + // Strip the extension from |custom| if it matches up with default + // extension of the trace. If |custom| is 'foo.json.gz', we don't + // want filename to be 'foo.json.gz.json.gz'. + name = custom.replace(extensionRegex, ''); } else { const date = new Date(); - const dateText = ' ' + date.toDateString() + + const dateText = date.toDateString() + ' ' + date.toLocaleTimeString(); name = dateText; } - const filename = defaultName.replace(fileRegex, name) + fileExtension; + // filename will be something like 'trace foo.json.gz'. All spaces will be + // changed to '_' later. + const filename = defaultNameWithoutExt + ' ' + name + fileExtension; return filename .replace(illegalRe, '.') diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/reserved_infos.py b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/reserved_infos.py index 1a52a0f3053..e3087e5719f 100644 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/reserved_infos.py +++ b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/reserved_infos.py @@ -40,6 +40,7 @@ CHROMIUM_REVISIONS = _Info('chromiumRevisions', 'GenericSet', str) DESCRIPTION = _Info('description', 'GenericSet', str) DEVICE_IDS = _Info('deviceIds', 'GenericSet', str) DOCUMENTATION_URLS = _Info('documentationLinks', 'GenericSet', str) +INFO_BLURB = _Info('infoBlurb', 'GenericSet', str) FUCHSIA_GARNET_REVISIONS = _Info('fuchsiaGarnetRevisions', 'GenericSet', str) FUCHSIA_PERIDOT_REVISIONS = _Info('fuchsiaPeridotRevisions', 'GenericSet', str) FUCHSIA_TOPAZ_REVISIONS = _Info('fuchsiaTopazRevisions', 'GenericSet', str) diff --git a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/reserved_names.html b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/reserved_names.html index 77bb9681016..e1f7c686d23 100644 --- a/chromium/third_party/catapult/tracing/tracing/value/diagnostics/reserved_names.html +++ b/chromium/third_party/catapult/tracing/tracing/value/diagnostics/reserved_names.html @@ -33,6 +33,7 @@ tr.exportTo('tr.v.d', function() { DESCRIPTION: {name: 'description', type: tr.v.d.GenericSet}, DEVICE_IDS: {name: 'deviceIds', type: tr.v.d.GenericSet}, DOCUMENTATION_URLS: {name: 'documentationUrls', type: tr.v.d.GenericSet}, + INFO_BLURB: {name: 'infoBlurb', type: tr.v.d.GenericSet}, FUCHSIA_GARNET_REVISIONS: { name: 'fuchsiaGarnetRevisions', type: tr.v.d.GenericSet}, FUCHSIA_PERIDOT_REVISIONS: { |