Commit a28aa413 authored by hjd's avatar hjd Committed by Commit bot

memory-infra: Plumb platform_private_footprint to MemoryDumpManager

BUG=707019

Review-Url: https://codereview.chromium.org/2852473002
Cr-Commit-Position: refs/heads/master@{#468941}
parent 2a1bf28f
...@@ -78,6 +78,7 @@ void FillOsDumpFromProcessMemoryDump( ...@@ -78,6 +78,7 @@ void FillOsDumpFromProcessMemoryDump(
if (pmd->has_process_totals()) { if (pmd->has_process_totals()) {
const ProcessMemoryTotals* totals = pmd->process_totals(); const ProcessMemoryTotals* totals = pmd->process_totals();
osDump->resident_set_kb = totals->resident_set_bytes() / 1024; osDump->resident_set_kb = totals->resident_set_bytes() / 1024;
osDump->platform_private_footprint = totals->GetPlatformPrivateFootprint();
} }
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/process/process_handle.h" #include "base/process/process_handle.h"
#include "base/trace_event/process_memory_totals.h"
namespace base { namespace base {
namespace trace_event { namespace trace_event {
...@@ -83,6 +84,7 @@ struct MemoryDumpArgs { ...@@ -83,6 +84,7 @@ struct MemoryDumpArgs {
struct BASE_EXPORT MemoryDumpCallbackResult { struct BASE_EXPORT MemoryDumpCallbackResult {
struct OSMemDump { struct OSMemDump {
uint32_t resident_set_kb = 0; uint32_t resident_set_kb = 0;
ProcessMemoryTotals::PlatformPrivateFootprint platform_private_footprint;
}; };
struct ChromeMemDump { struct ChromeMemDump {
uint32_t malloc_total_kb = 0; uint32_t malloc_total_kb = 0;
......
...@@ -52,6 +52,9 @@ class BASE_EXPORT ProcessMemoryTotals { ...@@ -52,6 +52,9 @@ class BASE_EXPORT ProcessMemoryTotals {
// On iOS, // On iOS,
// TBD: https://crbug.com/714961 // TBD: https://crbug.com/714961
}; };
const PlatformPrivateFootprint& GetPlatformPrivateFootprint() const {
return platform_private_footprint_;
}
PlatformPrivateFootprint& GetPlatformPrivateFootprint() { PlatformPrivateFootprint& GetPlatformPrivateFootprint() {
return platform_private_footprint_; return platform_private_footprint_;
} }
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
mojom = "//services/resource_coordinator/public/interfaces/memory/memory_instrumentation.mojom" mojom = "//services/resource_coordinator/public/interfaces/memory/memory_instrumentation.mojom"
public_headers = [ "//base/trace_event/memory_dump_request_args.h" ] public_headers = [
"//base/trace_event/memory_dump_request_args.h",
"//base/trace_event/process_memory_totals.h",
]
traits_headers = [ "//services/resource_coordinator/public/cpp/memory/memory_instrumentation_struct_traits.h" ] traits_headers = [ "//services/resource_coordinator/public/cpp/memory/memory_instrumentation_struct_traits.h" ]
deps = [ deps = [
"//base", "//base",
...@@ -13,6 +16,7 @@ type_mappings = [ ...@@ -13,6 +16,7 @@ type_mappings = [
"memory_instrumentation.mojom.DumpType=base::trace_event::MemoryDumpType", "memory_instrumentation.mojom.DumpType=base::trace_event::MemoryDumpType",
"memory_instrumentation.mojom.LevelOfDetail=base::trace_event::MemoryDumpLevelOfDetail", "memory_instrumentation.mojom.LevelOfDetail=base::trace_event::MemoryDumpLevelOfDetail",
"memory_instrumentation.mojom.RequestArgs=base::trace_event::MemoryDumpRequestArgs", "memory_instrumentation.mojom.RequestArgs=base::trace_event::MemoryDumpRequestArgs",
"memory_instrumentation.mojom.PlatformPrivateFootprint=base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint",
"memory_instrumentation.mojom.ChromeMemDump=base::trace_event::MemoryDumpCallbackResult::ChromeMemDump", "memory_instrumentation.mojom.ChromeMemDump=base::trace_event::MemoryDumpCallbackResult::ChromeMemDump",
"memory_instrumentation.mojom.OSMemDump=base::trace_event::MemoryDumpCallbackResult::OSMemDump", "memory_instrumentation.mojom.OSMemDump=base::trace_event::MemoryDumpCallbackResult::OSMemDump",
"memory_instrumentation.mojom.MemoryDumpCallbackResult=base::trace_event::MemoryDumpCallbackResult", "memory_instrumentation.mojom.MemoryDumpCallbackResult=base::trace_event::MemoryDumpCallbackResult",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "services/resource_coordinator/public/cpp/memory/memory_instrumentation_struct_traits.h" #include "services/resource_coordinator/public/cpp/memory/memory_instrumentation_struct_traits.h"
#include "base/trace_event/memory_dump_request_args.h" #include "base/trace_event/memory_dump_request_args.h"
#include "base/trace_event/process_memory_totals.h"
#include "mojo/common/common_custom_types_struct_traits.h" #include "mojo/common/common_custom_types_struct_traits.h"
#include "services/resource_coordinator/public/interfaces/memory/memory_instrumentation.mojom.h" #include "services/resource_coordinator/public/interfaces/memory/memory_instrumentation.mojom.h"
...@@ -110,6 +111,21 @@ bool StructTraits<memory_instrumentation::mojom::RequestArgsDataView, ...@@ -110,6 +111,21 @@ bool StructTraits<memory_instrumentation::mojom::RequestArgsDataView,
return true; return true;
} }
// static
bool StructTraits<
memory_instrumentation::mojom::PlatformPrivateFootprintDataView,
base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint>::
Read(
memory_instrumentation::mojom::PlatformPrivateFootprintDataView input,
base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint* out) {
out->phys_footprint_bytes = input.phys_footprint_bytes();
out->internal_bytes = input.internal_bytes();
out->compressed_bytes = input.compressed_bytes();
out->rss_anon_bytes = input.rss_anon_bytes();
out->vm_swap_bytes = input.vm_swap_bytes();
return true;
}
// static // static
bool StructTraits<memory_instrumentation::mojom::ChromeMemDumpDataView, bool StructTraits<memory_instrumentation::mojom::ChromeMemDumpDataView,
base::trace_event::MemoryDumpCallbackResult::ChromeMemDump>:: base::trace_event::MemoryDumpCallbackResult::ChromeMemDump>::
...@@ -128,6 +144,8 @@ bool StructTraits<memory_instrumentation::mojom::OSMemDumpDataView, ...@@ -128,6 +144,8 @@ bool StructTraits<memory_instrumentation::mojom::OSMemDumpDataView,
Read(memory_instrumentation::mojom::OSMemDumpDataView input, Read(memory_instrumentation::mojom::OSMemDumpDataView input,
base::trace_event::MemoryDumpCallbackResult::OSMemDump* out) { base::trace_event::MemoryDumpCallbackResult::OSMemDump* out) {
out->resident_set_kb = input.resident_set_kb(); out->resident_set_kb = input.resident_set_kb();
if (!input.ReadPlatformPrivateFootprint(&out->platform_private_footprint))
return false;
return true; return true;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/process/process_handle.h" #include "base/process/process_handle.h"
#include "base/trace_event/memory_dump_request_args.h" #include "base/trace_event/memory_dump_request_args.h"
#include "base/trace_event/process_memory_totals.h"
#include "mojo/common/common_custom_types_struct_traits.h" #include "mojo/common/common_custom_types_struct_traits.h"
#include "services/resource_coordinator/public/cpp/memory/memory_export.h" #include "services/resource_coordinator/public/cpp/memory/memory_export.h"
#include "services/resource_coordinator/public/interfaces/memory/memory_instrumentation.mojom.h" #include "services/resource_coordinator/public/interfaces/memory/memory_instrumentation.mojom.h"
...@@ -53,6 +54,40 @@ struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT ...@@ -53,6 +54,40 @@ struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT
base::trace_event::MemoryDumpRequestArgs* out); base::trace_event::MemoryDumpRequestArgs* out);
}; };
template <>
struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT StructTraits<
memory_instrumentation::mojom::PlatformPrivateFootprintDataView,
base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint> {
static uint64_t phys_footprint_bytes(
const base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint&
args) {
return args.phys_footprint_bytes;
}
static uint64_t internal_bytes(
const base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint&
args) {
return args.internal_bytes;
}
static uint64_t compressed_bytes(
const base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint&
args) {
return args.compressed_bytes;
}
static uint64_t rss_anon_bytes(
const base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint&
args) {
return args.rss_anon_bytes;
}
static uint64_t vm_swap_bytes(
const base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint&
args) {
return args.vm_swap_bytes;
}
static bool Read(
memory_instrumentation::mojom::PlatformPrivateFootprintDataView input,
base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint* out);
};
template <> template <>
struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT
StructTraits<memory_instrumentation::mojom::ChromeMemDumpDataView, StructTraits<memory_instrumentation::mojom::ChromeMemDumpDataView,
...@@ -86,6 +121,11 @@ struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT ...@@ -86,6 +121,11 @@ struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT
const base::trace_event::MemoryDumpCallbackResult::OSMemDump& args) { const base::trace_event::MemoryDumpCallbackResult::OSMemDump& args) {
return args.resident_set_kb; return args.resident_set_kb;
} }
static base::trace_event::ProcessMemoryTotals::PlatformPrivateFootprint
platform_private_footprint(
const base::trace_event::MemoryDumpCallbackResult::OSMemDump& args) {
return args.platform_private_footprint;
}
static bool Read(memory_instrumentation::mojom::OSMemDumpDataView input, static bool Read(memory_instrumentation::mojom::OSMemDumpDataView input,
base::trace_event::MemoryDumpCallbackResult::OSMemDump* out); base::trace_event::MemoryDumpCallbackResult::OSMemDump* out);
}; };
......
...@@ -25,8 +25,17 @@ struct RequestArgs { ...@@ -25,8 +25,17 @@ struct RequestArgs {
LevelOfDetail level_of_detail; LevelOfDetail level_of_detail;
}; };
struct PlatformPrivateFootprint {
uint64 phys_footprint_bytes = 0;
uint64 internal_bytes = 0;
uint64 compressed_bytes = 0;
uint64 rss_anon_bytes = 0;
uint64 vm_swap_bytes = 0;
};
struct OSMemDump { struct OSMemDump {
uint32 resident_set_kb = 0; uint32 resident_set_kb = 0;
PlatformPrivateFootprint platform_private_footprint;
}; };
struct ChromeMemDump { struct ChromeMemDump {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment