summaryrefslogtreecommitdiffstats
path: root/bootstat
diff options
context:
space:
mode:
authorTej Singh <singhtejinder@google.com>2018-02-06 15:57:38 -0800
committerMark Salyzyn <salyzyn@google.com>2018-06-04 13:31:05 -0700
commit993f65619e534d29a1e63cdc3d76a5bdec97225b (patch)
treef4722454450fb1ac0039c4851d7c67494fd54f44 /bootstat
parentdc17e9efa043dc74c177c50834937a84457aaf3f (diff)
downloadsystem_core-993f65619e534d29a1e63cdc3d76a5bdec97225b.tar.gz
system_core-993f65619e534d29a1e63cdc3d76a5bdec97225b.tar.bz2
system_core-993f65619e534d29a1e63cdc3d76a5bdec97225b.zip
Fix performance degradation from BootSequence atom
(partial cherry pick from commit fe3e762b6de94ab43b3019d38cdc2abfad3a786c) Adding the boot sequence reported atom in ag/3518079 caused the duration of bootstat to increase, as seen in b/72864061. I isolated the cause down to calling BootReasonStrToReason. However, this function also gets called in ReportBootReason, so I created another function that does the parsing and sets the system boot reason property, and made RecordBootReason and statsd logging get that property. Bug: 72864061 Test: rebooted phone, verified boot events were received in adb shell logcat -b stats and verified adb shell bootstat -p printed correct values. Ran timing tests as well on walleye with 20 boots: before this change, the average was ~150-160ms. After, it was ~80ms. Change-Id: I92dbc9880328835647be7d9d50c7861b42f27bdb Merged-In: I92dbc9880328835647be7d9d50c7861b42f27bdb
Diffstat (limited to 'bootstat')
-rw-r--r--bootstat/bootstat.cpp33
-rw-r--r--bootstat/bootstat.rc3
2 files changed, 23 insertions, 13 deletions
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index 529d0c942..d5fb0472f 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -1129,6 +1129,13 @@ android::base::boot_clock::duration GetUptime() {
return android::base::boot_clock::now().time_since_epoch() - GetBootTimeOffset();
}
+void SetSystemBootReason() {
+ const std::string bootloader_boot_reason(GetProperty(bootloader_reboot_reason_property));
+ const std::string system_boot_reason(BootReasonStrToReason(bootloader_boot_reason));
+ // Record the scrubbed system_boot_reason to the property
+ SetProperty(system_reboot_reason_property, system_boot_reason);
+}
+
// Records several metrics related to the time it takes to boot the device,
// including disambiguating boot time on encrypted or non-encrypted devices.
void RecordBootComplete() {
@@ -1208,12 +1215,10 @@ void RecordBootReason() {
boot_event_store.AddBootEventWithValue("boot_reason", boot_reason);
// Log the scrubbed system_boot_reason.
- const std::string system_reason(BootReasonStrToReason(reason));
+ const std::string system_reason(GetProperty(system_reboot_reason_property));
int32_t system_boot_reason = BootReasonStrToEnum(system_reason);
boot_event_store.AddBootEventWithValue("system_boot_reason", system_boot_reason);
- // Record the scrubbed system_boot_reason to the property
- SetProperty(system_reboot_reason_property, system_reason);
if (reason == "") {
SetProperty(bootloader_reboot_reason_property, system_reason);
}
@@ -1279,20 +1284,22 @@ int main(int argc, char** argv) {
int option_index = 0;
static const char value_str[] = "value";
+ static const char system_boot_reason_str[] = "set_system_boot_reason";
static const char boot_complete_str[] = "record_boot_complete";
static const char boot_reason_str[] = "record_boot_reason";
static const char factory_reset_str[] = "record_time_since_factory_reset";
static const struct option long_options[] = {
// clang-format off
- { "help", no_argument, NULL, 'h' },
- { "log", no_argument, NULL, 'l' },
- { "print", no_argument, NULL, 'p' },
- { "record", required_argument, NULL, 'r' },
- { value_str, required_argument, NULL, 0 },
- { boot_complete_str, no_argument, NULL, 0 },
- { boot_reason_str, no_argument, NULL, 0 },
- { factory_reset_str, no_argument, NULL, 0 },
- { NULL, 0, NULL, 0 }
+ { "help", no_argument, NULL, 'h' },
+ { "log", no_argument, NULL, 'l' },
+ { "print", no_argument, NULL, 'p' },
+ { "record", required_argument, NULL, 'r' },
+ { value_str, required_argument, NULL, 0 },
+ { system_boot_reason_str, no_argument, NULL, 0 },
+ { boot_complete_str, no_argument, NULL, 0 },
+ { boot_reason_str, no_argument, NULL, 0 },
+ { factory_reset_str, no_argument, NULL, 0 },
+ { NULL, 0, NULL, 0 }
// clang-format on
};
@@ -1308,6 +1315,8 @@ int main(int argc, char** argv) {
// |optarg| is an external variable set by getopt representing
// the option argument.
value = optarg;
+ } else if (option_name == system_boot_reason_str) {
+ SetSystemBootReason();
} else if (option_name == boot_complete_str) {
RecordBootComplete();
} else if (option_name == boot_reason_str) {
diff --git a/bootstat/bootstat.rc b/bootstat/bootstat.rc
index f06a38ff1..1300a277a 100644
--- a/bootstat/bootstat.rc
+++ b/bootstat/bootstat.rc
@@ -68,8 +68,9 @@ on property:init.svc.zygote=stopping
# Record boot complete metrics.
on property:sys.boot_completed=1 && property:sys.logbootcomplete=1
+ # Converts bootloader boot reason to system boot reason
# Record boot_complete and related stats (decryption, etc).
# Record the boot reason.
# Record time since factory reset.
# Log all boot events.
- exec_background - system log -- /system/bin/bootstat --record_boot_complete --record_boot_reason --record_time_since_factory_reset -l
+ exec_background - system log -- /system/bin/bootstat --set_system_boot_reason --record_boot_complete --record_boot_reason --record_time_since_factory_reset -l