[res] Optimize Idmap verification - use mtime as crc
Idmap.verifyIdmap() is called for every apk-rro combination on boot, and is one of the slowest operations in the service. It used to verify that the idmap version, the target/overlay paths, and their content are unchanged, and used the whole file's resources CRC for that (resources.arsc + the manifest). The calculation requres opening and parsing both apks as zip files, then reading the resources from disk to get the CRC. Later, if it's determined to be out of date, the next "create" call does the same work again. This CL changes the crc field in idmap to store the file's stat.st_mtime value, which is a good indicator if the file has changed since the idmap creation. Given that we also check the path, the old code was already invalidating idmaps on apk moves (like staging -> final directory during installation), so this won't add any extra invalidations because of that. It still would invalidate the idmap when an apk changes but its resources don't, but that is such a rare case (updating the whole partition so the paths are the same, and only changing the non- resource parts of the apks), that the overall speedup of the verification totally outweighs it. OMS total startup time on P11 reduces 110ms -> 60ms, at a cost of one-time idmap regeneration on the first boot Test: build + boot + atest idmap2_tests Bug: b/422474410 Flag: android.content.res.idmap_crc_is_mtime Change-Id: Ia35a01f999acf09a668221102dccb455feec3851
Loading
Please register or sign in to comment