diff options
author | Narayan Kamath <narayan@google.com> | 2014-08-08 13:43:59 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2014-08-08 17:39:59 +0000 |
commit | 05e8f801b54d43ae43f86a310217ec6f931b5738 (patch) | |
tree | 2dfea8a4eb0b2de13e9a77eab9f0f97244922694 | |
parent | 6d9fe654b5da2f2b7751b6affae535f4ddfa7f64 (diff) | |
download | frameworks_base-05e8f801b54d43ae43f86a310217ec6f931b5738.zip frameworks_base-05e8f801b54d43ae43f86a310217ec6f931b5738.tar.gz frameworks_base-05e8f801b54d43ae43f86a310217ec6f931b5738.tar.bz2 |
Reduce the frequency of calls to isDexOptNeededInternal.
The package manager maintains a set of dexopted instruction
sets as a fast path to avoid calling expensive code. We were
correctly adding elements to that list while performing dexopt,
but were *not* adding elements to the list when isDexOptNeededInternal
told us things were up to date. As a result, we'd hit the slow path
100% of the time on userdebug builds in the steady state, i.e, when
the system did not dexopt anything since boot.
With this change, we make sure isDexOptNeededInternal is called
precisely once per boot in such case.
This patch also fixes broken logic for apps that have multiple
code paths. We must mark the paths as dexopted only if we've
processed all paths.
bug: 16828525
bug: 16868741
Change-Id: Icb59121fe915d892e677d9b7e9a4efd11555ae27
-rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 44b7f01..36dec3e 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -4635,12 +4635,12 @@ public class PackageManagerService extends IPackageManager.Stub { // 2.) we are defering a needed dexopt // 3.) we are skipping an unneeded dexopt final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets); - for (String path : paths) { - for (String dexCodeInstructionSet : dexCodeInstructionSets) { - if (!forceDex && pkg.mDexOptPerformed.contains(dexCodeInstructionSet)) { - continue; - } + for (String dexCodeInstructionSet : dexCodeInstructionSets) { + if (!forceDex && pkg.mDexOptPerformed.contains(dexCodeInstructionSet)) { + continue; + } + for (String path : paths) { try { // This will return DEXOPT_NEEDED if we either cannot find any odex file for this // patckage or the one we find does not match the image checksum (i.e. it was @@ -4661,10 +4661,9 @@ public class PackageManagerService extends IPackageManager.Stub { // just result in an error again. Also, don't bother dexopting for other // paths & ISAs. return DEX_OPT_FAILED; - } else { - performedDexOpt = true; - pkg.mDexOptPerformed.add(dexCodeInstructionSet); } + + performedDexOpt = true; } else if (!defer && isDexOptNeeded == DexFile.PATCHOAT_NEEDED) { Log.i(TAG, "Running patchoat on: " + pkg.applicationInfo.packageName); final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid); @@ -4676,10 +4675,9 @@ public class PackageManagerService extends IPackageManager.Stub { // just result in an error again. Also, don't bother dexopting for other // paths & ISAs. return DEX_OPT_FAILED; - } else { - performedDexOpt = true; - pkg.mDexOptPerformed.add(dexCodeInstructionSet); } + + performedDexOpt = true; } // We're deciding to defer a needed dexopt. Don't bother dexopting for other @@ -4706,6 +4704,13 @@ public class PackageManagerService extends IPackageManager.Stub { return DEX_OPT_FAILED; } } + + // At this point we haven't failed dexopt and we haven't deferred dexopt. We must + // either have either succeeded dexopt, or have had isDexOptNeededInternal tell us + // it isn't required. We therefore mark that this package doesn't need dexopt unless + // it's forced. performedDexOpt will tell us whether we performed dex-opt or skipped + // it. + pkg.mDexOptPerformed.add(dexCodeInstructionSet); } // If we've gotten here, we're sure that no error occurred and that we haven't |