summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-12-10 10:33:27 -0800
committerDianne Hackborn <hackbod@google.com>2014-12-10 10:33:27 -0800
commitae6cc8af2674909924fb18cb73763a110bee63dd (patch)
tree6bdea4b73aeefb404e8a9bd9b7566dd53fe92b64
parent5a267e72b2e26bd55fa7e7123587e9987dc6415a (diff)
downloadframeworks_base-ae6cc8af2674909924fb18cb73763a110bee63dd.zip
frameworks_base-ae6cc8af2674909924fb18cb73763a110bee63dd.tar.gz
frameworks_base-ae6cc8af2674909924fb18cb73763a110bee63dd.tar.bz2
Further work on issue #18640385: Add procstats test mode
Tune sampling periods: - Lower minimum sample interval when in test mode. - Add a check when sampling pss to make sure this is at least 1 second since the pss changed, to reduce the amount of bad data (very small pss samples) that we see. Change-Id: I624a7d0480f3f6b22d229744e028d13a2c7b0e89
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityManagerService.java7
-rw-r--r--services/core/java/com/android/server/am/ProcessList.java12
2 files changed, 16 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 1227148..82afeed 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1841,7 +1841,9 @@ public final class ActivityManagerService extends ActivityManagerNative
proc = mPendingPssProcesses.remove(0);
procState = proc.pssProcState;
lastPssTime = proc.lastPssTime;
- if (proc.thread != null && procState == proc.setProcState) {
+ if (proc.thread != null && procState == proc.setProcState
+ && (lastPssTime+ProcessList.PSS_SAFE_TIME_FROM_STATE_CHANGE)
+ < SystemClock.uptimeMillis()) {
pid = proc.pid;
} else {
proc = null;
@@ -17746,7 +17748,8 @@ public final class ActivityManagerService extends ActivityManagerNative
+ (app.nextPssTime-now) + ": " + app);
} else {
if (now > app.nextPssTime || (now > (app.lastPssTime+ProcessList.PSS_MAX_INTERVAL)
- && now > (app.lastStateTime+ProcessList.PSS_MIN_TIME_FROM_STATE_CHANGE))) {
+ && now > (app.lastStateTime+ProcessList.minTimeFromStateChange(
+ mTestPssMode)))) {
requestPssLocked(app, app.setProcState);
app.nextPssTime = ProcessList.computeNextPssTime(app.curProcState, false,
mTestPssMode, isSleeping(), now);
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index aa86786..4ac6684 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -411,7 +411,10 @@ final class ProcessList {
sb.append(ramKb);
}
- // The minimum amount of time after a state change it is safe ro collect PSS.
+ // How long after a state change that it is safe to collect PSS without it being dirty.
+ public static final int PSS_SAFE_TIME_FROM_STATE_CHANGE = 1000;
+
+ // The minimum time interval after a state change it is safe to collect PSS.
public static final int PSS_MIN_TIME_FROM_STATE_CHANGE = 15*1000;
// The maximum amount of time we want to go between PSS collections.
@@ -441,6 +444,9 @@ final class ProcessList {
// The amount of time until PSS when a cached process stays in the same state.
private static final int PSS_SAME_CACHED_INTERVAL = 30*60*1000;
+ // The minimum time interval after a state change it is safe to collect PSS.
+ public static final int PSS_TEST_MIN_TIME_FROM_STATE_CHANGE = 10*1000;
+
// The amount of time during testing until PSS when a process first becomes top.
private static final int PSS_TEST_FIRST_TOP_INTERVAL = 3*1000;
@@ -548,6 +554,10 @@ final class ProcessList {
return sProcStateToProcMem[procState1] != sProcStateToProcMem[procState2];
}
+ public static long minTimeFromStateChange(boolean test) {
+ return test ? PSS_TEST_MIN_TIME_FROM_STATE_CHANGE : PSS_MIN_TIME_FROM_STATE_CHANGE;
+ }
+
public static long computeNextPssTime(int procState, boolean first, boolean test,
boolean sleeping, long now) {
final long[] table = test