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

Unified Diff: base/trace_event/memory_dump_manager.cc

Issue 2760253005: memory-infra: Fill the memory dump callback result (1/2) (Closed)
Patch Set: update for 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
« no previous file with comments | « base/trace_event/memory_dump_manager.h ('k') | no next file » | 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 45d448425e9afbf7112e9575aefa6f2a5b2a32bc..fbc7bcf8e70e717779372f8f117392b81e946e2d 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -17,6 +17,7 @@
#include "base/debug/stack_trace.h"
#include "base/debug/thread_heap_usage_tracker.h"
#include "base/memory/ptr_util.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 +720,21 @@ bool MemoryDumpManager::PollFastMemoryTotal(uint64_t* memory_total) {
}
// static
+uint32_t MemoryDumpManager::GetDumpsSumKb(const std::string& prefix,
+ const ProcessMemoryDump* pmd) {
+ uint64_t sum = 0;
+ for (const auto& kv : pmd->allocator_dumps()) {
+ auto name = StringPiece(kv.first);
+ if (name.starts_with(prefix)) {
+ sum += kv.second->GetSize();
+ }
+ // We shouldn't be summing things with suballocations.
+ DCHECK(name.find("/__") == name.npos);
ssid 2017/03/23 03:11:38 So, this is supposed to work only for BACKGROUND m
hjd 2017/03/23 14:50:31 I removed this now that it should work in all mode
+ }
+ return sum / 1024;
+}
+
+// static
void MemoryDumpManager::FinalizeDumpAndAddToTrace(
std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) {
HEAP_PROFILER_SCOPED_IGNORE;
@@ -737,6 +753,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 +777,25 @@ 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 (pmd_async_state->req_args.level_of_detail ==
+ MemoryDumpLevelOfDetail::BACKGROUND) {
+ if (pid == kNullProcessId) {
+ result.chrome_dump.malloc_total_kb =
+ GetDumpsSumKb("malloc/", process_memory_dump);
ssid 2017/03/23 03:11:38 This seems very fragile. the double counting depen
Primiano Tucci (use gerrit) 2017/03/23 12:27:58 In this case I'd just count "malloc" (without any
hjd 2017/03/23 14:50:30 Done.
+ result.chrome_dump.v8_total_kb =
+ GetDumpsSumKb("v8/", process_memory_dump);
+ // 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 =
+ GetDumpsSumKb("partition_alloc/partitions", process_memory_dump);
+ result.chrome_dump.blink_gc_total_kb =
+ GetDumpsSumKb("blink_gc/", process_memory_dump);
ssid 2017/03/23 03:11:38 So, in this case we would be counting the "allocat
Primiano Tucci (use gerrit) 2017/03/23 12:27:58 We don't for blink_gc. Since we have an explicit t
hjd 2017/03/23 14:50:31 Done.
+ }
+ }
}
bool tracing_still_enabled;
« no previous file with comments | « 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