Skip to content
Commit c086fe9a authored by Winson's avatar Winson
Browse files

Optimize (Parsing)PackageImpl implementation

To speed up recurring ApplicationInfo creation, this caches
the the appInfoFlags/appInfoPrivateFlags at parse time, since
they're immutable at that point. This saves having to calculate
it hundreds of times for all the packages in getInstalledPackages
or similar.

This also saves the base app data directories for the system user,
or user 0, interning the strings since they're shared across
packages with the same volume UUID. A better solution would
cache these paths during boot scan and re-use the strings directly
rather than re-building and relying on interning, but there was
no good mechanism for that.

This decreases string append computation time and compromises
between persistent memory and performance.

This also compacts boolean fields into a bitset, decreasing
the amount persisted in both the object memory and the Parcelable
output.

In combination these changes result in a net decrease in memory
usage, although the difference is neglible, on the order of
~4KB for 181 packages or ~22B a package. The increase in speed is
roughly 2/3rds saved off the total time of generateWithComponents.

An important note is that hideAsParsed/hideAsFinal are now
required to be called because they now calculate the derived
fields to be cached.

Bug: 153656459

Test: atest CrossProfileAppsServiceImplRoboTest
Test: atest PackageManagerComponentLabelIconOverrideTest
Test: atest PackageParserTest
Test: atest UserSystemPackageInstallerTest
Test: atest DexoptUtilsTest
Test: atest com.android.server.pm.parsing
Test: atest PackageInfoUserFieldsTest
Test: atest com.android.server.pm.ScanTests
Test: atest android.content.pm.cts.PackageManagerTest

Change-Id: I977edb9dec720893ccb1ce5b9df33733c408d3c1
parent e78c0050
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment