[RFC] Special case system apps for profile optimizations
If the OTA updates a system app which was previously preopted to a non-
preopted state the app might end up being verified at runtime. That's
because by default the apps are verify-profile but for preopted apps
there's no profile.
Do a hacky check to ensure that if we have no profiles (a reasonable
indication that before the OTA the app was preopted) system apps get
compiled with a non-profile filter (by default interpret-only).
Bug: 30032273
Test: Andreas "has verified that Calin's change to A/B works as expected
and promotes things like SystemUI to speed. From my side, that's
ready to be merged"
Change-Id: I7a052a8ea76cab7f649dc993237ea05534d6c4b9
(cherry picked from commit 0bd7762079)
This commit is contained in:
committed by
Andreas Gampe
parent
9438528d99
commit
08313b0d95
@@ -285,6 +285,11 @@ public class Environment {
|
|||||||
return buildPath(getDataDirectory(), "misc", "profiles", "cur", String.valueOf(userId));
|
return buildPath(getDataDirectory(), "misc", "profiles", "cur", String.valueOf(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** {@hide} */
|
||||||
|
public static File getReferenceProfile(String packageName) {
|
||||||
|
return buildPath(getDataDirectory(), "misc", "profiles", "ref", packageName);
|
||||||
|
}
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public static File getDataProfilesDePackageDirectory(int userId, String packageName) {
|
public static File getDataProfilesDePackageDirectory(int userId, String packageName) {
|
||||||
return buildPath(getDataProfilesDeDirectory(userId), packageName);
|
return buildPath(getDataProfilesDeDirectory(userId), packageName);
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ import static com.android.server.pm.InstructionSets.getPreferredInstructionSet;
|
|||||||
import static com.android.server.pm.InstructionSets.getPrimaryInstructionSet;
|
import static com.android.server.pm.InstructionSets.getPrimaryInstructionSet;
|
||||||
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getCompilerFilterForReason;
|
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getCompilerFilterForReason;
|
||||||
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getFullCompilerFilter;
|
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getFullCompilerFilter;
|
||||||
|
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getNonProfileGuidedCompilerFilter;
|
||||||
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_FAILURE;
|
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_FAILURE;
|
||||||
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS;
|
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS;
|
||||||
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS_GIDS_CHANGED;
|
import static com.android.server.pm.PermissionsState.PERMISSION_OPERATION_SUCCESS_GIDS_CHANGED;
|
||||||
@@ -2793,7 +2794,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] stats = performDexOpt(coreApps, false,
|
int[] stats = performDexOptUpgrade(coreApps, false,
|
||||||
getCompilerFilterForReason(REASON_CORE_APP));
|
getCompilerFilterForReason(REASON_CORE_APP));
|
||||||
|
|
||||||
final int elapsedTimeSeconds =
|
final int elapsedTimeSeconds =
|
||||||
@@ -7300,7 +7301,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final long startTime = System.nanoTime();
|
final long startTime = System.nanoTime();
|
||||||
final int[] stats = performDexOpt(pkgs, mIsPreNUpgrade /* showDialog */,
|
final int[] stats = performDexOptUpgrade(pkgs, mIsPreNUpgrade /* showDialog */,
|
||||||
getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT));
|
getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT));
|
||||||
|
|
||||||
final int elapsedTimeSeconds =
|
final int elapsedTimeSeconds =
|
||||||
@@ -7319,7 +7320,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
* which are (in order) {@code numberOfPackagesOptimized}, {@code numberOfPackagesSkipped}
|
* which are (in order) {@code numberOfPackagesOptimized}, {@code numberOfPackagesSkipped}
|
||||||
* and {@code numberOfPackagesFailed}.
|
* and {@code numberOfPackagesFailed}.
|
||||||
*/
|
*/
|
||||||
private int[] performDexOpt(List<PackageParser.Package> pkgs, boolean showDialog,
|
private int[] performDexOptUpgrade(List<PackageParser.Package> pkgs, boolean showDialog,
|
||||||
String compilerFilter) {
|
String compilerFilter) {
|
||||||
|
|
||||||
int numberOfPackagesVisited = 0;
|
int numberOfPackagesVisited = 0;
|
||||||
@@ -7353,6 +7354,19 @@ public class PackageManagerService extends IPackageManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the OTA updates a system app which was previously preopted to a non-preopted state
|
||||||
|
// the app might end up being verified at runtime. That's because by default the apps
|
||||||
|
// are verify-profile but for preopted apps there's no profile.
|
||||||
|
// Do a hacky check to ensure that if we have no profiles (a reasonable indication
|
||||||
|
// that before the OTA the app was preopted) the app gets compiled with a non-profile
|
||||||
|
// filter (by default interpret-only).
|
||||||
|
// Note that at this stage unused apps are already filtered.
|
||||||
|
if (isSystemApp(pkg) &&
|
||||||
|
DexFile.isProfileGuidedCompilerFilter(compilerFilter) &&
|
||||||
|
!Environment.getReferenceProfile(pkg.packageName).exists()) {
|
||||||
|
compilerFilter = getNonProfileGuidedCompilerFilter(compilerFilter);
|
||||||
|
}
|
||||||
|
|
||||||
// checkProfiles is false to avoid merging profiles during boot which
|
// checkProfiles is false to avoid merging profiles during boot which
|
||||||
// might interfere with background compilation (b/28612421).
|
// might interfere with background compilation (b/28612421).
|
||||||
// Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
|
// Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
|
||||||
|
|||||||
Reference in New Issue
Block a user