Add cmdline as a compilation reason

Set the compiler reason to 'cmdline' when the compilation was
initiated from cmdline. This will effectivively eliminate the
'unknown' reason from our metrics (except in some corner cases)

Test: adb shell cmd compile ...
Bug: 188655918
Change-Id: I0cb6e9182530bc2d88975af185a0a8256fae2c2c
This commit is contained in:
Calin Juravle
2021-05-18 08:27:06 -07:00
parent bd5ef43130
commit 303a702a9c
4 changed files with 8 additions and 9 deletions

View File

@@ -674,7 +674,6 @@ public class PackageManagerService extends IPackageManager.Stub
}
// Compilation reasons.
public static final int REASON_UNKNOWN = -1;
public static final int REASON_FIRST_BOOT = 0;
public static final int REASON_BOOT_AFTER_OTA = 1;
public static final int REASON_POST_BOOT = 2;
@@ -687,7 +686,8 @@ public class PackageManagerService extends IPackageManager.Stub
public static final int REASON_BACKGROUND_DEXOPT = 9;
public static final int REASON_AB_OTA = 10;
public static final int REASON_INACTIVE_PACKAGE_DOWNGRADE = 11;
public static final int REASON_SHARED = 12;
public static final int REASON_CMDLINE = 12;
public static final int REASON_SHARED = 13;
public static final int REASON_LAST = REASON_SHARED;
@@ -9967,7 +9967,7 @@ public class PackageManagerService extends IPackageManager.Stub
int flags = (checkProfiles ? DexoptOptions.DEXOPT_CHECK_FOR_PROFILES_UPDATES : 0) |
(force ? DexoptOptions.DEXOPT_FORCE : 0) |
(bootComplete ? DexoptOptions.DEXOPT_BOOT_COMPLETE : 0);
return performDexOpt(new DexoptOptions(packageName, REASON_UNKNOWN,
return performDexOpt(new DexoptOptions(packageName, REASON_CMDLINE,
targetCompilerFilter, splitName, flags));
}

View File

@@ -40,6 +40,7 @@ public class PackageManagerServiceCompilerMapping {
"bg-dexopt",
"ab-ota",
"inactive",
"cmdline",
// "shared" must be the last entry
"shared"
};
@@ -141,9 +142,6 @@ public class PackageManagerServiceCompilerMapping {
}
public static String getReasonName(int reason) {
if (reason == PackageManagerService.REASON_UNKNOWN) {
return "unknown";
}
if (reason < 0 || reason >= REASON_STRINGS.length) {
throw new IllegalArgumentException("reason " + reason + " invalid");
}

View File

@@ -607,6 +607,7 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
TRON_COMPILATION_REASON_INSTALL_BULK_SECONDARY_DOWNGRADED_WITH_DM = 19;
private static final int TRON_COMPILATION_REASON_BOOT_AFTER_OTA = 20;
private static final int TRON_COMPILATION_REASON_POST_BOOT = 21;
private static final int TRON_COMPILATION_REASON_CMDLINE = 22;
// The annotation to add as a suffix to the compilation reason when dexopt was
// performed with dex metadata.
@@ -617,7 +618,7 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
*/
private static int getCompilationReasonTronValue(String compilationReason) {
switch (compilationReason) {
case "unknown" : return TRON_COMPILATION_REASON_UNKNOWN;
case "cmdline" : return TRON_COMPILATION_REASON_CMDLINE;
case "error" : return TRON_COMPILATION_REASON_ERROR;
case "first-boot" : return TRON_COMPILATION_REASON_FIRST_BOOT;
case "boot-after-ota": return TRON_COMPILATION_REASON_BOOT_AFTER_OTA;

View File

@@ -59,8 +59,6 @@ public class ArtStatsLogUtils {
private static final Map<Integer, Integer> COMPILATION_REASON_MAP = new HashMap();
static {
COMPILATION_REASON_MAP.put(PackageManagerService.REASON_UNKNOWN, ArtStatsLog.
ART_DATUM_REPORTED__COMPILATION_REASON__ART_COMPILATION_REASON_UNKNOWN);
COMPILATION_REASON_MAP.put(PackageManagerService.REASON_FIRST_BOOT, ArtStatsLog.
ART_DATUM_REPORTED__COMPILATION_REASON__ART_COMPILATION_REASON_FIRST_BOOT);
COMPILATION_REASON_MAP.put(PackageManagerService.REASON_BOOT_AFTER_OTA, ArtStatsLog.
@@ -86,6 +84,8 @@ public class ArtStatsLogUtils {
COMPILATION_REASON_MAP.put(PackageManagerService.REASON_INACTIVE_PACKAGE_DOWNGRADE,
ArtStatsLog.
ART_DATUM_REPORTED__COMPILATION_REASON__ART_COMPILATION_REASON_INACTIVE);
COMPILATION_REASON_MAP.put(PackageManagerService.REASON_CMDLINE,
ArtStatsLog.ART_DATUM_REPORTED__COMPILATION_REASON__ART_COMPILATION_REASON_CMDLINE);
COMPILATION_REASON_MAP.put(PackageManagerService.REASON_SHARED,
ArtStatsLog.ART_DATUM_REPORTED__COMPILATION_REASON__ART_COMPILATION_REASON_SHARED);
}