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

Side by Side Diff: base/trace_event/malloc_dump_provider.cc

Issue 2898943004: Cleanup malloc dump provider after previous refactoring (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/trace_event/malloc_dump_provider.h" 5 #include "base/trace_event/malloc_dump_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <unordered_map> 9 #include <unordered_map>
10 10
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // The dumps of the heap profiler should be created only when heap profiling 291 // The dumps of the heap profiler should be created only when heap profiling
292 // was enabled (--enable-heap-profiling) AND a DETAILED dump is requested. 292 // was enabled (--enable-heap-profiling) AND a DETAILED dump is requested.
293 // However, when enabled, the overhead of the heap profiler should be always 293 // However, when enabled, the overhead of the heap profiler should be always
294 // reported to avoid oscillations of the malloc total in LIGHT dumps. 294 // reported to avoid oscillations of the malloc total in LIGHT dumps.
295 295
296 tid_dumping_heap_ = PlatformThread::CurrentId(); 296 tid_dumping_heap_ = PlatformThread::CurrentId();
297 // At this point the Insert/RemoveAllocation hooks will ignore this thread. 297 // At this point the Insert/RemoveAllocation hooks will ignore this thread.
298 // Enclosing all the temporary data structures in a scope, so that the heap 298 // Enclosing all the temporary data structures in a scope, so that the heap
299 // profiler does not see unbalanced malloc/free calls from these containers. 299 // profiler does not see unbalanced malloc/free calls from these containers.
300 { 300 {
301 size_t shim_allocated_objects_size = 0;
302 size_t shim_allocated_objects_count = 0;
303 TraceEventMemoryOverhead overhead; 301 TraceEventMemoryOverhead overhead;
304 std::unordered_map<AllocationContext, AllocationMetrics> metrics_by_context; 302 std::unordered_map<AllocationContext, AllocationMetrics> metrics_by_context;
305 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) { 303 if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED) {
306 ShardedAllocationRegister::OutputMetrics metrics = 304 ShardedAllocationRegister::OutputMetrics shim_metrics =
307 allocation_register_.UpdateAndReturnsMetrics(metrics_by_context); 305 allocation_register_.UpdateAndReturnsMetrics(metrics_by_context);
308 306
309 // Aggregate data for objects allocated through the shim. 307 // Aggregate data for objects allocated through the shim.
310 shim_allocated_objects_size += metrics.size; 308 inner_dump->AddScalar("shim_allocated_objects_size",
311 shim_allocated_objects_count += metrics.count; 309 MemoryAllocatorDump::kUnitsBytes,
310 shim_metrics.size);
311 inner_dump->AddScalar("shim_allocator_object_count",
312 MemoryAllocatorDump::kUnitsObjects,
313 shim_metrics.count);
312 } 314 }
313 allocation_register_.EstimateTraceMemoryOverhead(&overhead); 315 allocation_register_.EstimateTraceMemoryOverhead(&overhead);
314 316
315 inner_dump->AddScalar("shim_allocated_objects_size",
316 MemoryAllocatorDump::kUnitsBytes,
317 shim_allocated_objects_size);
318 inner_dump->AddScalar("shim_allocator_object_count",
319 MemoryAllocatorDump::kUnitsObjects,
320 shim_allocated_objects_count);
321 pmd->DumpHeapUsage(metrics_by_context, overhead, "malloc"); 317 pmd->DumpHeapUsage(metrics_by_context, overhead, "malloc");
322 } 318 }
323 tid_dumping_heap_ = kInvalidThreadId; 319 tid_dumping_heap_ = kInvalidThreadId;
324 320
325 return true; 321 return true;
326 } 322 }
327 323
328 void MallocDumpProvider::OnHeapProfilingEnabled(bool enabled) { 324 void MallocDumpProvider::OnHeapProfilingEnabled(bool enabled) {
329 #if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) 325 #if BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
330 if (enabled) { 326 if (enabled) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (tid_dumping_heap_ != kInvalidThreadId && 363 if (tid_dumping_heap_ != kInvalidThreadId &&
368 tid_dumping_heap_ == PlatformThread::CurrentId()) 364 tid_dumping_heap_ == PlatformThread::CurrentId())
369 return; 365 return;
370 if (!allocation_register_.is_enabled()) 366 if (!allocation_register_.is_enabled())
371 return; 367 return;
372 allocation_register_.Remove(address); 368 allocation_register_.Remove(address);
373 } 369 }
374 370
375 } // namespace trace_event 371 } // namespace trace_event
376 } // namespace base 372 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698