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

Side by Side Diff: third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.cpp

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: Fix rebase damage Created 3 years, 7 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/PartitionAllocMemoryDumpProvider.h" 5 #include "platform/PartitionAllocMemoryDumpProvider.h"
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/heap_profiler_allocation_context.h" 10 #include "base/trace_event/heap_profiler_allocation_context.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return &instance; 129 return &instance;
130 } 130 }
131 131
132 bool PartitionAllocMemoryDumpProvider::OnMemoryDump( 132 bool PartitionAllocMemoryDumpProvider::OnMemoryDump(
133 const base::trace_event::MemoryDumpArgs& args, 133 const base::trace_event::MemoryDumpArgs& args,
134 base::trace_event::ProcessMemoryDump* memory_dump) { 134 base::trace_event::ProcessMemoryDump* memory_dump) {
135 using base::trace_event::MemoryDumpLevelOfDetail; 135 using base::trace_event::MemoryDumpLevelOfDetail;
136 136
137 MemoryDumpLevelOfDetail level_of_detail = args.level_of_detail; 137 MemoryDumpLevelOfDetail level_of_detail = args.level_of_detail;
138 if (is_heap_profiling_enabled_) { 138 if (is_heap_profiling_enabled_) {
139 // Overhead should always be reported, regardless of light vs. heavy. 139 MutexLocker locker(allocation_register_mutex_);
140 base::trace_event::TraceEventMemoryOverhead overhead; 140 memory_dump->DumpHeapUsage(*allocation_register_, kPartitionAllocDumpName);
141 std::unordered_map<base::trace_event::AllocationContext,
142 base::trace_event::AllocationMetrics>
143 metrics_by_context;
144 {
145 MutexLocker locker(allocation_register_mutex_);
146 // Dump only the overhead estimation in non-detailed dumps.
147 if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) {
148 for (const auto& alloc_size : *allocation_register_) {
149 base::trace_event::AllocationMetrics& metrics =
150 metrics_by_context[alloc_size.context];
151 metrics.size += alloc_size.size;
152 metrics.count++;
153 }
154 }
155 allocation_register_->EstimateTraceMemoryOverhead(&overhead);
156 }
157 memory_dump->DumpHeapUsage(metrics_by_context, overhead, "partition_alloc");
158 } 141 }
159 142
160 PartitionStatsDumperImpl partition_stats_dumper(memory_dump, level_of_detail); 143 PartitionStatsDumperImpl partition_stats_dumper(memory_dump, level_of_detail);
161 144
162 base::trace_event::MemoryAllocatorDump* partitions_dump = 145 base::trace_event::MemoryAllocatorDump* partitions_dump =
163 memory_dump->CreateAllocatorDump(base::StringPrintf( 146 memory_dump->CreateAllocatorDump(base::StringPrintf(
164 "%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); 147 "%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
165 148
166 // This method calls memoryStats.partitionsDumpBucketStats with memory 149 // This method calls memoryStats.partitionsDumpBucketStats with memory
167 // statistics. 150 // statistics.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 allocation_register_->Insert(address, size, context); 200 allocation_register_->Insert(address, size, context);
218 } 201 }
219 202
220 void PartitionAllocMemoryDumpProvider::Remove(void* address) { 203 void PartitionAllocMemoryDumpProvider::Remove(void* address) {
221 MutexLocker locker(allocation_register_mutex_); 204 MutexLocker locker(allocation_register_mutex_);
222 if (allocation_register_) 205 if (allocation_register_)
223 allocation_register_->Remove(address); 206 allocation_register_->Remove(address);
224 } 207 }
225 208
226 } // namespace blink 209 } // namespace blink
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_memory_overhead.cc ('k') | third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698