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

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

Issue 1467453003: [Tracing] Make heap profiler type info a string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 "base/trace_event/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 15 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
16 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h" 16 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
17 #include "base/trace_event/heap_profiler_type_name_deduplicator.h"
17 #include "base/trace_event/malloc_dump_provider.h" 18 #include "base/trace_event/malloc_dump_provider.h"
18 #include "base/trace_event/memory_dump_provider.h" 19 #include "base/trace_event/memory_dump_provider.h"
19 #include "base/trace_event/memory_dump_session_state.h" 20 #include "base/trace_event/memory_dump_session_state.h"
20 #include "base/trace_event/process_memory_dump.h" 21 #include "base/trace_event/process_memory_dump.h"
21 #include "base/trace_event/trace_event_argument.h" 22 #include "base/trace_event/trace_event_argument.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 24
24 #if !defined(OS_NACL) 25 #if !defined(OS_NACL)
25 #include "base/trace_event/process_memory_totals_dump_provider.h" 26 #include "base/trace_event/process_memory_totals_dump_provider.h"
26 #endif 27 #endif
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 if (!dump_thread->Start()) { 512 if (!dump_thread->Start()) {
512 LOG(ERROR) << "Failed to start the memory-infra thread for tracing"; 513 LOG(ERROR) << "Failed to start the memory-infra thread for tracing";
513 return; 514 return;
514 } 515 }
515 516
516 AutoLock lock(lock_); 517 AutoLock lock(lock_);
517 518
518 DCHECK(delegate_); // At this point we must have a delegate. 519 DCHECK(delegate_); // At this point we must have a delegate.
519 520
520 scoped_refptr<StackFrameDeduplicator> stack_frame_deduplicator = nullptr; 521 scoped_refptr<StackFrameDeduplicator> stack_frame_deduplicator = nullptr;
522 scoped_refptr<TypeNameDeduplicator> type_name_deduplicator = nullptr;
521 523
522 if (heap_profiling_enabled_) { 524 if (heap_profiling_enabled_) {
523 // If heap profiling is enabled, the stack frame deduplicator will be in 525 // If heap profiling is enabled, the stack frame deduplicator and type name
524 // use. Add a metadata event to write its frames. 526 // deduplicator will be in use. Add a metadata events to write the frames
527 // and type IDs.
525 stack_frame_deduplicator = new StackFrameDeduplicator; 528 stack_frame_deduplicator = new StackFrameDeduplicator;
529 type_name_deduplicator = new TypeNameDeduplicator;
526 TRACE_EVENT_API_ADD_METADATA_EVENT( 530 TRACE_EVENT_API_ADD_METADATA_EVENT(
527 "stackFrames", "stackFrames", 531 "stackFrames", "stackFrames",
528 scoped_refptr<ConvertableToTraceFormat>(stack_frame_deduplicator)); 532 scoped_refptr<ConvertableToTraceFormat>(stack_frame_deduplicator));
533 TRACE_EVENT_API_ADD_METADATA_EVENT(
534 "typeNames", "typeNames",
535 scoped_refptr<ConvertableToTraceFormat>(type_name_deduplicator));
529 } 536 }
530 537
531 DCHECK(!dump_thread_); 538 DCHECK(!dump_thread_);
532 dump_thread_ = dump_thread.Pass(); 539 dump_thread_ = dump_thread.Pass();
533 session_state_ = new MemoryDumpSessionState(stack_frame_deduplicator); 540 session_state_ = new MemoryDumpSessionState(stack_frame_deduplicator,
541 type_name_deduplicator);
534 542
535 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) { 543 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) {
536 it->disabled = false; 544 it->disabled = false;
537 it->consecutive_failures = 0; 545 it->consecutive_failures = 0;
538 } 546 }
539 547
540 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); 548 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1);
541 549
542 // TODO(primiano): This is a temporary hack to disable periodic memory dumps 550 // TODO(primiano): This is a temporary hack to disable periodic memory dumps
543 // when running memory benchmarks until telemetry uses TraceConfig to 551 // when running memory benchmarks until telemetry uses TraceConfig to
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 auto iter = process_dumps.find(pid); 650 auto iter = process_dumps.find(pid);
643 if (iter == process_dumps.end()) { 651 if (iter == process_dumps.end()) {
644 scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state)); 652 scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state));
645 iter = process_dumps.insert(pid, new_pmd.Pass()).first; 653 iter = process_dumps.insert(pid, new_pmd.Pass()).first;
646 } 654 }
647 return iter->second; 655 return iter->second;
648 } 656 }
649 657
650 } // namespace trace_event 658 } // namespace trace_event
651 } // namespace base 659 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698