From 85d364d4de7db5235c23affaccd7211b1aa42bab Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 16 Aug 2026 18:24:01 -0700 Subject: [PATCH] loggerd: fix ~0.5s startup logging delay (#38649) --- openpilot/common/hardware/base.h | 2 +- openpilot/common/hardware/comma/hardware.h | 16 +++++++++------- openpilot/system/loggerd/logger.cc | 6 +++--- openpilot/system/loggerd/logger.h | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/openpilot/common/hardware/base.h b/openpilot/common/hardware/base.h index f4546adfa8..53db48ff5b 100644 --- a/openpilot/common/hardware/base.h +++ b/openpilot/common/hardware/base.h @@ -15,7 +15,7 @@ public: static std::string get_serial() { return "cccccc"; } - static std::map get_init_logs() { + static std::map get_init_logs(bool route_log = false) { return {}; } diff --git a/openpilot/common/hardware/comma/hardware.h b/openpilot/common/hardware/comma/hardware.h index 6292183d9d..7bb9074f6b 100644 --- a/openpilot/common/hardware/comma/hardware.h +++ b/openpilot/common/hardware/comma/hardware.h @@ -59,7 +59,7 @@ public: std::ofstream("/sys/class/leds/led:switch_2/brightness") << value << "\n"; } - static std::map get_init_logs() { + static std::map get_init_logs(bool route_log = false) { std::map ret = { {"/BUILD", util::read_file("/BUILD")}, {"lsblk", util::check_output("lsblk -o NAME,SIZE,STATE,VENDOR,MODEL,REV,SERIAL")}, @@ -73,12 +73,14 @@ public: temp.erase(temp.find_last_not_of(std::string("\0\r\n", 3))+1); ret["boot temp"] = temp; - // TODO: log something from system and boot - for (std::string part : {"xbl", "abl", "aop", "devcfg", "xbl_config"}) { - for (std::string slot : {"a", "b"}) { - std::string partition = part + "_" + slot; - std::string hash = util::check_output("sha256sum /dev/disk/by-partlabel/" + partition); - ret[partition] = hash.substr(0, hash.find_first_of(" ")); + // TODO: these are too slow to do on route log inits. need to do it async? + if (!route_log) { + for (std::string part : {"xbl", "abl", "aop", "devcfg", "xbl_config"}) { + for (std::string slot : {"a", "b"}) { + std::string partition = part + "_" + slot; + std::string hash = util::check_output("sha256sum /dev/disk/by-partlabel/" + partition); + ret[partition] = hash.substr(0, hash.find_first_of(" ")); + } } } diff --git a/openpilot/system/loggerd/logger.cc b/openpilot/system/loggerd/logger.cc index 0ebe323939..f553760016 100644 --- a/openpilot/system/loggerd/logger.cc +++ b/openpilot/system/loggerd/logger.cc @@ -12,7 +12,7 @@ #include "common/version.h" // ***** log metadata ***** -kj::Array logger_build_init_data() { +kj::Array logger_build_init_data(bool route_log) { uint64_t wall_time = nanos_since_epoch(); MessageBuilder msg; @@ -70,7 +70,7 @@ kj::Array logger_build_init_data() { "df -h", // usage for all filesystems }; - auto hw_logs = Hardware::get_init_logs(); + auto hw_logs = Hardware::get_init_logs(route_log); auto commands = init.initCommands().initEntries(log_commands.size() + hw_logs.size()); for (int i = 0; i < log_commands.size(); i++) { @@ -164,7 +164,7 @@ static void log_sentinel(LoggerState *log, SentinelType type, int exit_signal = LoggerState::LoggerState(const std::string &log_root) { route_name = logger_get_identifier("RouteCount"); route_path = log_root + "/" + route_name; - init_data = logger_build_init_data(); + init_data = logger_build_init_data(true); } LoggerState::~LoggerState() { diff --git a/openpilot/system/loggerd/logger.h b/openpilot/system/loggerd/logger.h index 419becfe5d..17c29d1a02 100644 --- a/openpilot/system/loggerd/logger.h +++ b/openpilot/system/loggerd/logger.h @@ -32,6 +32,6 @@ protected: std::unique_ptr rlog, qlog; }; -kj::Array logger_build_init_data(); +kj::Array logger_build_init_data(bool route_log = false); std::string logger_get_identifier(std::string key); std::string zstd_decompress(const std::string &in);