Monitor swap
Pull value of VmSwap from /proc/PID/status when capturing
ProcessMemoryState atom.
Before change:
(average pull time nanos) 43355896
(max pull time nanos) 75649278
After change:
(average pull time nanos) 86307073
(max pull time nanos) 151681474
Delta: 2x increase
Pulling frequency is controled via statsd and we trade-off more
expensive reads for more actionable data (helping detect memory leaks).
Bug: 130624561
Test: atest MemoryStatUtilTest
Test: benchmark pulling ProcessMemoryState atom
Test: manually take a statsd report
Change-Id: I1d90563b70b5253b3d31ddab4810db870620c4d4
(cherry picked from commit 65a9b7122ada9db7a95cdfe31fa97b328bd04a06)
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index cc15a7a..12474ce 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -3804,7 +3804,7 @@
// SWAP
// Value is read from memory.stat, field total_swap if per-app memory
- // cgroups are enabled. Otherwise, 0.
+ // cgroups are enabled. Otherwise, VmSwap from /proc/PID/status.
optional int64 swap_in_bytes = 8;
// Deprecated: use ProcessMemoryHighWaterMark atom instead. Always 0.
@@ -3844,6 +3844,10 @@
// Elapsed real time when the process started.
// Value is read from /proc/PID/stat, field 22.
optional int64 start_time_nanos = 7;
+
+ // SWAP
+ // Value read from /proc/PID/status, field VmSwap.
+ optional int64 swap_in_bytes = 8;
}
/*
diff --git a/cmds/statsd/src/external/StatsPullerManager.cpp b/cmds/statsd/src/external/StatsPullerManager.cpp
index ca73059..2ffe18e 100644
--- a/cmds/statsd/src/external/StatsPullerManager.cpp
+++ b/cmds/statsd/src/external/StatsPullerManager.cpp
@@ -146,7 +146,7 @@
.puller = new StatsCompanionServicePuller(android::util::PROCESS_MEMORY_STATE)}},
// native_process_memory_state
{android::util::NATIVE_PROCESS_MEMORY_STATE,
- {.additiveFields = {3, 4, 5, 6},
+ {.additiveFields = {3, 4, 5, 6, 8},
.puller = new StatsCompanionServicePuller(android::util::NATIVE_PROCESS_MEMORY_STATE)}},
// process_memory_high_water_mark
{android::util::PROCESS_MEMORY_HIGH_WATER_MARK,