summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pablo Gamito <pablogamito@google.com> 2024-03-07 10:04:38 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-03-07 10:04:38 +0000
commiteec4fd6a55267f30cceee21a85ae76515c155bde (patch)
treedfb148e17f35821741c3ee9e4a65a53540067505
parentf83c015f091fa4e817f33dc915b5590e92c976a1 (diff)
parentd45f744ed0db6a89513975e4fb3e6702cf503ae2 (diff)
Merge "Move proto logging to thread pool" into main
-rw-r--r--core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java b/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java
index bdd9a913a06c..ecbc21b10192 100644
--- a/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java
+++ b/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java
@@ -70,6 +70,8 @@ import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import perfetto.protos.PerfettoTrace.ProtoLogViewerConfig.MessageData;
@@ -90,6 +92,8 @@ public class PerfettoProtoLogImpl implements IProtoLog {
private final ViewerConfigInputStreamProvider mViewerConfigInputStreamProvider;
private final TreeMap<String, IProtoLogGroup> mLogGroups;
+ private final ExecutorService mBackgroundLoggingService = Executors.newCachedThreadPool();
+
public PerfettoProtoLogImpl(String viewerConfigFilePath,
TreeMap<String, IProtoLogGroup> logGroups) {
this(() -> {
@@ -134,7 +138,8 @@ public class PerfettoProtoLogImpl implements IProtoLog {
long tsNanos = SystemClock.elapsedRealtimeNanos();
try {
- logToProto(level, group.name(), messageHash, paramsMask, args, tsNanos);
+ mBackgroundLoggingService.submit(() ->
+ logToProto(level, group.name(), messageHash, paramsMask, args, tsNanos));
if (group.isLogToLogcat()) {
logToLogcat(group.getTag(), level, messageHash, messageString, args);
}