From 7f4d90343c6b3799ddbd1f1d5c854bd14f49464e Mon Sep 17 00:00:00 2001 From: Edgar Arriaga Date: Wed, 11 May 2022 18:32:19 -0700 Subject: [PATCH] Avoid full compaction when apps move within Cached bucket This patch reduces the amount of times we trigger full compactions that currently happen at any OOM adjust change when the app is within the Cached state bucket as it was identified that there were many instances of this situation. Bug: 232311101 Test: Checked that the number of full compactions went down in dumpsys activity Change-Id: If4995432cbf770227ebd60dad2889522d98b103d --- .../core/java/com/android/server/am/CachedAppOptimizer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/am/CachedAppOptimizer.java b/services/core/java/com/android/server/am/CachedAppOptimizer.java index 53777ef95c31c..c88d82cf0cf2c 100644 --- a/services/core/java/com/android/server/am/CachedAppOptimizer.java +++ b/services/core/java/com/android/server/am/CachedAppOptimizer.java @@ -1235,7 +1235,8 @@ public final class CachedAppOptimizer { && (newAdj == ProcessList.PREVIOUS_APP_ADJ || newAdj == ProcessList.HOME_APP_ADJ)) { // Perform a minor compaction when a perceptible app becomes the prev/home app compactAppSome(app, false); - } else if (newAdj >= ProcessList.CACHED_APP_MIN_ADJ + } else if (oldAdj < ProcessList.CACHED_APP_MIN_ADJ + && newAdj >= ProcessList.CACHED_APP_MIN_ADJ && newAdj <= ProcessList.CACHED_APP_MAX_ADJ) { // Perform a major compaction when any app enters cached compactAppFull(app, false);