summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2024-01-09 19:22:26 +0000
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-01-10 20:52:25 +0000
commit4c5115d2196a6912102616c77aa233f14cb8b382 (patch)
treeee9c34a862ef0937daa17b8ea6920ce6f669e891
parent40855538527351c24a272252efa52a2e4ff2d27b (diff)
Throttle the creation of threads in Debouncer (again).
http://r.android.com/2887708 throttled the creation of ScheduledExecutorService, but it didn't actually throttle the creation of threads because we were using the ScheduledExecutorService created by Executors.newSingleThreadScheduledExecutor(), which has a surprising behavior that it destroys the single thread when the last task is cancelled, and re-creates it when a new task is scheduled. After this change, we use the ScheduledExecutorService created by Executors.newScheduledThreadPool(1 /* corePoolSize */) instead. Bug: 317234694 Test: - 1. Capture a trace starting from right before `adb shell start` with `--duration 120` and `-e sched:sched_wakeup_new`. 2. See only one thread creation initiated by "notifyDexLoad" (https://pprofng.corp.google.com/?id=721c44e87ff38dff14d4a6e7d6e1c010&pivot=%5Ecom%5C.android%5C.server%5C.pm%5C.PackageManagerService%5C$IPackageManagerImpl%5C.notifyDexLoad$) Change-Id: I21bd9040c1cf2508b3912236a25522f9bfb8e39f
-rw-r--r--libartservice/service/java/com/android/server/art/DexUseManagerLocal.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java b/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java
index c73f71b9e3..b9d0afe0d9 100644
--- a/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java
+++ b/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java
@@ -1173,7 +1173,7 @@ public class DexUseManagerLocal {
@NonNull
public ScheduledExecutorService createScheduledExecutor() {
- return Executors.newSingleThreadScheduledExecutor();
+ return Executors.newScheduledThreadPool(1 /* corePoolSize */);
}
@NonNull