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

Unified Diff: base/trace_event/memory_dump_manager.cc

Issue 2760253005: memory-infra: Fill the memory dump callback result (1/2) (Closed)
Patch Set: tweak a few comments 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..82a12e15216b142a6d038a9d668d09f98cb89e75 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -719,6 +719,20 @@ bool MemoryDumpManager::PollFastMemoryTotal(uint64_t* memory_total) {
}
// static
+uint32_t MemoryDumpManager::SumSizesInKbForPrefix(
+ const std::string& prefix,
+ const ProcessMemoryDump* pmd) {
+ uint64_t sum = 0;
+ for (const auto& kv : pmd->allocator_dumps()) {
+ if (kv.first.compare(0, prefix.length(), prefix) == 0) {
Primiano Tucci (use gerrit) 2017/03/22 17:19:52 as we discussed offline let's use StartsWith in st
hjd 2017/03/22 19:24:20 Done.
+ sum += kv.second->GetSize();
+ }
+ }
+ // Convert bytes to kilobytes.
Primiano Tucci (use gerrit) 2017/03/22 17:19:52 this comment should be unnecessary given the name
hjd 2017/03/22 19:24:20 Done.
+ return sum / 1024;
+}
+
+// static
void MemoryDumpManager::FinalizeDumpAndAddToTrace(
std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
HEAP_PROFILER_SCOPED_IGNORE;
@@ -737,6 +751,26 @@ void MemoryDumpManager::FinalizeDumpAndAddToTrace(
"MemoryDumpManager::FinalizeDumpAndAddToTrace",
TRACE_ID_MANGLE(dump_guid), TRACE_EVENT_FLAG_FLOW_IN);
+ // Fill results struct.
Primiano Tucci (use gerrit) 2017/03/22 17:19:52 ditto about todo + bug
hjd 2017/03/22 19:24:20 Done.
+ MemoryDumpCallbackResult result;
+ for (const auto& kv : pmd_async_state->process_dumps) {
Primiano Tucci (use gerrit) 2017/03/22 17:19:52 since you have the same loop below, could you make
hjd 2017/03/22 19:24:20 not really, just seemed easier while I was debuggi
+ ProcessMemoryDump* process_memory_dump = kv.second.get();
+ if (kv.first == kNullProcessId) {
+ result.chrome_dump.v8_total_kb =
+ SumSizesInKbForPrefix("v8/", process_memory_dump);
+ result.chrome_dump.malloc_total_kb =
+ SumSizesInKbForPrefix("malloc/", process_memory_dump);
Primiano Tucci (use gerrit) 2017/03/22 17:19:52 hmm I know that we discussed this offline but now
hjd 2017/03/22 19:24:20 Done.
+ // partition_alloc reports sizes for both allocated_objects and
+ // 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 = SumSizesInKbForPrefix(
+ "partition_alloc/partitions", process_memory_dump);
+ result.chrome_dump.blink_gc_total_kb =
+ SumSizesInKbForPrefix("blink_gc/", process_memory_dump);
+ }
+ }
+
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();
« base/trace_event/memory_dump_manager.h ('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