Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: tracing/tracing/metrics/system_health/memory_metric.html

Issue 2132683002: [memory-metric] Add support for time ranges to the TBMv2 memory metric (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved. 3 Copyright 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/iteration_helpers.html"> 8 <link rel="import" href="/tracing/base/iteration_helpers.html">
9 <link rel="import" href="/tracing/base/multi_dimensional_view.html"> 9 <link rel="import" href="/tracing/base/multi_dimensional_view.html">
10 <link rel="import" href="/tracing/base/range.html"> 10 <link rel="import" href="/tracing/base/range.html">
(...skipping 30 matching lines...) Expand all
41 tr.v.NumericBuilder.createLinear( 41 tr.v.NumericBuilder.createLinear(
42 tr.v.Unit.byName.unitlessNumber_smallerIsBetter, 42 tr.v.Unit.byName.unitlessNumber_smallerIsBetter,
43 tr.b.Range.fromExplicitRange(0, 20), 20)); 43 tr.b.Range.fromExplicitRange(0, 20), 20));
44 // For size numerics (subsystem and vm stats), we use 1 bin from 0 B to 44 // For size numerics (subsystem and vm stats), we use 1 bin from 0 B to
45 // 1 KiB and 4*24 exponentially scaled bins from 1 KiB to 16 GiB (=2^24 KiB). 45 // 1 KiB and 4*24 exponentially scaled bins from 1 KiB to 16 GiB (=2^24 KiB).
46 MEMORY_NUMERIC_BUILDER_MAP.set(sizeInBytes_smallerIsBetter, 46 MEMORY_NUMERIC_BUILDER_MAP.set(sizeInBytes_smallerIsBetter,
47 new tr.v.NumericBuilder(sizeInBytes_smallerIsBetter, 0) 47 new tr.v.NumericBuilder(sizeInBytes_smallerIsBetter, 0)
48 .addBinBoundary(1024 /* 1 KiB */) 48 .addBinBoundary(1024 /* 1 KiB */)
49 .addExponentialBins(16 * 1024 * 1024 * 1024 /* 16 GiB */, 4 * 24)); 49 .addExponentialBins(16 * 1024 * 1024 * 1024 /* 16 GiB */, 4 * 24));
50 50
51 function memoryMetric(values, model) { 51 function memoryMetric(values, model, opt_options) {
52 var browserNameToGlobalDumps = splitGlobalDumpsByBrowserName(model); 52 var rangeOfInterest = opt_options ? opt_options.rangeOfInterest : undefined;
53 var browserNameToGlobalDumps =
54 splitGlobalDumpsByBrowserName(model, rangeOfInterest);
53 addGeneralMemoryDumpValues(browserNameToGlobalDumps, values); 55 addGeneralMemoryDumpValues(browserNameToGlobalDumps, values);
54 addDetailedMemoryDumpValues(browserNameToGlobalDumps, values); 56 addDetailedMemoryDumpValues(browserNameToGlobalDumps, values);
55 addMemoryDumpCountValues(browserNameToGlobalDumps, values); 57 addMemoryDumpCountValues(browserNameToGlobalDumps, values);
56 } 58 }
57 59
58 /** 60 /**
59 * Splits the global memory dumps in |model| by browser name. 61 * Splits the global memory dumps in |model| by browser name.
60 * 62 *
61 * @param {!tr.Model} model The trace model from which the global dumps 63 * @param {!tr.Model} model The trace model from which the global dumps
62 * should be extracted. 64 * should be extracted.
65 * @param {!tr.b.Range=} opt_rangeOfInterest If proided, global memory dumps
66 * that do not exclusively intersect the range will be skipped.
63 * @return {!Map<string, !Array<!tr.model.GlobalMemoryDump>} A map from 67 * @return {!Map<string, !Array<!tr.model.GlobalMemoryDump>} A map from
64 * browser names to the associated global memory dumps. 68 * browser names to the associated global memory dumps.
65 */ 69 */
66 function splitGlobalDumpsByBrowserName(model) { 70 function splitGlobalDumpsByBrowserName(model, opt_rangeOfInterest) {
67 var chromeModelHelper = 71 var chromeModelHelper =
68 model.getOrCreateHelper(tr.model.helpers.ChromeModelHelper); 72 model.getOrCreateHelper(tr.model.helpers.ChromeModelHelper);
69 var browserNameToGlobalDumps = new Map(); 73 var browserNameToGlobalDumps = new Map();
70 var globalDumpToBrowserHelper = new WeakMap(); 74 var globalDumpToBrowserHelper = new WeakMap();
71 75
72 // 1. For each browser process in the model, add its global memory dumps to 76 // 1. For each browser process in the model, add its global memory dumps to
73 // |browserNameToGlobalDumps|. |chromeModelHelper| can be undefined if 77 // |browserNameToGlobalDumps|. |chromeModelHelper| can be undefined if
74 // it fails to find any browser, renderer or GPU process (see 78 // it fails to find any browser, renderer or GPU process (see
75 // tr.model.helpers.ChromeModelHelper.supportsModel). 79 // tr.model.helpers.ChromeModelHelper.supportsModel).
76 if (chromeModelHelper) { 80 if (chromeModelHelper) {
77 chromeModelHelper.browserHelpers.forEach(function(helper) { 81 chromeModelHelper.browserHelpers.forEach(function(helper) {
78 // Retrieve the associated global memory dumps and check that they 82 // Retrieve the associated global memory dumps and check that they
79 // haven't been classified as belonging to another browser process. 83 // haven't been classified as belonging to another browser process.
80 var globalDumps = helper.process.memoryDumps.map( 84 var globalDumps = skipDumpsThatDoNotExclusivelyIntersectRange(
81 d => d.globalMemoryDump); 85 helper.process.memoryDumps.map(d => d.globalMemoryDump),
86 opt_rangeOfInterest);
82 globalDumps.forEach(function(globalDump) { 87 globalDumps.forEach(function(globalDump) {
83 var existingHelper = globalDumpToBrowserHelper.get(globalDump); 88 var existingHelper = globalDumpToBrowserHelper.get(globalDump);
84 if (existingHelper !== undefined) { 89 if (existingHelper !== undefined) {
85 throw new Error('Memory dump ID clash across multiple browsers ' + 90 throw new Error('Memory dump ID clash across multiple browsers ' +
86 'with PIDs: ' + existingHelper.pid + ' and ' + helper.pid); 91 'with PIDs: ' + existingHelper.pid + ' and ' + helper.pid);
87 } 92 }
88 globalDumpToBrowserHelper.set(globalDump, helper); 93 globalDumpToBrowserHelper.set(globalDump, helper);
89 }); 94 });
90 95
91 makeKeyUniqueAndSet(browserNameToGlobalDumps, 96 makeKeyUniqueAndSet(browserNameToGlobalDumps,
92 canonicalizeName(helper.browserName), globalDumps); 97 canonicalizeName(helper.browserName), globalDumps);
93 }); 98 });
94 } 99 }
95 100
96 // 2. If any global memory dump does not have any associated browser 101 // 2. If any global memory dump does not have any associated browser
97 // process for some reason, associate it with an 'unknown_browser' browser 102 // process for some reason, associate it with an 'unknown_browser' browser
98 // so that we don't lose the data. 103 // so that we don't lose the data.
99 var unclassifiedGlobalDumps = 104 var unclassifiedGlobalDumps = skipDumpsThatDoNotExclusivelyIntersectRange(
100 model.globalMemoryDumps.filter(g => !globalDumpToBrowserHelper.has(g)); 105 model.globalMemoryDumps.filter(g => !globalDumpToBrowserHelper.has(g)),
106 opt_rangeOfInterest);
101 if (unclassifiedGlobalDumps.length > 0) { 107 if (unclassifiedGlobalDumps.length > 0) {
102 makeKeyUniqueAndSet( 108 makeKeyUniqueAndSet(
103 browserNameToGlobalDumps, 'unknown_browser', unclassifiedGlobalDumps); 109 browserNameToGlobalDumps, 'unknown_browser', unclassifiedGlobalDumps);
104 } 110 }
105 111
106 return browserNameToGlobalDumps; 112 return browserNameToGlobalDumps;
107 } 113 }
108 114
115 function skipDumpsThatDoNotExclusivelyIntersectRange(dumps, opt_range) {
116 if (!opt_range)
117 return dumps;
118 return dumps.filter(d => opt_range.intersectsExplicitRangeExclusive(
petrcermak 2016/07/07 17:02:23 Ben: I used this to be consistent with the remaini
benjhayden 2016/07/07 17:23:10 I probably just copy-pasted it from somewhere else
petrcermak 2016/07/08 12:14:55 OK, I've changed it to "inclusive" for the memory
119 d.start, d.end));
120 }
121
109 function canonicalizeName(name) { 122 function canonicalizeName(name) {
110 return name.toLowerCase().replace(' ', '_'); 123 return name.toLowerCase().replace(' ', '_');
111 }; 124 };
112 125
113 var USER_FRIENDLY_BROWSER_NAMES = { 126 var USER_FRIENDLY_BROWSER_NAMES = {
114 'chrome': 'Chrome', 127 'chrome': 'Chrome',
115 'webview': 'WebView', 128 'webview': 'WebView',
116 'unknown_browser': 'an unknown browser' 129 'unknown_browser': 'an unknown browser'
117 }; 130 };
118 131
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 /** 1020 /**
1008 * Create a memory tr.v.Numeric (histogram) with |unit| and add all total 1021 * Create a memory tr.v.Numeric (histogram) with |unit| and add all total
1009 * values in |node| to it. 1022 * values in |node| to it.
1010 */ 1023 */
1011 function buildMemoryNumericFromNode(node, unit) { 1024 function buildMemoryNumericFromNode(node, unit) {
1012 var numeric = MEMORY_NUMERIC_BUILDER_MAP.get(unit).build(); 1025 var numeric = MEMORY_NUMERIC_BUILDER_MAP.get(unit).build();
1013 node.values.forEach(v => numeric.add(v.total)); 1026 node.values.forEach(v => numeric.add(v.total));
1014 return numeric; 1027 return numeric;
1015 } 1028 }
1016 1029
1017 tr.metrics.MetricRegistry.register(memoryMetric); 1030 tr.metrics.MetricRegistry.register(memoryMetric, {
1031 supportsRangeOfInterest: true
1032 });
1018 1033
1019 return { 1034 return {
1020 memoryMetric: memoryMetric 1035 memoryMetric: memoryMetric
1021 }; 1036 };
1022 }); 1037 });
1023 </script> 1038 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698