OSDN Git Service

Start processes asynchronously in AMS.
authorSudheer Shanka <sudheersai@google.com>
Mon, 16 Oct 2017 17:20:32 +0000 (10:20 -0700)
committerSudheer Shanka <sudheersai@google.com>
Fri, 15 Dec 2017 20:23:12 +0000 (12:23 -0800)
commitf6690100be5c5cd75c64d9a6a0345acff7b754d1
tree78790f82c5b435c060fa92521010f99bc42c136d
parent454c831d1d66e19eb282d0f99c7a682db4a9ae9d
Start processes asynchronously in AMS.

Currently, process start is initiated in ActivityManagerService
holding the main lock and this takes ~40ms to complete. As seen
in some of the issues in previous releases, this is one of the
contributors of the lock contention in system_server. This change
tries to address this issue by moving the process start outside
the locked section.

When a process start is required, instead of doing it synchronously,
this request will be posted on a handler thread. On the handler thread,
this process start request will be completed without holding a lock.
If for some reason, we decide the process is not needed anymore before
it is actually started or being started, then AMS does everything as
usual removing the references to the process from internal state except
actually killing the process which will be handled on the handler
thread.

Bug: 68775202
Test: Ran app startup perf tests using forrest, will update the bug with results.
Test: https://docs.google.com/spreadsheets/d/1cW81guRALZXKsN-WZsKyQiCSY-RgkJ2m_M9IfqIquz8
Test: cts-tradefed run singleCommand cts-dev -m CtsActivityManagerDeviceTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsWindowManagerDeviceTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsAppTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsMultiUserHostTestCases
Test: adb shell am instrument -e package com.android.server.am -w \
      com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -e class com.android.server.pm.UserManagerTest -w \
      com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -e package android.content -w \
      com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: cts-tradefed run singleCommand cts-dev -m CtsProviderTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsContentTestCases -t \
      android.content.cts.ContentResolverTest
Test: cts-tradefed run singleCommand cts-dev -m CtsContentTestCases -t \
      android.content.cts.ContentProviderTest
Test: cts-tradefed run singleCommand cts-dev -m CtsWebkitTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsHostsideWebViewTests
Test: cts-tradefed run singleCommand cts-dev -m CtsAssistTestCases
Test: make WebViewLoadingTests && make tradefed-all && tradefed.sh \
      run template/local_min --template:map test=WebViewLoadingTests
Test: adb shell setprop wrap.com.google.android.apps.maps \
      '"LIBC_DEBUG_MALLOC_OPTIONS=backtrace logwrapper"'
      && adb shell dumpsys meminfo --unreachable <PID_OF_APP>
      && check ppid of <APP> is logwrapper's pid.
Test: cts-tradefed run singleCommand cts-dev -m CtsWrapWrapNoDebugTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsWrapWrapDebugTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsWrapNoWrapTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsWrapWrapDebugMallocDebugTestCases
Test: manual

Change-Id: I1fe7ce48cd5a4aadccaf6b3d6fdb5cad3304f1d3
core/java/android/app/ActivityManagerInternal.java
core/java/android/app/ActivityThread.java
core/java/android/app/IActivityManager.aidl
core/java/android/provider/Settings.java
core/java/android/webkit/WebViewLibraryLoader.java
services/core/java/com/android/server/am/ActivityManagerConstants.java
services/core/java/com/android/server/am/ActivityManagerService.java
services/core/java/com/android/server/am/AppErrors.java
services/core/java/com/android/server/am/BroadcastQueue.java
services/core/java/com/android/server/am/ProcessList.java
services/core/java/com/android/server/am/ProcessRecord.java