diff options
| author | 2020-03-25 00:16:37 +0000 | |
|---|---|---|
| committer | 2020-03-25 00:16:37 +0000 | |
| commit | 0fdf17d06b56960e7e48761a56d05ddcd3eeff84 (patch) | |
| tree | 870f4c12ca62fa2510d7c6916a269589c8641784 | |
| parent | 93032f6f95a8411d51c76c226758e3365fcebe9a (diff) | |
| parent | 13e1049d098c50b40e10ea5fac446bb94d4cdfe2 (diff) | |
Merge "SystemServerInitThreadPool: add timing log for executing and shutdown" into rvc-dev
| -rw-r--r-- | services/core/java/com/android/server/SystemServerInitThreadPool.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/SystemServerInitThreadPool.java b/services/core/java/com/android/server/SystemServerInitThreadPool.java index 8f914fe6f59f..94d6b135e554 100644 --- a/services/core/java/com/android/server/SystemServerInitThreadPool.java +++ b/services/core/java/com/android/server/SystemServerInitThreadPool.java @@ -25,6 +25,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.util.ConcurrentUtils; import com.android.internal.util.Preconditions; import com.android.server.am.ActivityManagerService; +import com.android.server.utils.TimingsTraceAndSlog; import java.util.ArrayList; import java.util.List; @@ -93,6 +94,8 @@ public class SystemServerInitThreadPool { mPendingTasks.add(description); } return mService.submit(() -> { + TimingsTraceAndSlog traceLog = TimingsTraceAndSlog.newAsyncLog(); + traceLog.traceBegin("InitThreadPoolExec:" + description); if (IS_DEBUGGABLE) { Slog.d(TAG, "Started executing " + description); } @@ -100,6 +103,7 @@ public class SystemServerInitThreadPool { runnable.run(); } catch (RuntimeException e) { Slog.e(TAG, "Failure in " + description + ": " + e, e); + traceLog.traceEnd(); throw e; } synchronized (mPendingTasks) { @@ -108,6 +112,7 @@ public class SystemServerInitThreadPool { if (IS_DEBUGGABLE) { Slog.d(TAG, "Finished executing " + description); } + traceLog.traceEnd(); }); } @@ -132,7 +137,10 @@ public class SystemServerInitThreadPool { */ static void shutdown() { synchronized (LOCK) { + TimingsTraceAndSlog t = new TimingsTraceAndSlog(); + t.traceBegin("WaitInitThreadPoolShutdown"); if (sInstance == null) { + t.traceEnd(); Slog.wtf(TAG, "Already shutdown", new Exception()); return; } @@ -147,6 +155,7 @@ public class SystemServerInitThreadPool { } catch (InterruptedException e) { Thread.currentThread().interrupt(); dumpStackTraces(); + t.traceEnd(); throw new IllegalStateException(TAG + " init interrupted"); } if (!terminated) { @@ -160,11 +169,13 @@ public class SystemServerInitThreadPool { synchronized (sInstance.mPendingTasks) { copy.addAll(sInstance.mPendingTasks); } + t.traceEnd(); throw new IllegalStateException("Cannot shutdown. Unstarted tasks " + unstartedRunnables + " Unfinished tasks " + copy); } sInstance = null; // Make eligible for GC Slog.d(TAG, "Shutdown successful"); + t.traceEnd(); } } |