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

Unified Diff: base/trace_event/memory_dump_manager.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/trace_event/malloc_dump_provider.cc ('k') | base/trace_event/process_memory_dump.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_dump_manager.cc
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc
index bd00bd66993e2b5821ef53b8cd0eefd610476d8b..f4146c0579996fc63a7f9b790bae8af1dd11e91f 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -29,9 +29,7 @@
#include "base/trace_event/heap_profiler.h"
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
#include "base/trace_event/heap_profiler_event_filter.h"
-#include "base/trace_event/heap_profiler_serialization_state.h"
-#include "base/trace_event/heap_profiler_stack_frame_deduplicator.h"
-#include "base/trace_event/heap_profiler_type_name_deduplicator.h"
+#include "base/trace_event/heap_profiler_event_writer.h"
#include "base/trace_event/malloc_dump_provider.h"
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/memory_dump_scheduler.h"
@@ -83,37 +81,6 @@ void FillOsDumpFromProcessMemoryDump(
}
}
-// Proxy class which wraps a ConvertableToTraceFormat owned by the
-// |heap_profiler_serialization_state| into a proxy object that can be added to
-// the trace event log. This is to solve the problem that the
-// HeapProfilerSerializationState is refcounted but the tracing subsystem wants
-// a std::unique_ptr<ConvertableToTraceFormat>.
-template <typename T>
-struct SessionStateConvertableProxy : public ConvertableToTraceFormat {
- using GetterFunctPtr = T* (HeapProfilerSerializationState::*)() const;
-
- SessionStateConvertableProxy(scoped_refptr<HeapProfilerSerializationState>
- heap_profiler_serialization_state,
- GetterFunctPtr getter_function)
- : heap_profiler_serialization_state(heap_profiler_serialization_state),
- getter_function(getter_function) {}
-
- void AppendAsTraceFormat(std::string* out) const override {
- return (heap_profiler_serialization_state.get()->*getter_function)()
- ->AppendAsTraceFormat(out);
- }
-
- void EstimateTraceMemoryOverhead(
- TraceEventMemoryOverhead* overhead) override {
- return (heap_profiler_serialization_state.get()->*getter_function)()
- ->EstimateTraceMemoryOverhead(overhead);
- }
-
- scoped_refptr<HeapProfilerSerializationState>
- heap_profiler_serialization_state;
- GetterFunctPtr const getter_function;
-};
-
void OnPeakDetected(MemoryDumpLevelOfDetail level_of_detail) {
MemoryDumpManager::GetInstance()->RequestGlobalDump(
MemoryDumpType::PEAK_MEMORY_USAGE, level_of_detail);
@@ -776,6 +743,14 @@ void MemoryDumpManager::FinalizeDumpAndAddToTrace(
}
}
+ bool tracing_still_enabled;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled);
+ if (!tracing_still_enabled) {
+ pmd_async_state->dump_successful = false;
+ VLOG(1) << kLogPrefix << " failed because tracing was disabled before"
+ << " the dump was completed";
+ }
+
if (!pmd_async_state->callback.is_null()) {
pmd_async_state->callback.Run(dump_guid, dump_successful, result);
pmd_async_state->callback.Reset();
@@ -793,28 +768,13 @@ void MemoryDumpManager::SetupForTracing(
->set_heap_profiler_breakdown_threshold_bytes(
memory_dump_config.heap_profiler_options.breakdown_threshold_bytes);
if (heap_profiling_enabled_) {
- // If heap profiling is enabled, the stack frame deduplicator and type name
- // deduplicator will be in use. Add a metadata events to write the frames
- // and type IDs.
- heap_profiler_serialization_state->SetStackFrameDeduplicator(
- WrapUnique(new StackFrameDeduplicator));
-
- heap_profiler_serialization_state->SetTypeNameDeduplicator(
- WrapUnique(new TypeNameDeduplicator));
-
- TRACE_EVENT_API_ADD_METADATA_EVENT(
- TraceLog::GetCategoryGroupEnabled("__metadata"), "stackFrames",
- "stackFrames",
- MakeUnique<SessionStateConvertableProxy<StackFrameDeduplicator>>(
- heap_profiler_serialization_state,
- &HeapProfilerSerializationState::stack_frame_deduplicator));
-
- TRACE_EVENT_API_ADD_METADATA_EVENT(
- TraceLog::GetCategoryGroupEnabled("__metadata"), "typeNames",
- "typeNames",
- MakeUnique<SessionStateConvertableProxy<TypeNameDeduplicator>>(
- heap_profiler_serialization_state,
- &HeapProfilerSerializationState::type_name_deduplicator));
+ heap_profiler_serialization_state->CreateDeduplicators();
+ const TraceConfig& trace_config =
+ TraceLog::GetInstance()->GetCurrentTraceConfig();
+ // TODO(dskiba): support continuous mode (crbug.com/701052)
+ LOG_IF(ERROR, trace_config.GetTraceRecordMode() != RECORD_CONTINUOUSLY)
+ << "Heap profile format is incremental and doesn't yet fully support "
+ << "continuous mode.";
}
AutoLock lock(lock_);
« no previous file with comments | « base/trace_event/malloc_dump_provider.cc ('k') | base/trace_event/process_memory_dump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698