diff options
| author | 2020-04-15 12:46:23 +0100 | |
|---|---|---|
| committer | 2020-04-16 11:08:55 +0100 | |
| commit | 6c157067a4963435503aa7fae37a0da756a9f07f (patch) | |
| tree | 1286e201a73b09cc277389031170101c8e011f71 | |
| parent | e65d87a96be37cb12cd2923d36885cbb97c10d38 (diff) | |
Add batched createAppData API to installd.
Benchmarking creation of new users shows on a freshly setup device
sees many individual binder calls from system server into installd to
create app data directories. Batching these calls shows a significant
performance improvement.
Bug: 153171028
Test: Manually create guest user, trace performance with Perfetto.
Change-Id: Iea43c058d465be44c0937bf6c353555869fc9fd2
| -rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 27 | ||||
| -rw-r--r-- | cmds/installd/InstalldNativeService.h | 7 | ||||
| -rw-r--r-- | cmds/installd/binder/android/os/IInstalld.aidl | 3 |
3 files changed, 36 insertions, 1 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index 6fee11b566..c0fb0f89a6 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -412,6 +412,33 @@ static bool prepare_app_profile_dir(const std::string& packageName, int32_t appI return true; } +binder::Status InstalldNativeService::createAppDataBatched( + const std::optional<std::vector<std::optional<std::string>>>& uuids, + const std::optional<std::vector<std::optional<std::string>>>& packageNames, + int32_t userId, int32_t flags, const std::vector<int32_t>& appIds, + const std::vector<std::string>& seInfos, const std::vector<int32_t>& targetSdkVersions, + int64_t* _aidl_return) { + ENFORCE_UID(AID_SYSTEM); + std::lock_guard<std::recursive_mutex> lock(mLock); + + ATRACE_BEGIN("createAppDataBatched"); + binder::Status ret; + for (size_t i = 0; i < uuids->size(); i++) { + std::optional<std::string> packageName = packageNames->at(i); + if (!packageName) { + continue; + } + ret = createAppData(uuids->at(i), *packageName, userId, flags, appIds[i], + seInfos[i], targetSdkVersions[i], _aidl_return); + if (!ret.isOk()) { + ATRACE_END(); + return ret; + } + } + ATRACE_END(); + return ok(); +} + binder::Status InstalldNativeService::createAppData(const std::optional<std::string>& uuid, const std::string& packageName, int32_t userId, int32_t flags, int32_t appId, const std::string& seInfo, int32_t targetSdkVersion, int64_t* _aidl_return) { diff --git a/cmds/installd/InstalldNativeService.h b/cmds/installd/InstalldNativeService.h index 1a8da5f865..3f44021b95 100644 --- a/cmds/installd/InstalldNativeService.h +++ b/cmds/installd/InstalldNativeService.h @@ -44,7 +44,12 @@ public: int32_t userSerial, int32_t flags); binder::Status destroyUserData(const std::optional<std::string>& uuid, int32_t userId, int32_t flags); - + binder::Status createAppDataBatched( + const std::optional<std::vector<std::optional<std::string>>>& uuids, + const std::optional<std::vector<std::optional<std::string>>>& packageNames, + int32_t userId, int32_t flags, const std::vector<int32_t>& appIds, + const std::vector<std::string>& seInfos, const std::vector<int32_t>& targetSdkVersions, + int64_t* _aidl_return); binder::Status createAppData(const std::optional<std::string>& uuid, const std::string& packageName, int32_t userId, int32_t flags, int32_t appId, const std::string& seInfo, int32_t targetSdkVersion, int64_t* _aidl_return); diff --git a/cmds/installd/binder/android/os/IInstalld.aidl b/cmds/installd/binder/android/os/IInstalld.aidl index 0b9a444c58..1e18a6ba70 100644 --- a/cmds/installd/binder/android/os/IInstalld.aidl +++ b/cmds/installd/binder/android/os/IInstalld.aidl @@ -23,6 +23,9 @@ interface IInstalld { long createAppData(@nullable @utf8InCpp String uuid, in @utf8InCpp String packageName, int userId, int flags, int appId, in @utf8InCpp String seInfo, int targetSdkVersion); + long createAppDataBatched(in @nullable @utf8InCpp String[] uuids, + in @nullable @utf8InCpp String[] packageNames, in int userId, int flags, in int[] appIds, + in @utf8InCpp String[] seInfos, in int[] targetSdkVersions); void restoreconAppData(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName, int userId, int flags, int appId, @utf8InCpp String seInfo); void migrateAppData(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName, |