Add ProcessMemoryHighWaterMark atom
Collection of the RSS high-water mark is moved to a separate atom to
improve performance, increase flexibility and overcome security
constrainsts.
Performance: avoid reading /proc/pid/status in ProcessMemoryState;
flexibility: allow pulling RSS high-water mark on a different schedule;
security: add single point where we can trigger the high-water mark
reset.
The RSS high-water mark will be removed from ProcessMemoryState and
NativeProcessMemoryState atoms in a followup-up CL to ensure that the
collected data is continuous.
Bug: 119598534
Test: atest UidAtomTests#testProcessMemoryHighWaterMark
Change-Id: I52da7b5e695f771f1551e1f6a6a773bded4504d1
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 9757f32..726abe2 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -159,7 +159,7 @@
}
// Pulled events will start at field 10000.
- // Next: 10038
+ // Next: 10043
oneof pulled {
WifiBytesTransfer wifi_bytes_transfer = 10000;
WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001;
@@ -203,6 +203,7 @@
DeviceCalculatedPowerUse device_calculated_power_use = 10039;
DeviceCalculatedPowerBlameUid device_calculated_power_blame_uid = 10040;
DeviceCalculatedPowerBlameOther device_calculated_power_blame_other = 10041;
+ ProcessMemoryHighWaterMark process_memory_high_water_mark = 10042;
}
// DO NOT USE field numbers above 100,000 in AOSP.
@@ -2529,7 +2530,8 @@
// RSS high watermark.
// Peak RSS usage of the process. Value is read from the VmHWM field in /proc/PID/status or
// from memory.max_usage_in_bytes under /dev/memcg if the device uses per-app memory cgroups.
- optional int64 rss_high_watermark_in_bytes = 9;
+ // Deprecated: use ProcessMemoryHighWaterMark atom instead.
+ optional int64 rss_high_watermark_in_bytes = 9 [deprecated = true];
// Elapsed real time when the process started.
// Value is read from /proc/PID/stat, field 22. 0 if read from per-app memory cgroups.
@@ -2557,7 +2559,8 @@
// RSS high watermark.
// Peak RSS usage of the process. Value is read from the VmHWM field in /proc/PID/status.
- optional int64 rss_high_watermark_in_bytes = 6;
+ // Deprecated: use ProcessMemoryHighWaterMark atom instead.
+ optional int64 rss_high_watermark_in_bytes = 6 [deprecated = true];
// Elapsed real time when the process started.
// Value is read from /proc/PID/stat, field 22.
@@ -2565,6 +2568,22 @@
}
/*
+ * Logs the memory high-water mark for a process.
+ * Recorded in ActivityManagerService.
+ */
+message ProcessMemoryHighWaterMark {
+ // The uid if available. -1 means not available.
+ optional int32 uid = 1 [(is_uid) = true];
+
+ // The process name. Provided by ActivityManagerService or read from /proc/PID/cmdline.
+ optional string process_name = 2;
+
+ // RSS high-water mark. Peak RSS usage of the process. Read from the VmHWM field in
+ // /proc/PID/status.
+ optional int64 rss_high_water_mark_in_bytes = 3;
+}
+
+/*
* Elapsed real time from SystemClock.
*/
message SystemElapsedRealtime {
@@ -3349,4 +3368,4 @@
// Power used by this item in mAh, as computed by BatteryStats, since BatteryStats last reset
// (i.e. roughly since device was last significantly charged).
optional float power_milli_amp_hours = 2;
-}
\ No newline at end of file
+}