Optimize FilterApkAssets by caching config
ResTable_config of every ResTable_type is read from device every time
AssetManager::RebuildFilterList is invoked. For large APKs (like
framework-res.apk), this causes a large number of page faults
when accessing the config from disk. The configs are also used in the
slow path of AssetManager::FindEntryInternal, which makes it even
slower. Instead cache the config on the TypeSpec of its ApkAsset.
Bug: 177247024
Test: libandroidfw_tests
Change-Id: I66d507c4eeb2399f7558f3d9dfc53c157129ada0
diff --git a/cmds/idmap2/libidmap2/ResourceMapping.cpp b/cmds/idmap2/libidmap2/ResourceMapping.cpp
index 9abb9e4..46eeb8e 100644
--- a/cmds/idmap2/libidmap2/ResourceMapping.cpp
+++ b/cmds/idmap2/libidmap2/ResourceMapping.cpp
@@ -285,14 +285,12 @@
bool enforce_overlayable,
LogInfo& log_info) {
AssetManager2 target_asset_manager;
- if (!target_asset_manager.SetApkAssets({&target_apk_assets}, true /* invalidate_caches */,
- false /* filter_incompatible_configs*/)) {
+ if (!target_asset_manager.SetApkAssets({&target_apk_assets})) {
return Error("failed to create target asset manager");
}
AssetManager2 overlay_asset_manager;
- if (!overlay_asset_manager.SetApkAssets({&overlay_apk_assets}, true /* invalidate_caches */,
- false /* filter_incompatible_configs */)) {
+ if (!overlay_asset_manager.SetApkAssets({&overlay_apk_assets})) {
return Error("failed to create overlay asset manager");
}