RESTRICT AUTOMERGE: Disable file compaction by default
At present time kernel does not support shared pages to be
swapped using file compaction which uses MADV_COLD and most
of the file pages in a process are actually shared mappings
causing us to waste a lot of cycles scanning through a lot
of unreclaimable pages, this patch disables file compaction
which will be reenabled until a solution is implemented on
upstream kernel that allows reclaiming shared pages, thus
making it worth to scan all of those pages again.
Test: am compact file <processname> <uid>
Bug: 265473345
Change-Id: I4c819058da229c00d1eafea636f89784718adc5f
(cherry picked from commit 30b069612a)
This commit is contained in:
@@ -110,6 +110,8 @@ public final class CachedAppOptimizer {
|
|||||||
|
|
||||||
private static final String ATRACE_COMPACTION_TRACK = "Compaction";
|
private static final String ATRACE_COMPACTION_TRACK = "Compaction";
|
||||||
|
|
||||||
|
@VisibleForTesting static final boolean ENABLE_FILE_COMPACT = false;
|
||||||
|
|
||||||
// Defaults for phenotype flags.
|
// Defaults for phenotype flags.
|
||||||
@VisibleForTesting static final Boolean DEFAULT_USE_COMPACTION = false;
|
@VisibleForTesting static final Boolean DEFAULT_USE_COMPACTION = false;
|
||||||
@VisibleForTesting static final Boolean DEFAULT_USE_FREEZER = true;
|
@VisibleForTesting static final Boolean DEFAULT_USE_FREEZER = true;
|
||||||
@@ -515,9 +517,11 @@ public final class CachedAppOptimizer {
|
|||||||
|
|
||||||
@GuardedBy("mProcLock")
|
@GuardedBy("mProcLock")
|
||||||
void compactAppSome(ProcessRecord app, boolean force) {
|
void compactAppSome(ProcessRecord app, boolean force) {
|
||||||
app.mOptRecord.setReqCompactAction(COMPACT_PROCESS_SOME);
|
if (ENABLE_FILE_COMPACT) {
|
||||||
++mSomeCompactRequest;
|
app.mOptRecord.setReqCompactAction(COMPACT_PROCESS_SOME);
|
||||||
compactApp(app, force, "some");
|
++mSomeCompactRequest;
|
||||||
|
compactApp(app, force, "some");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method returns true only if requirements are met. Note, that requirements are different
|
// This method returns true only if requirements are met. Note, that requirements are different
|
||||||
@@ -1278,6 +1282,15 @@ public final class CachedAppOptimizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ENABLE_FILE_COMPACT) {
|
||||||
|
// Turn off file compaction
|
||||||
|
if (resolvedAction == COMPACT_ACTION_FULL) {
|
||||||
|
resolvedAction = COMPACT_ACTION_ANON;
|
||||||
|
} else if (resolvedAction == COMPACT_ACTION_FILE) {
|
||||||
|
resolvedAction = COMPACT_ACTION_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return resolvedAction;
|
return resolvedAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1545,6 +1558,9 @@ public final class CachedAppOptimizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int resolvedAction = resolveCompactionAction(requestedAction);
|
int resolvedAction = resolveCompactionAction(requestedAction);
|
||||||
|
if (resolvedAction == COMPACT_ACTION_NONE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
action = compactActionIntToString(resolvedAction);
|
action = compactActionIntToString(resolvedAction);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1079,14 +1079,16 @@ public final class CachedAppOptimizerTest {
|
|||||||
|
|
||||||
mCachedAppOptimizerUnderTest.mLastCompactionStats.clear();
|
mCachedAppOptimizerUnderTest.mLastCompactionStats.clear();
|
||||||
|
|
||||||
// We force a some compaction
|
if (CachedAppOptimizer.ENABLE_FILE_COMPACT) {
|
||||||
mCachedAppOptimizerUnderTest.compactAppSome(processRecord, true);
|
// We force a some compaction
|
||||||
waitForHandler();
|
mCachedAppOptimizerUnderTest.compactAppSome(processRecord, true);
|
||||||
// then process is compacted.
|
waitForHandler();
|
||||||
String executedCompactAction =
|
// then process is compacted.
|
||||||
|
String executedCompactAction =
|
||||||
compactActionIntToString(processRecord.mOptRecord.getLastCompactAction());
|
compactActionIntToString(processRecord.mOptRecord.getLastCompactAction());
|
||||||
assertThat(executedCompactAction)
|
assertThat(executedCompactAction)
|
||||||
.isEqualTo(mCachedAppOptimizerUnderTest.mCompactActionSome);
|
.isEqualTo(mCachedAppOptimizerUnderTest.mCompactActionSome);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFlag(String key, String value, boolean defaultValue) throws Exception {
|
private void setFlag(String key, String value, boolean defaultValue) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user