Merge changes I2ef3737f,If080281f
* changes: Add property for system server compiler filter Compile secondary dex at boot after OTA
This commit is contained in:
@@ -546,12 +546,13 @@ public class ZygoteInit {
|
||||
for (String classPathElement : classPathElements) {
|
||||
// System server is fully AOTed and never profiled
|
||||
// for profile guided compilation.
|
||||
// TODO: Make this configurable between INTERPRET_ONLY, SPEED, SPACE and EVERYTHING?
|
||||
String systemServerFilter = SystemProperties.get(
|
||||
"dalvik.vm.systemservercompilerfilter", "speed");
|
||||
|
||||
int dexoptNeeded;
|
||||
try {
|
||||
dexoptNeeded = DexFile.getDexOptNeeded(
|
||||
classPathElement, instructionSet, "speed",
|
||||
classPathElement, instructionSet, systemServerFilter,
|
||||
false /* newProfile */, false /* downgrade */);
|
||||
} catch (FileNotFoundException ignored) {
|
||||
// Do not add to the classpath.
|
||||
@@ -570,7 +571,7 @@ public class ZygoteInit {
|
||||
final String packageName = "*";
|
||||
final String outputPath = null;
|
||||
final int dexFlags = 0;
|
||||
final String compilerFilter = "speed";
|
||||
final String compilerFilter = systemServerFilter;
|
||||
final String uuid = StorageManager.UUID_PRIVATE_INTERNAL;
|
||||
final String seInfo = null;
|
||||
try {
|
||||
|
||||
@@ -321,6 +321,10 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
||||
mPackageManagerService.getDexManager().isUsedByOtherApps(pkg.packageName),
|
||||
true /* bootComplete */);
|
||||
|
||||
mPackageManagerService.getDexManager().dexoptSecondaryDex(pkg.packageName,
|
||||
getCompilerFilterForReason(compilationReason),
|
||||
false /* force */,
|
||||
false /* compileOnlySharedDex */);
|
||||
return commands;
|
||||
}
|
||||
|
||||
|
||||
@@ -9392,24 +9392,39 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
// Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
|
||||
// behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
|
||||
// trade-off worth doing to save boot time work.
|
||||
int dexOptStatus = performDexOptTraced(pkg.packageName,
|
||||
int primaryDexOptStaus = performDexOptTraced(pkg.packageName,
|
||||
false /* checkProfiles */,
|
||||
compilerFilter,
|
||||
false /* force */,
|
||||
bootComplete);
|
||||
switch (dexOptStatus) {
|
||||
case PackageDexOptimizer.DEX_OPT_PERFORMED:
|
||||
numberOfPackagesOptimized++;
|
||||
break;
|
||||
case PackageDexOptimizer.DEX_OPT_SKIPPED:
|
||||
numberOfPackagesSkipped++;
|
||||
break;
|
||||
case PackageDexOptimizer.DEX_OPT_FAILED:
|
||||
numberOfPackagesFailed++;
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Unexpected dexopt return code " + dexOptStatus);
|
||||
break;
|
||||
|
||||
boolean secondaryDexOptStatus = true;
|
||||
if (pkg.isSystemApp()) {
|
||||
// Only dexopt shared secondary dex files belonging to system apps to not slow down
|
||||
// too much boot after an OTA.
|
||||
secondaryDexOptStatus = mDexManager.dexoptSecondaryDex(pkg.packageName,
|
||||
compilerFilter,
|
||||
false /* force */,
|
||||
true /* compileOnlySharedDex */);
|
||||
}
|
||||
|
||||
if (secondaryDexOptStatus) {
|
||||
switch (primaryDexOptStaus) {
|
||||
case PackageDexOptimizer.DEX_OPT_PERFORMED:
|
||||
numberOfPackagesOptimized++;
|
||||
break;
|
||||
case PackageDexOptimizer.DEX_OPT_SKIPPED:
|
||||
numberOfPackagesSkipped++;
|
||||
break;
|
||||
case PackageDexOptimizer.DEX_OPT_FAILED:
|
||||
numberOfPackagesFailed++;
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Unexpected dexopt return code " + primaryDexOptStaus);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
numberOfPackagesFailed++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9611,8 +9626,8 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
} else if (isInstantApp(packageName, UserHandle.getCallingUserId())) {
|
||||
return false;
|
||||
}
|
||||
mDexManager.reconcileSecondaryDexFiles(packageName);
|
||||
return mDexManager.dexoptSecondaryDex(packageName, compilerFilter, force);
|
||||
return mDexManager.dexoptSecondaryDex(packageName, compilerFilter, force,
|
||||
/* compileOnlySharedDex*/ false);
|
||||
}
|
||||
|
||||
public boolean performDexOptSecondary(String packageName, int compileReason,
|
||||
|
||||
@@ -307,7 +307,7 @@ public class DexManager {
|
||||
public boolean dexoptSecondaryDex(String packageName, int compilerReason, boolean force) {
|
||||
return dexoptSecondaryDex(packageName,
|
||||
PackageManagerServiceCompilerMapping.getCompilerFilterForReason(compilerReason),
|
||||
force);
|
||||
force, /* compileOnlySharedDex */ false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,7 +315,8 @@ public class DexManager {
|
||||
* @return true if all secondary dex files were processed successfully (compiled or skipped
|
||||
* because they don't need to be compiled)..
|
||||
*/
|
||||
public boolean dexoptSecondaryDex(String packageName, String compilerFilter, boolean force) {
|
||||
public boolean dexoptSecondaryDex(String packageName, String compilerFilter, boolean force,
|
||||
boolean compileOnlySharedDex) {
|
||||
// Select the dex optimizer based on the force parameter.
|
||||
// Forced compilation is done through ForcedUpdatePackageDexOptimizer which will adjust
|
||||
// the necessary dexopt flags to make sure that compilation is not skipped. This avoid
|
||||
@@ -337,6 +338,9 @@ public class DexManager {
|
||||
for (Map.Entry<String, DexUseInfo> entry : useInfo.getDexUseInfoMap().entrySet()) {
|
||||
String dexPath = entry.getKey();
|
||||
DexUseInfo dexUseInfo = entry.getValue();
|
||||
if (compileOnlySharedDex && !dexUseInfo.isUsedByOtherApps()) {
|
||||
continue;
|
||||
}
|
||||
PackageInfo pkg = null;
|
||||
try {
|
||||
pkg = mPackageManager.getPackageInfo(packageName, /*flags*/0,
|
||||
|
||||
Reference in New Issue
Block a user