summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShashi Shekar Shankar <ssbang@codeaurora.org>2015-01-05 17:40:39 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:27:49 -0600
commit4734ae78e403ed7cecf427351961ec59a523ab69 (patch)
treeb0317147f77cbf68d770574e21d06523aba82f11
parente3c2f2356e4b7a16e9bb5fd88e6361230d74d6c9 (diff)
downloadframeworks_base-4734ae78e403ed7cecf427351961ec59a523ab69.zip
frameworks_base-4734ae78e403ed7cecf427351961ec59a523ab69.tar.gz
frameworks_base-4734ae78e403ed7cecf427351961ec59a523ab69.tar.bz2
Performance: Enable Aggressive trim settings
This change will enable aggressive trim settings for targets up to 1GB. The change can be turned on/off from system properties. By default, the properties are set for targets up to 1GB. CRs-Fixed: 783020 Change-Id: I233dddbff07e7ec1fe2ee96402fe1d411903beb5
-rw-r--r--services/core/java/com/android/server/am/ProcessList.java35
1 files changed, 32 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 3a7fee0..6506cf6 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -32,6 +32,7 @@ import com.android.server.wm.WindowManagerService;
import android.content.res.Resources;
import android.graphics.Point;
import android.os.SystemProperties;
+import android.os.Process;
import android.net.LocalSocketAddress;
import android.net.LocalSocket;
import android.util.Slog;
@@ -134,6 +135,16 @@ final class ProcessList {
// processes and the number of those processes does not count against the cached
// process limit.
static final int MAX_CACHED_APPS = SystemProperties.getInt("ro.sys.fw.bg_apps_limit",32);
+ static final boolean USE_TRIM_SETTINGS =
+ SystemProperties.getBoolean("ro.sys.fw.use_trim_settings",true);
+ static final int EMPTY_APP_PERCENT = SystemProperties.getInt("ro.sys.fw.empty_app_percent",50);
+ static final int TRIM_EMPTY_PERCENT =
+ SystemProperties.getInt("ro.sys.fw.trim_empty_percent",100);
+ static final int TRIM_CACHE_PERCENT =
+ SystemProperties.getInt("ro.sys.fw.trim_cache_percent",100);
+ static final long TRIM_ENABLE_MEMORY =
+ SystemProperties.getLong("ro.sys.fw.trim_enable_memory",1073741824);
+ public static boolean allowTrim() { return Process.getTotalMemory() < TRIM_ENABLE_MEMORY ; }
// We allow empty processes to stick around for at most 30 minutes.
static final long MAX_EMPTY_TIME = 30*60*1000;
@@ -143,11 +154,25 @@ final class ProcessList {
// The number of empty apps at which we don't consider it necessary to do
// memory trimming.
- static final int TRIM_EMPTY_APPS = MAX_EMPTY_APPS/2;
+ public static int computeTrimEmptyApps() {
+ if (USE_TRIM_SETTINGS && allowTrim()) {
+ return MAX_EMPTY_APPS*TRIM_EMPTY_PERCENT/100;
+ } else {
+ return MAX_EMPTY_APPS/2;
+ }
+ }
+ static final int TRIM_EMPTY_APPS = computeTrimEmptyApps();
// The number of cached at which we don't consider it necessary to do
// memory trimming.
- static final int TRIM_CACHED_APPS = (MAX_CACHED_APPS-MAX_EMPTY_APPS)/3;
+ public static int computeTrimCachedApps() {
+ if (USE_TRIM_SETTINGS && allowTrim()) {
+ return MAX_CACHED_APPS*TRIM_CACHE_PERCENT/100;
+ } else {
+ return (MAX_CACHED_APPS-MAX_EMPTY_APPS)/3;
+ }
+ }
+ static final int TRIM_CACHED_APPS = computeTrimCachedApps();
// Threshold of number of cached+empty where we consider memory critical.
static final int TRIM_CRITICAL_THRESHOLD = 3;
@@ -308,7 +333,11 @@ final class ProcessList {
}
public static int computeEmptyProcessLimit(int totalProcessLimit) {
- return totalProcessLimit/2;
+ if(USE_TRIM_SETTINGS && allowTrim()) {
+ return totalProcessLimit*EMPTY_APP_PERCENT/100;
+ } else {
+ return totalProcessLimit/2;
+ }
}
private static String buildOomTag(String prefix, String space, int val, int base) {