Revert^2 "[metrics] Report CompilationReason and CompilerFilter"
Since we do not know the real primary OAT file when the runtime starts
up, we have to wait until NotifyStartupCompleted to be sure we have
the right one. To accomodate this, we delay starting the metrics
session until the first report and then send updated session
information in NotifyStartupCompleted.
Note that we could delay the whole metrics reporting initialization to
NotifyStartupCompleted, but this doesn't get called in all
circumstances, which would mean metrics reporting is disabled in cases
where we want it.
This reverts commit 8b07c653a7e45886ee92d8a12aa439e98e84befa.
Reason for revert: Fixing crash
The bug was get GetPrimaryOatFile could return null in some cases, but
we were not handling this correctly.
Bug: 178239096
Test: manual
Change-Id: I468837ee8f026edd82c47bd216ddb5b2d9c2ece3
diff --git a/libartbase/base/metrics/metrics.h b/libartbase/base/metrics/metrics.h
index 4e3346a..316eb7a 100644
--- a/libartbase/base/metrics/metrics.h
+++ b/libartbase/base/metrics/metrics.h
@@ -83,8 +83,14 @@
kError,
kUnknown,
kFirstBoot,
- kBoot,
+ kBootAfterOTA,
+ kPostBoot,
kInstall,
+ kInstallFast,
+ kInstallBulk,
+ kInstallBulkSecondary,
+ kInstallBulkDowngraded,
+ kInstallBulkSecondaryDowngraded,
kBgDexopt,
kABOTA,
kInactive,
@@ -95,28 +101,90 @@
constexpr const char* CompilationReasonName(CompilationReason reason) {
switch (reason) {
case CompilationReason::kError:
- return "Error";
+ return "error";
case CompilationReason::kUnknown:
- return "Unknown";
+ return "unknown";
case CompilationReason::kFirstBoot:
- return "FirstBoot";
- case CompilationReason::kBoot:
- return "Boot";
+ return "first-boot";
+ case CompilationReason::kBootAfterOTA:
+ return "boot-after-ota";
+ case CompilationReason::kPostBoot:
+ return "post-boot";
case CompilationReason::kInstall:
- return "Install";
+ return "install";
+ case CompilationReason::kInstallFast:
+ return "install-fast";
+ case CompilationReason::kInstallBulk:
+ return "install-bulk";
+ case CompilationReason::kInstallBulkSecondary:
+ return "install-bulk-secondary";
+ case CompilationReason::kInstallBulkDowngraded:
+ return "install-bulk-downgraded";
+ case CompilationReason::kInstallBulkSecondaryDowngraded:
+ return "install-bulk-secondary-downgraded";
case CompilationReason::kBgDexopt:
- return "BgDexopt";
+ return "bg-dexopt";
case CompilationReason::kABOTA:
- return "ABOTA";
+ return "ab-ota";
case CompilationReason::kInactive:
- return "Inactive";
+ return "inactive";
case CompilationReason::kShared:
- return "Shared";
+ return "shared";
case CompilationReason::kInstallWithDexMetadata:
- return "InstallWithDexMetadata";
+ return "install-with-dex-metadata";
}
}
+constexpr CompilationReason CompilationReasonFromName(std::string_view name) {
+ // Names come from PackageManagerServiceCompilerMapping.java
+ if (name == "unknown") {
+ return CompilationReason::kUnknown;
+ }
+ if (name == "first-boot") {
+ return CompilationReason::kFirstBoot;
+ }
+ if (name == "boot-after-ota") {
+ return CompilationReason::kBootAfterOTA;
+ }
+ if (name == "post-boot") {
+ return CompilationReason::kPostBoot;
+ }
+ if (name == "install") {
+ return CompilationReason::kInstall;
+ }
+ if (name == "install-fast") {
+ return CompilationReason::kInstallFast;
+ }
+ if (name == "install-bulk") {
+ return CompilationReason::kInstallBulk;
+ }
+ if (name == "install-bulk-secondary") {
+ return CompilationReason::kInstallBulkSecondary;
+ }
+ if (name == "install-bulk-downgraded") {
+ return CompilationReason::kInstallBulkDowngraded;
+ }
+ if (name == "install-bulk-secondary-downgraded") {
+ return CompilationReason::kInstallBulkSecondaryDowngraded;
+ }
+ if (name == "bg-dexopt") {
+ return CompilationReason::kBgDexopt;
+ }
+ if (name == "ab-ota") {
+ return CompilationReason::kABOTA;
+ }
+ if (name == "inactive") {
+ return CompilationReason::kInactive;
+ }
+ if (name == "shared") {
+ return CompilationReason::kShared;
+ }
+ if (name == "install-with-dex-metadata") {
+ return CompilationReason::kInstallWithDexMetadata;
+ }
+ return CompilationReason::kError;
+}
+
// SessionData contains metadata about a metrics session (basically the lifetime of an ART process).
// This information should not change for the lifetime of the session.
struct SessionData {