Add some trace points to compaction batches and cancellation
Adding a few trace points that will help to shed some light into some field traces that show long compaction running times to determine whether cancellation is not properly working in the field or if the batch sizes are too big. Bug: 226463719 Test: Verified trace points in perfetto. Change-Id: I362044a38ffc5e820b7fddf6cb08fa2325e6929b
This commit is contained in:
@@ -101,6 +101,8 @@ public final class CachedAppOptimizer {
|
||||
private static final int COMPACT_ACTION_FILE_FLAG = 1;
|
||||
private static final int COMPACT_ACTION_ANON_FLAG = 2;
|
||||
|
||||
private static final String ATRACE_COMPACTION_TRACK = "Compaction";
|
||||
|
||||
// Defaults for phenotype flags.
|
||||
@VisibleForTesting static final Boolean DEFAULT_USE_COMPACTION = false;
|
||||
@VisibleForTesting static final Boolean DEFAULT_USE_FREEZER = true;
|
||||
@@ -462,6 +464,8 @@ public final class CachedAppOptimizer {
|
||||
void compactAppSome(ProcessRecord app) {
|
||||
app.mOptRecord.setReqCompactAction(COMPACT_PROCESS_SOME);
|
||||
if (!app.mOptRecord.hasPendingCompact()) {
|
||||
Trace.instantForTrack(Trace.TRACE_TAG_ACTIVITY_MANAGER, ATRACE_COMPACTION_TRACK,
|
||||
"compactAppSome " + app.processName != null ? app.processName : "");
|
||||
app.mOptRecord.setHasPendingCompact(true);
|
||||
mPendingCompactionProcesses.add(app);
|
||||
mCompactionHandler.sendMessage(
|
||||
@@ -479,6 +483,8 @@ public final class CachedAppOptimizer {
|
||||
&& app.mState.getCurAdj() <= mCompactThrottleMaxOomAdj) {
|
||||
app.mOptRecord.setReqCompactAction(COMPACT_PROCESS_FULL);
|
||||
if (!app.mOptRecord.hasPendingCompact()) {
|
||||
Trace.instantForTrack(Trace.TRACE_TAG_ACTIVITY_MANAGER, ATRACE_COMPACTION_TRACK,
|
||||
"compactAppFull " + app.processName != null ? app.processName : "");
|
||||
app.mOptRecord.setHasPendingCompact(true);
|
||||
mPendingCompactionProcesses.add(app);
|
||||
mCompactionHandler.sendMessage(
|
||||
@@ -498,6 +504,8 @@ public final class CachedAppOptimizer {
|
||||
void compactAppPersistent(ProcessRecord app) {
|
||||
app.mOptRecord.setReqCompactAction(COMPACT_PROCESS_PERSISTENT);
|
||||
if (!app.mOptRecord.hasPendingCompact()) {
|
||||
Trace.instantForTrack(Trace.TRACE_TAG_ACTIVITY_MANAGER, ATRACE_COMPACTION_TRACK,
|
||||
"compactAppPersistent " + app.processName != null ? app.processName : "");
|
||||
app.mOptRecord.setHasPendingCompact(true);
|
||||
mPendingCompactionProcesses.add(app);
|
||||
mCompactionHandler.sendMessage(
|
||||
@@ -516,6 +524,8 @@ public final class CachedAppOptimizer {
|
||||
void compactAppBfgs(ProcessRecord app) {
|
||||
app.mOptRecord.setReqCompactAction(COMPACT_PROCESS_BFGS);
|
||||
if (!app.mOptRecord.hasPendingCompact()) {
|
||||
Trace.instantForTrack(Trace.TRACE_TAG_ACTIVITY_MANAGER, ATRACE_COMPACTION_TRACK,
|
||||
"compactAppBfgs " + app.processName != null ? app.processName : "");
|
||||
app.mOptRecord.setHasPendingCompact(true);
|
||||
mPendingCompactionProcesses.add(app);
|
||||
mCompactionHandler.sendMessage(
|
||||
@@ -532,6 +542,8 @@ public final class CachedAppOptimizer {
|
||||
|
||||
void compactAllSystem() {
|
||||
if (useCompaction()) {
|
||||
Trace.instantForTrack(
|
||||
Trace.TRACE_TAG_ACTIVITY_MANAGER, ATRACE_COMPACTION_TRACK, "compactAllSystem");
|
||||
mCompactionHandler.sendMessage(mCompactionHandler.obtainMessage(
|
||||
COMPACT_SYSTEM_MSG));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#define LOG_TAG "CachedAppOptimizer"
|
||||
//#define LOG_NDEBUG 0
|
||||
#define ATRACE_TAG ATRACE_TAG_ACTIVITY_MANAGER
|
||||
#define ATRACE_COMPACTION_TRACK "Compaction"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
@@ -40,6 +42,7 @@
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -115,6 +118,8 @@ static int64_t compactMemory(const std::vector<Vma>& vmas, int pid, int madviseT
|
||||
// is requested and when it is handled during this time our
|
||||
// OOM adjust could have improved.
|
||||
LOG(DEBUG) << "Cancelled running compaction for " << pid;
|
||||
ATRACE_INSTANT_FOR_TRACK(ATRACE_COMPACTION_TRACK,
|
||||
StringPrintf("Cancelled compaction for %d", pid).c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -150,7 +155,9 @@ static int64_t compactMemory(const std::vector<Vma>& vmas, int pid, int madviseT
|
||||
break;
|
||||
}
|
||||
|
||||
ATRACE_BEGIN(StringPrintf("Compact %d VMAs", iVec).c_str());
|
||||
auto bytesProcessed = process_madvise(pidfd, vmasToKernel, iVec, madviseType, 0);
|
||||
ATRACE_END();
|
||||
|
||||
if (CC_UNLIKELY(bytesProcessed == -1)) {
|
||||
if (errno == EINVAL) {
|
||||
@@ -303,6 +310,7 @@ static void com_android_server_am_CachedAppOptimizer_compactSystem(JNIEnv *, job
|
||||
static void com_android_server_am_CachedAppOptimizer_cancelCompaction(JNIEnv*, jobject) {
|
||||
if (compactionInProgress) {
|
||||
cancelRunningCompaction = true;
|
||||
ATRACE_INSTANT_FOR_TRACK(ATRACE_COMPACTION_TRACK, "Cancel compaction");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ cc_library_shared {
|
||||
"libnativehelper",
|
||||
"libprocessgroup",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
"android.hardware.graphics.bufferqueue@1.0",
|
||||
"android.hardware.graphics.bufferqueue@2.0",
|
||||
"android.hardware.graphics.common@1.2",
|
||||
|
||||
Reference in New Issue
Block a user