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

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

Issue 3009553002: Refactor Histogram relationship diagnostics. (Closed)
Patch Set: Created 3 years, 3 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/math/range.html"> 8 <link rel="import" href="/tracing/base/math/range.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/unit.html"> 10 <link rel="import" href="/tracing/base/unit.html">
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 1082
1083 /** 1083 /**
1084 * For the given |browserName| (e.g. 'chrome'), |property| 1084 * For the given |browserName| (e.g. 'chrome'), |property|
1085 * (e.g. EFFECTIVE_SIZE), |processPath| (e.g. ['browser_process']), 1085 * (e.g. EFFECTIVE_SIZE), |processPath| (e.g. ['browser_process']),
1086 * |componentPath| (e.g. ['v8']), add 1086 * |componentPath| (e.g. ['v8']), add
1087 * a tr.v.Histogram with |unit| aggregating the total 1087 * a tr.v.Histogram with |unit| aggregating the total
1088 * values of the associated |componentNode| across all timestamps 1088 * values of the associated |componentNode| across all timestamps
1089 * (corresponding to global memory dumps associated with the given browser) 1089 * (corresponding to global memory dumps associated with the given browser)
1090 * |values| for each process (e.g. 'gpu_process', 'browser_process', etc). 1090 * |values| for each process (e.g. 'gpu_process', 'browser_process', etc).
1091 * We also report a special 'all_processes' histogram which agregates all 1091 * We also report a special 'all_processes' histogram which agregates all
1092 * others, this has a RelatedHistogramBreakdown diagnostic explaining 1092 * others, this has a RelatedNameMap diagnostic explaining
1093 * how it is built from the other histograms. 1093 * how it is built from the other histograms.
1094 * 1094 *
1095 * See addMemoryDumpValues for more details. 1095 * See addMemoryDumpValues for more details.
1096 */ 1096 */
1097 function reportComponentDataAsValues(browserName, sourceName, property, 1097 function reportComponentDataAsValues(browserName, sourceName, property,
1098 processPath, componentPath, tree, values, customComponentTreeModifier, 1098 processPath, componentPath, tree, values, customComponentTreeModifier,
1099 opt_cachedHistograms) { 1099 opt_cachedHistograms) {
1100 const cachedHistograms = opt_cachedHistograms || new Map(); 1100 const cachedHistograms = opt_cachedHistograms || new Map();
1101 function recurse(processPath, componentPath, node) { 1101 function recurse(processPath, componentPath, node) {
1102 return reportComponentDataAsValues(browserName, sourceName, property, 1102 return reportComponentDataAsValues(browserName, sourceName, property,
(...skipping 11 matching lines...) Expand all
1114 node); 1114 node);
1115 } 1115 }
1116 1116
1117 customComponentTreeModifier(tree); 1117 customComponentTreeModifier(tree);
1118 const histogram = buildHistogram(processPath, componentPath, tree); 1118 const histogram = buildHistogram(processPath, componentPath, tree);
1119 if (cachedHistograms.has(histogram.name)) { 1119 if (cachedHistograms.has(histogram.name)) {
1120 return cachedHistograms.get(histogram.name); 1120 return cachedHistograms.get(histogram.name);
1121 } 1121 }
1122 cachedHistograms.set(histogram.name, histogram); 1122 cachedHistograms.set(histogram.name, histogram);
1123 1123
1124 const processBreakdown = new tr.v.d.RelatedHistogramBreakdown(); 1124 const processNames = new tr.v.d.RelatedNameMap();
1125 processBreakdown.colorScheme =
1126 tr.e.chrome.chrome_processes.PROCESS_COLOR_SCHEME_NAME;
1127 for (const [childProcessName, childProcessNode] of tree.children[0]) { 1125 for (const [childProcessName, childProcessNode] of tree.children[0]) {
1128 processPath.push(childProcessName); 1126 processPath.push(childProcessName);
1129 const childProcessHistogram = 1127 const childProcessHistogram =
1130 recurse(processPath, componentPath, childProcessNode); 1128 recurse(processPath, componentPath, childProcessNode);
1131 processBreakdown.set(childProcessName, childProcessHistogram); 1129 processNames.set(childProcessName, childProcessHistogram.name);
1132 processPath.pop(); 1130 processPath.pop();
1133 } 1131 }
1134 1132
1135 const componentBreakdown = new tr.v.d.RelatedHistogramBreakdown(); 1133 const componentNames = new tr.v.d.RelatedNameMap();
1136 for (const [childComponentName, childComponentNode] of tree.children[1]) { 1134 for (const [childComponentName, childComponentNode] of tree.children[1]) {
1137 componentPath.push(childComponentName); 1135 componentPath.push(childComponentName);
1138 const childComponentHistogram = 1136 const childComponentHistogram =
1139 recurse(processPath, componentPath, childComponentNode); 1137 recurse(processPath, componentPath, childComponentNode);
1140 componentBreakdown.set(childComponentName, childComponentHistogram); 1138 componentNames.set(childComponentName, childComponentHistogram.name);
1141 componentPath.pop(); 1139 componentPath.pop();
1142 } 1140 }
1143 1141
1144 values.addHistogram(histogram); 1142 values.addHistogram(histogram);
1145 if (tree.children[0].size > 0) { 1143 if (tree.children[0].size > 0) {
1146 histogram.diagnostics.set('processes', processBreakdown); 1144 histogram.diagnostics.set('processes', processNames);
1147 } 1145 }
1148 if (tree.children[1].size > 0) { 1146 if (tree.children[1].size > 0) {
1149 histogram.diagnostics.set('components', componentBreakdown); 1147 histogram.diagnostics.set('components', componentNames);
1150 } 1148 }
1151 1149
1152 return histogram; 1150 return histogram;
1153 } 1151 }
1154 1152
1155 /** 1153 /**
1156 * Gets the name for a histogram. 1154 * Gets the name for a histogram.
1157 * The histograms have the following naming scheme: 1155 * The histograms have the following naming scheme:
1158 * memory:chrome:browser_process:reported_by_chrome:v8:heap:effective_size_avg 1156 * memory:chrome:browser_process:reported_by_chrome:v8:heap:effective_size_avg
1159 * ^browser ^process ^source ^component ^property 1157 * ^browser ^process ^source ^component ^property
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 browserName, sourceName, property.name, processName, componentPath); 1189 browserName, sourceName, property.name, processName, componentPath);
1192 const description = getNumericDescription( 1190 const description = getNumericDescription(
1193 property, browserName, processName, componentPath); 1191 property, browserName, processName, componentPath);
1194 1192
1195 // Build the underlying numeric for the memory value. 1193 // Build the underlying numeric for the memory value.
1196 const numeric = buildMemoryNumericFromNode(name, node, property.unit); 1194 const numeric = buildMemoryNumericFromNode(name, node, property.unit);
1197 numeric.description = description; 1195 numeric.description = description;
1198 return numeric; 1196 return numeric;
1199 } 1197 }
1200 1198
1199 function buildSampleDiagnostics(value, node) {
1200 if (node.children.length < 2) return undefined;
1201 const diagnostics = new Map();
1202 const i = node.values.indexOf(value);
1203
1204 const processBreakdown = new tr.v.d.Breakdown();
1205 processBreakdown.colorScheme =
1206 tr.e.chrome.chrome_processes.PROCESS_COLOR_SCHEME_NAME;
1207 for (const [name, subNode] of node.children[0]) {
1208 processBreakdown.set(name, subNode.values[i].total);
1209 }
1210 if (processBreakdown.size > 0) {
1211 diagnostics.set('processes', processBreakdown);
1212 }
1213
1214 const componentBreakdown = new tr.v.d.Breakdown();
1215 for (const [name, subNode] of node.children[1]) {
1216 componentBreakdown.set(name, subNode.values[i].total);
1217 }
1218 if (componentBreakdown.size > 0) {
1219 diagnostics.set('components', componentBreakdown);
1220 }
1221
1222 if (diagnostics.size === 0) return undefined;
1223 return diagnostics;
1224 }
1225
1201 /** 1226 /**
1202 * Create a memory tr.v.Histogram with |unit| and add all total values in 1227 * Create a memory tr.v.Histogram with |unit| and add all total values in
1203 * |node| to it. 1228 * |node| to it.
1204 */ 1229 */
1205 function buildMemoryNumericFromNode(name, node, unit) { 1230 function buildMemoryNumericFromNode(name, node, unit) {
1206 const histogram = new tr.v.Histogram( 1231 const histogram = new tr.v.Histogram(
1207 name, unit, BOUNDARIES_FOR_UNIT_MAP.get(unit)); 1232 name, unit, BOUNDARIES_FOR_UNIT_MAP.get(unit));
1208 node.values.forEach(v => histogram.addSample(v.total)); 1233
1234 node.values.forEach(v => histogram.addSample(
1235 v.total, buildSampleDiagnostics(v, node)));
1236
1209 return histogram; 1237 return histogram;
1210 } 1238 }
1211 1239
1212 tr.metrics.MetricRegistry.register(memoryMetric, { 1240 tr.metrics.MetricRegistry.register(memoryMetric, {
1213 supportsRangeOfInterest: true 1241 supportsRangeOfInterest: true
1214 }); 1242 });
1215 1243
1216 return { 1244 return {
1217 memoryMetric, 1245 memoryMetric,
1218 }; 1246 };
1219 }); 1247 });
1220 </script> 1248 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698