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

Unified Diff: base/process/process_metrics_mac.cc

Issue 2832933003: Add the UMA metric Memory.Gpu.PhysicalFootprint.MacOS (Closed)
Patch Set: Comments from mark. Created 3 years, 8 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/process/process_metrics.h ('k') | chrome/browser/memory_details.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_metrics_mac.cc
diff --git a/base/process/process_metrics_mac.cc b/base/process/process_metrics_mac.cc
index be4107e22322cd0f37bd1927649169e070c38271..1481f7717f4a2b2fb490063d80a66b0da12db2cf 100644
--- a/base/process/process_metrics_mac.cc
+++ b/base/process/process_metrics_mac.cc
@@ -13,6 +13,7 @@
#include "base/containers/hash_tables.h"
#include "base/logging.h"
+#include "base/mac/mac_util.h"
#include "base/mac/mach_logging.h"
#include "base/mac/scoped_mach_port.h"
#include "base/memory/ptr_util.h"
@@ -23,6 +24,38 @@ namespace base {
namespace {
+#if !defined(MAC_OS_X_VERSION_10_11) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11
+// The |phys_footprint| field was introduced in 10.11.
+struct ChromeTaskVMInfo {
+ mach_vm_size_t virtual_size;
+ integer_t region_count;
+ integer_t page_size;
+ mach_vm_size_t resident_size;
+ mach_vm_size_t resident_size_peak;
+ mach_vm_size_t device;
+ mach_vm_size_t device_peak;
+ mach_vm_size_t internal;
+ mach_vm_size_t internal_peak;
+ mach_vm_size_t external;
+ mach_vm_size_t external_peak;
+ mach_vm_size_t reusable;
+ mach_vm_size_t reusable_peak;
+ mach_vm_size_t purgeable_volatile_pmap;
+ mach_vm_size_t purgeable_volatile_resident;
+ mach_vm_size_t purgeable_volatile_virtual;
+ mach_vm_size_t compressed;
+ mach_vm_size_t compressed_peak;
+ mach_vm_size_t compressed_lifetime;
+ mach_vm_size_t phys_footprint;
+};
+mach_msg_type_number_t ChromeTaskVMInfoCount =
+ sizeof(ChromeTaskVMInfo) / sizeof(natural_t);
+#else
+using ChromeTaskVMInfo = task_vm_info;
+mach_msg_type_number_t ChromeTaskVMInfoCount = TASK_VM_INFO_REV1_COUNT;
+#endif // MAC_OS_X_VERSION_10_11
+
bool GetTaskInfo(mach_port_t task, task_basic_info_64* task_info_data) {
if (task == MACH_PORT_NULL)
return false;
@@ -290,6 +323,20 @@ bool ProcessMetrics::GetCommittedAndWorkingSetKBytes(
return true;
}
+size_t ProcessMetrics::GetPhysicalFootprint() const {
+ if (mac::IsAtMostOS10_10())
+ return 0;
+
+ ChromeTaskVMInfo task_vm_info;
+ mach_msg_type_number_t count = ChromeTaskVMInfoCount;
+ kern_return_t result =
+ task_info(TaskForPid(process_), TASK_VM_INFO,
+ reinterpret_cast<task_info_t>(&task_vm_info), &count);
+ if (result != KERN_SUCCESS)
+ return 0;
+ return task_vm_info.phys_footprint;
+}
+
#define TIME_VALUE_TO_TIMEVAL(a, r) do { \
(r)->tv_sec = (a)->seconds; \
(r)->tv_usec = (a)->microseconds; \
« no previous file with comments | « base/process/process_metrics.h ('k') | chrome/browser/memory_details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698