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

Unified Diff: base/trace_event/memory_dump_manager.cc

Issue 2760253005: memory-infra: Fill the memory dump callback result (1/2) (Closed)
Patch Set: fix typo Created 3 years, 9 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
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 45d448425e9afbf7112e9575aefa6f2a5b2a32bc..27b18fbb13020dca67ed8670b6e1f7e865152053 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -17,6 +17,8 @@
#include "base/debug/stack_trace.h"
#include "base/debug/thread_heap_usage_tracker.h"
#include "base/memory/ptr_util.h"
+#include "base/strings/pattern.h"
+#include "base/strings/string_piece.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/heap_profiler.h"
@@ -719,6 +721,19 @@ bool MemoryDumpManager::PollFastMemoryTotal(uint64_t* memory_total) {
}
// static
+uint32_t MemoryDumpManager::GetDumpsSumKb(const std::string& pattern,
+ const ProcessMemoryDump* pmd) {
+ uint64_t sum = 0;
+ for (const auto& kv : pmd->allocator_dumps()) {
+ auto name = StringPiece(kv.first);
+ if (MatchPattern(name, pattern)) {
Primiano Tucci (use gerrit) 2017/03/23 15:50:49 ditto about braces
hjd 2017/03/23 16:16:39 Done.
+ sum += kv.second->GetSize();
+ }
+ }
+ return sum / 1024;
+}
+
+// static
void MemoryDumpManager::FinalizeDumpAndAddToTrace(
std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
HEAP_PROFILER_SCOPED_IGNORE;
@@ -737,6 +752,10 @@ void MemoryDumpManager::FinalizeDumpAndAddToTrace(
"MemoryDumpManager::FinalizeDumpAndAddToTrace",
TRACE_ID_MANGLE(dump_guid), TRACE_EVENT_FLAG_FLOW_IN);
+ // The results struct to fill.
+ // TODO(hjd): Transitional until we send the full PMD. See crbug.com/704203
+ MemoryDumpCallbackResult result;
+
for (const auto& kv : pmd_async_state->process_dumps) {
ProcessId pid = kv.first; // kNullProcessId for the current process.
ProcessMemoryDump* process_memory_dump = kv.second.get();
@@ -757,6 +776,22 @@ void MemoryDumpManager::FinalizeDumpAndAddToTrace(
kTraceEventNumArgs, kTraceEventArgNames,
kTraceEventArgTypes, nullptr /* arg_values */, &event_value,
TRACE_EVENT_FLAG_HAS_ID);
+
+ // TODO(hjd): Transitional until we send the full PMD. See crbug.com/704203
+ if (pid == kNullProcessId) {
+ result.chrome_dump.malloc_total_kb =
+ GetDumpsSumKb("malloc", process_memory_dump);
+ result.chrome_dump.v8_total_kb =
+ GetDumpsSumKb("v8/*", process_memory_dump);
+ // partition_alloc reports sizes for both allocated_objects and
Primiano Tucci (use gerrit) 2017/03/23 15:50:49 nit: add a \n before this comment to split from th
hjd 2017/03/23 16:16:39 Done.
+ // partitions. The memory allocated_objects uses is a subset of
+ // the partitions memory so to avoid double counting we only
+ // count partitions memory.
+ result.chrome_dump.partition_alloc_total_kb =
+ GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump);
+ result.chrome_dump.blink_gc_total_kb =
+ GetDumpsSumKb("blink_gc", process_memory_dump);
+ }
}
bool tracing_still_enabled;
« base/trace_event/memory_allocator_dump.cc ('K') | « base/trace_event/memory_dump_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698