OLD | NEW |
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/metrics/metric_registry.html"> | 9 <link rel="import" href="/tracing/metrics/metric_registry.html"> |
10 <link rel="import" href="/tracing/value/diagnostics/diagnostic_map.html"> | 10 <link rel="import" href="/tracing/value/diagnostics/diagnostic_map.html"> |
(...skipping 20 matching lines...) Expand all Loading... |
31 tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, TIME_BOUNDARIES); | 31 tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, TIME_BOUNDARIES); |
32 hist.addSample(duration); | 32 hist.addSample(duration); |
33 histograms.addHistogram(hist); | 33 histograms.addHistogram(hist); |
34 if (opt_description) hist.description = opt_description; | 34 if (opt_description) hist.description = opt_description; |
35 } | 35 } |
36 | 36 |
37 // Adds histograms specific to memory-infra dumps. | 37 // Adds histograms specific to memory-infra dumps. |
38 function addMemoryInfraHistograms( | 38 function addMemoryInfraHistograms( |
39 histograms, model, categoryNamesToTotalEventSizes) { | 39 histograms, model, categoryNamesToTotalEventSizes) { |
40 var memoryDumpCount = model.globalMemoryDumps.length; | 40 var memoryDumpCount = model.globalMemoryDumps.length; |
41 if (memoryDumpCount === 0) | 41 if (memoryDumpCount === 0) return; |
42 return; | |
43 | 42 |
44 var totalOverhead = 0; | 43 var totalOverhead = 0; |
45 var nonMemoryInfraThreadOverhead = 0; | 44 var nonMemoryInfraThreadOverhead = 0; |
46 var overheadByProvider = {}; | 45 var overheadByProvider = {}; |
47 tr.b.iterItems(model.processes, function(pid, process) { | 46 for (var process of Object.values(model.processes)) { |
48 tr.b.iterItems(process.threads, function(tid, thread) { | 47 for (var thread of Object.values(process.threads)) { |
49 tr.b.iterItems(thread.sliceGroup.slices, (unusedSliceId, slice) => { | 48 for (var slice of Object.values(thread.sliceGroup.slices)) { |
50 if (slice.category !== MEMORY_INFRA_TRACING_CATEGORY) | 49 if (slice.category !== MEMORY_INFRA_TRACING_CATEGORY) return; |
51 return; | 50 |
52 totalOverhead += slice.duration; | 51 totalOverhead += slice.duration; |
53 if (thread.name !== 'MemoryInfra') | 52 if (thread.name !== 'MemoryInfra') |
54 nonMemoryInfraThreadOverhead += slice.duration; | 53 nonMemoryInfraThreadOverhead += slice.duration; |
55 if (slice.args && slice.args['dump_provider.name']) { | 54 if (slice.args && slice.args['dump_provider.name']) { |
56 var providerName = slice.args['dump_provider.name']; | 55 var providerName = slice.args['dump_provider.name']; |
57 var durationAndCount = overheadByProvider[providerName]; | 56 var durationAndCount = overheadByProvider[providerName]; |
58 if (durationAndCount === undefined) { | 57 if (durationAndCount === undefined) { |
59 overheadByProvider[providerName] = durationAndCount = | 58 overheadByProvider[providerName] = durationAndCount = |
60 {duration: 0, count: 0}; | 59 {duration: 0, count: 0}; |
61 } | 60 } |
62 durationAndCount.duration += slice.duration; | 61 durationAndCount.duration += slice.duration; |
63 durationAndCount.count++; | 62 durationAndCount.count++; |
64 } | 63 } |
65 }); | 64 } |
66 }); | 65 } |
67 }); | 66 } |
68 | 67 |
69 addTimeDurationHistogram( | 68 addTimeDurationHistogram( |
70 'memory_dump_cpu_overhead', | 69 'memory_dump_cpu_overhead', |
71 totalOverhead / memoryDumpCount, histograms, | 70 totalOverhead / memoryDumpCount, histograms, |
72 'Average CPU overhead on all threads per memory-infra dump'); | 71 'Average CPU overhead on all threads per memory-infra dump'); |
73 addTimeDurationHistogram( | 72 addTimeDurationHistogram( |
74 'nonmemory_thread_memory_dump_cpu_overhead', | 73 'nonmemory_thread_memory_dump_cpu_overhead', |
75 nonMemoryInfraThreadOverhead / memoryDumpCount, histograms, | 74 nonMemoryInfraThreadOverhead / memoryDumpCount, histograms, |
76 'Average CPU overhead on non-memory-infra threads per memory-infra ' + | 75 'Average CPU overhead on non-memory-infra threads per memory-infra ' + |
77 'dump'); | 76 'dump'); |
78 tr.b.iterItems(overheadByProvider, function(providerName, overhead) { | 77 for (let [providerName, overhead] of Object.entries(overheadByProvider)) { |
79 addTimeDurationHistogram( | 78 addTimeDurationHistogram( |
80 providerName + '_memory_dump_cpu_overhead', | 79 providerName + '_memory_dump_cpu_overhead', |
81 overhead.duration / overhead.count, histograms, | 80 overhead.duration / overhead.count, histograms, |
82 'Average CPU overhead of ' + providerName + ' per OnMemoryDump call'); | 81 'Average CPU overhead of ' + providerName + ' per OnMemoryDump call'); |
83 }); | 82 } |
84 | 83 |
85 var memoryInfraEventsSize = | 84 var memoryInfraEventsSize = |
86 categoryNamesToTotalEventSizes.get(MEMORY_INFRA_TRACING_CATEGORY); | 85 categoryNamesToTotalEventSizes.get(MEMORY_INFRA_TRACING_CATEGORY); |
87 var memoryInfraTraceBytesValue = new tr.v.Histogram( | 86 var memoryInfraTraceBytesValue = new tr.v.Histogram( |
88 'total_memory_dump_size', | 87 'total_memory_dump_size', |
89 tr.b.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES); | 88 tr.b.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES); |
90 memoryInfraTraceBytesValue.description = | 89 memoryInfraTraceBytesValue.description = |
91 'Total trace size of memory-infra dumps in bytes'; | 90 'Total trace size of memory-infra dumps in bytes'; |
92 memoryInfraTraceBytesValue.addSample(memoryInfraEventsSize); | 91 memoryInfraTraceBytesValue.addSample(memoryInfraEventsSize); |
93 histograms.addHistogram(memoryInfraTraceBytesValue); | 92 histograms.addHistogram(memoryInfraTraceBytesValue); |
(...skipping 12 matching lines...) Expand all Loading... |
106 // (e.g. 'trace_size_growth_per_second', not 'Max event size in bytes per | 105 // (e.g. 'trace_size_growth_per_second', not 'Max event size in bytes per |
107 // second'). | 106 // second'). |
108 // https://github.com/catapult-project/catapult/issues/3233 | 107 // https://github.com/catapult-project/catapult/issues/3233 |
109 function tracingMetric(histograms, model) { | 108 function tracingMetric(histograms, model) { |
110 addTimeDurationHistogram( | 109 addTimeDurationHistogram( |
111 'trace_import_duration', model.stats.traceImportDurationMs, histograms); | 110 'trace_import_duration', model.stats.traceImportDurationMs, histograms); |
112 | 111 |
113 if (!model.stats.hasEventSizesinBytes) return; | 112 if (!model.stats.hasEventSizesinBytes) return; |
114 | 113 |
115 var eventStats = model.stats.allTraceEventStatsInTimeIntervals; | 114 var eventStats = model.stats.allTraceEventStatsInTimeIntervals; |
116 eventStats.sort(function(a, b) { | 115 eventStats.sort((a, b) => a.timeInterval - b.timeInterval); |
117 return a.timeInterval - b.timeInterval; | |
118 }); | |
119 | 116 |
120 var totalTraceBytes = eventStats.reduce((a, b) => | 117 var totalTraceBytes = eventStats.reduce( |
121 (a + b.totalEventSizeinBytes), 0); | 118 (a, b) => a + b.totalEventSizeinBytes, 0); |
122 | 119 |
123 // We maintain a sliding window of records [start ... end-1] where end | 120 // We maintain a sliding window of records [start ... end-1] where end |
124 // increments each time through the loop, and we move start just far enough | 121 // increments each time through the loop, and we move start just far enough |
125 // to keep the window less than 1 second wide. Note that we need to compute | 122 // to keep the window less than 1 second wide. Note that we need to compute |
126 // the number of time intervals (i.e. units that timeInterval is given in) | 123 // the number of time intervals (i.e. units that timeInterval is given in) |
127 // in one second to know how wide the sliding window should be. | 124 // in one second to know how wide the sliding window should be. |
128 var maxEventCountPerSec = 0; | 125 var maxEventCountPerSec = 0; |
129 var maxEventBytesPerSec = 0; | 126 var maxEventBytesPerSec = 0; |
130 var INTERVALS_PER_SEC = Math.floor( | 127 var INTERVALS_PER_SEC = Math.floor( |
131 1000 / model.stats.TIME_INTERVAL_SIZE_IN_MS); | 128 1000 / model.stats.TIME_INTERVAL_SIZE_IN_MS); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 207 |
211 tr.metrics.MetricRegistry.register(tracingMetric); | 208 tr.metrics.MetricRegistry.register(tracingMetric); |
212 | 209 |
213 return { | 210 return { |
214 tracingMetric, | 211 tracingMetric, |
215 // For testing only: | 212 // For testing only: |
216 MEMORY_INFRA_TRACING_CATEGORY, | 213 MEMORY_INFRA_TRACING_CATEGORY, |
217 }; | 214 }; |
218 }); | 215 }); |
219 </script> | 216 </script> |
OLD | NEW |