Throttle metric writing by 3 seconds
After aosp/2320000 , pref writes are atomic but slower. Since
update_engine frequently writes metrics such as bytes downloaded to
disk, update time is negatively impacted. Throttle metric writing to
mitigate.
Bug: 259174530
Test: th
Change-Id: I09be219fa08d5569a5cb5b808e07da3d71a8131c
diff --git a/common/metrics_constants.h b/common/metrics_constants.h
index b7633b9..af40300 100644
--- a/common/metrics_constants.h
+++ b/common/metrics_constants.h
@@ -17,6 +17,7 @@
#ifndef UPDATE_ENGINE_COMMON_METRICS_CONSTANTS_H_
#define UPDATE_ENGINE_COMMON_METRICS_CONSTANTS_H_
+#include <chrono>
namespace chromeos_update_engine {
namespace metrics {
@@ -140,6 +141,8 @@
kNumConstants
};
+constexpr auto kMetricFlushInterval = std::chrono::seconds(3);
+
} // namespace metrics
} // namespace chromeos_update_engine
diff --git a/common/utils.cc b/common/utils.cc
index 6b8bc54..4c1365a 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -56,8 +56,8 @@
#include <brillo/data_encoding.h>
#include "update_engine/common/constants.h"
-#include "update_engine/common/platform_constants.h"
#include "update_engine/common/subprocess.h"
+#include "update_engine/common/platform_constants.h"
#include "update_engine/payload_consumer/file_descriptor.h"
using base::Time;