From 657f3c6bbfb7b0a7782562c5de5fd1aecc1346b3 Mon Sep 17 00:00:00 2001 From: Yurii Zubrytskyi Date: Wed, 10 May 2023 13:16:23 -0700 Subject: [res] Speed up AssetManager pointer locking AssetManager needs to lock (promote()) apk asset weak pointers to use them in pretty much any operation, and often mulitple times for the same object. This CL introduces a concept of an 'operation' in AssetManager, and adds a cache for the locked assets that are retained until the end of that operation. This way we only need to lock each assets object exactly once, losing pretty much no performance. Benchmarks all returned to the pre-memory-safe state values. Bug: 280951693 Bug: 197260547 Bug: 276922628 Test: UTs + native benchmarks + java benchmarks + boot (cherry-picked from https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/base/+/23146856) Merged-In: I26ef88df4f6267b5e8b89f1588f2382db74030c0 Change-Id: I26ef88df4f6267b5e8b89f1588f2382db74030c0 --- tools/aapt2/process/SymbolTable.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools/aapt2') diff --git a/tools/aapt2/process/SymbolTable.cpp b/tools/aapt2/process/SymbolTable.cpp index b75458a7b8b6..d78baf9ffeb4 100644 --- a/tools/aapt2/process/SymbolTable.cpp +++ b/tools/aapt2/process/SymbolTable.cpp @@ -260,10 +260,11 @@ bool AssetManagerSymbolSource::IsPackageDynamic(uint32_t packageId, static std::unique_ptr LookupAttributeInTable( android::AssetManager2& am, ResourceId id) { using namespace android; - if (am.GetApkAssets().empty()) { + if (am.GetApkAssetsCount() == 0) { return {}; } + auto op = am.StartOperation(); auto bag_result = am.GetBag(id.id); if (!bag_result.has_value()) { return nullptr; -- cgit v1.2.3-59-g8ed1b