From e073306d7788dd14aa8b6bd24304a18dece7c084 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Thu, 9 Feb 2017 22:49:35 -0800 Subject: [PATCH] Track update count of IMMS#mMethodMap InputMethodManagerService#buildInputMethodListLocked() is known be one of the biggest contributors to CPU and I/O bandwidth consumed by InputMethodManagerService (IMMS). To check when it gets called and to see how a CL would affect its call count, it would be useful if we can easily get the call count of that method. With this CL, how many times IMMS#mMethodMap was rebuilt will be included in the dumpsys. Test: adb shell dumpsys input_method | grep "mMethodMapUpdateCount=" to make sure the count is increasing. Bug: 32343335 Change-Id: I05850578cbf2e6adfea6c7e9b1fb9ec4e9d5e2c9 --- .../com/android/server/InputMethodManagerService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index f0f50f07fccab..121bc3c02d523 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -227,6 +227,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub new LruCache<>(SECURE_SUGGESTION_SPANS_MAX_SIZE); private final InputMethodSubtypeSwitchingController mSwitchingController; + /** + * Tracks how many times {@link #mMethodMap} was updated. + */ + @GuardedBy("mMethodMap") + private int mMethodMapUpdateCount = 0; + // Used to bring IME service up to visible adjustment while it is being shown. final ServiceConnection mVisibleConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { @@ -3069,6 +3075,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } mMethodList.clear(); mMethodMap.clear(); + mMethodMapUpdateCount++; mMyPackageMonitor.clearPackagesToMonitorComponentChangeLocked(); // Use for queryIntentServicesAsUser @@ -4070,7 +4077,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub synchronized (mMethodMap) { p.println("Current Input Method Manager state:"); int N = mMethodList.size(); - p.println(" Input Methods:"); + p.println(" Input Methods: mMethodMapUpdateCount=" + mMethodMapUpdateCount); for (int i=0; i