Commit 4abfe94b authored by erikchen's avatar erikchen Committed by Commit bot

Add experimental private memory footprint metrics for macOS.

These metrics are temporary and are intended to be removed once the same metrics
are emitted by the memory instrumentation service.

BUG=720541

Review-Url: https://codereview.chromium.org/2875823004
Cr-Commit-Position: refs/heads/master@{#471107}
parent 6566c8ac
...@@ -97,7 +97,8 @@ ProcessMemoryInformation::ProcessMemoryInformation() ...@@ -97,7 +97,8 @@ ProcessMemoryInformation::ProcessMemoryInformation()
num_open_fds(-1), num_open_fds(-1),
open_fds_soft_limit(-1), open_fds_soft_limit(-1),
renderer_type(RENDERER_UNKNOWN), renderer_type(RENDERER_UNKNOWN),
phys_footprint(0) {} phys_footprint(0),
private_memory_footprint(0) {}
ProcessMemoryInformation::ProcessMemoryInformation( ProcessMemoryInformation::ProcessMemoryInformation(
const ProcessMemoryInformation& other) = default; const ProcessMemoryInformation& other) = default;
......
...@@ -72,6 +72,9 @@ struct ProcessMemoryInformation { ...@@ -72,6 +72,9 @@ struct ProcessMemoryInformation {
// The physical footprint is a macOS concept that tracks anonymous, // The physical footprint is a macOS concept that tracks anonymous,
// non-discardable memory. // non-discardable memory.
size_t phys_footprint; size_t phys_footprint;
// TODO(erikchen): Remove this temporary estimate for private memory once the
// memory infra service emits the same metric. https://crbug.com/720541.
size_t private_memory_footprint;
}; };
typedef std::vector<ProcessMemoryInformation> ProcessMemoryInformationList; typedef std::vector<ProcessMemoryInformation> ProcessMemoryInformationList;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/file_version_info.h" #include "base/file_version_info.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/process/process_iterator.h" #include "base/process/process_iterator.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -62,7 +63,16 @@ void CollectProcessDataForChromeProcess( ...@@ -62,7 +63,16 @@ void CollectProcessDataForChromeProcess(
base::ProcessMetrics::CreateProcessMetrics( base::ProcessMetrics::CreateProcessMetrics(
pid, content::BrowserChildProcessHost::GetPortProvider()); pid, content::BrowserChildProcessHost::GetPortProvider());
metrics->GetCommittedAndWorkingSetKBytes(&info.committed, &info.working_set); metrics->GetCommittedAndWorkingSetKBytes(&info.committed, &info.working_set);
info.phys_footprint = metrics->GetTaskVMInfo().phys_footprint; base::ProcessMetrics::TaskVMInfo vm_info = metrics->GetTaskVMInfo();
info.phys_footprint = vm_info.phys_footprint;
// TODO(erikchen): Remove this temporary estimate for private memory once the
// memory infra service emits the same metric. https://crbug.com/720541.
if (base::mac::IsAtLeastOS10_12()) {
info.private_memory_footprint = vm_info.phys_footprint;
} else {
info.private_memory_footprint = vm_info.internal + vm_info.compressed;
}
processes->push_back(info); processes->push_back(info);
} }
......
...@@ -108,6 +108,11 @@ void MetricsMemoryDetails::UpdateHistograms() { ...@@ -108,6 +108,11 @@ void MetricsMemoryDetails::UpdateHistograms() {
UMA_HISTOGRAM_COUNTS_10000("Memory.Browser.OpenFDsSoftLimit", UMA_HISTOGRAM_COUNTS_10000("Memory.Browser.OpenFDsSoftLimit",
open_fds_soft_limit); open_fds_soft_limit);
} }
#if defined(OS_MACOSX)
UMA_HISTOGRAM_MEMORY_LARGE_MB(
"Memory.Experimental.Browser.PrivateMemoryFootprint.MacOS",
browser.processes[index].private_memory_footprint / 1024 / 1024);
#endif
continue; continue;
case content::PROCESS_TYPE_RENDERER: { case content::PROCESS_TYPE_RENDERER: {
UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.RendererAll", sample / 1024); UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.RendererAll", sample / 1024);
...@@ -129,6 +134,12 @@ void MetricsMemoryDetails::UpdateHistograms() { ...@@ -129,6 +134,12 @@ void MetricsMemoryDetails::UpdateHistograms() {
num_open_fds); num_open_fds);
} }
extension_count++; extension_count++;
#if defined(OS_MACOSX)
UMA_HISTOGRAM_MEMORY_LARGE_MB(
"Memory.Experimental.Extension.PrivateMemoryFootprint.MacOS",
browser.processes[index].private_memory_footprint / 1024 /
1024);
#endif
continue; continue;
case ProcessMemoryInformation::RENDERER_CHROME: case ProcessMemoryInformation::RENDERER_CHROME:
UMA_HISTOGRAM_MEMORY_KB("Memory.Chrome", sample); UMA_HISTOGRAM_MEMORY_KB("Memory.Chrome", sample);
...@@ -141,6 +152,12 @@ void MetricsMemoryDetails::UpdateHistograms() { ...@@ -141,6 +152,12 @@ void MetricsMemoryDetails::UpdateHistograms() {
continue; continue;
case ProcessMemoryInformation::RENDERER_NORMAL: case ProcessMemoryInformation::RENDERER_NORMAL:
default: default:
#if defined(OS_MACOSX)
UMA_HISTOGRAM_MEMORY_LARGE_MB(
"Memory.Experimental.Renderer.PrivateMemoryFootprint.MacOS",
browser.processes[index].private_memory_footprint / 1024 /
1024);
#endif
// TODO(erikkay): Should we bother splitting out the other subtypes? // TODO(erikkay): Should we bother splitting out the other subtypes?
UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Renderer.Large2", UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Renderer.Large2",
sample / 1024); sample / 1024);
...@@ -182,6 +199,9 @@ void MetricsMemoryDetails::UpdateHistograms() { ...@@ -182,6 +199,9 @@ void MetricsMemoryDetails::UpdateHistograms() {
"Memory.Experimental.Gpu.PhysicalFootprint.MacOS", "Memory.Experimental.Gpu.PhysicalFootprint.MacOS",
browser.processes[index].phys_footprint / 1024 / 1024); browser.processes[index].phys_footprint / 1024 / 1024);
} }
UMA_HISTOGRAM_MEMORY_LARGE_MB(
"Memory.Experimental.Gpu.PrivateMemoryFootprint.MacOS",
browser.processes[index].private_memory_footprint / 1024 / 1024);
#endif #endif
UMA_HISTOGRAM_MEMORY_KB("Memory.Gpu", sample); UMA_HISTOGRAM_MEMORY_KB("Memory.Gpu", sample);
if (num_open_fds != -1 && open_fds_soft_limit != -1) { if (num_open_fds != -1 && open_fds_soft_limit != -1) {
......
...@@ -29594,6 +29594,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -29594,6 +29594,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Memory.Experimental.Browser.PrivateMemoryFootprint.MacOS"
units="MB">
<owner>erikchen@chromium.org</owner>
<summary>
A rough estimate of the private memory footprint of the browser process.
</summary>
</histogram>
<histogram name="Memory.Experimental.Browser.PurgedMemory" units="MB"> <histogram name="Memory.Experimental.Browser.PurgedMemory" units="MB">
<owner>bashi@chromium.org</owner> <owner>bashi@chromium.org</owner>
<summary> <summary>
...@@ -29620,6 +29628,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -29620,6 +29628,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Memory.Experimental.Extension.PrivateMemoryFootprint.MacOS"
units="MB">
<owner>erikchen@chromium.org</owner>
<summary>
A rough estimate of the private memory footprint of an extension process.
</summary>
</histogram>
<histogram name="Memory.Experimental.Gpu.PhysicalFootprint.MacOS" units="MB"> <histogram name="Memory.Experimental.Gpu.PhysicalFootprint.MacOS" units="MB">
<owner>erikchen@chromium.org</owner> <owner>erikchen@chromium.org</owner>
<summary> <summary>
...@@ -29630,6 +29646,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -29630,6 +29646,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Memory.Experimental.Gpu.PrivateMemoryFootprint.MacOS"
units="MB">
<owner>erikchen@chromium.org</owner>
<summary>
A rough estimate of the private memory footprint of the GPU process.
</summary>
</histogram>
<histogram base="true" name="Memory.Experimental.Renderer" units="MB"> <histogram base="true" name="Memory.Experimental.Renderer" units="MB">
<!-- Name completed by histogram_suffixes name="RendererMemoryAllocator" --> <!-- Name completed by histogram_suffixes name="RendererMemoryAllocator" -->
...@@ -29646,6 +29670,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -29646,6 +29670,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Memory.Experimental.Renderer.PrivateMemoryFootprint.MacOS"
units="MB">
<owner>erikchen@chromium.org</owner>
<summary>
A rough estimate of the private memory footprint of a renderer process.
</summary>
</histogram>
<histogram name="Memory.Experimental.Renderer.PurgedMemory" units="MB"> <histogram name="Memory.Experimental.Renderer.PurgedMemory" units="MB">
<owner>bashi@chromium.org</owner> <owner>bashi@chromium.org</owner>
<summary> <summary>
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