summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2023-05-24 08:18:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-05-24 08:18:21 +0000
commit5f2d8c987b585ca62fe2d3194776461170b34e39 (patch)
treeb507ae4608bd2fafe563faa058121efb3da10131
parent8b499332bd1ecf73d93a41c7532a0d0e11682120 (diff)
parentfb8ffc40feb548d4201825da21d10038cf80e2e6 (diff)
downloadpixel-5f2d8c987b585ca62fe2d3194776461170b34e39.tar.gz
Merge changes from topic "stats_cleanup" into udc-dev
* changes: thermal: stats: Reduce atom field suffix size thermal: stats: Combine initial threshold_buckets for cdev default enable
-rw-r--r--thermal/utils/thermal_info.h3
-rw-r--r--thermal/utils/thermal_stats_helper.cpp27
2 files changed, 24 insertions, 6 deletions
diff --git a/thermal/utils/thermal_info.h b/thermal/utils/thermal_info.h
index da9585a8..5b2e8b80 100644
--- a/thermal/utils/thermal_info.h
+++ b/thermal/utils/thermal_info.h
@@ -42,7 +42,8 @@ constexpr std::chrono::milliseconds kMinPollIntervalMs = std::chrono::millisecon
constexpr std::chrono::milliseconds kUeventPollTimeoutMs = std::chrono::milliseconds(300000);
// Max number of time_in_state buckets is 20 in atoms
// VendorSensorCoolingDeviceStats, VendorTempResidencyStats
-constexpr size_t kMaxStatsThresholdCount = 19;
+constexpr int kMaxStatsResidencyCount = 20;
+constexpr int kMaxStatsThresholdCount = kMaxStatsResidencyCount - 1;
enum FormulaOption : uint32_t {
COUNT_THRESHOLD = 0,
diff --git a/thermal/utils/thermal_stats_helper.cpp b/thermal/utils/thermal_stats_helper.cpp
index 27ac3190..d9a2a65a 100644
--- a/thermal/utils/thermal_stats_helper.cpp
+++ b/thermal/utils/thermal_stats_helper.cpp
@@ -21,6 +21,7 @@
#include <hardware/google/pixel/pixelstats/pixelatoms.pb.h>
#include <algorithm>
+#include <numeric>
#include <string_view>
namespace aidl {
@@ -29,7 +30,8 @@ namespace hardware {
namespace thermal {
namespace implementation {
-constexpr std::string_view kCustomThresholdSetSuffix("-THRESHOLD-LIST-");
+constexpr std::string_view kCustomThresholdSetSuffix("-TH-");
+constexpr std::string_view kCompressedThresholdSuffix("-CMBN-TH");
using aidl::android::frameworks::stats::VendorAtom;
namespace PixelAtoms = ::android::hardware::google::pixel::PixelAtoms;
@@ -109,10 +111,25 @@ bool ThermalStatsHelper::initializeSensorCdevRequestStats(
// Record by all state
if (isRecordByDefaultThreshold(
request_stats_info.record_by_default_threshold_all_or_name_set_, cdev)) {
- // buckets = [0, 1, 2, 3, ...max_state]
- const int default_threshold_time_in_state_size = max_state + 1;
- sensor_cdev_request_stats_map_[sensor][cdev].stats_by_default_threshold =
- StatsRecord(default_threshold_time_in_state_size);
+ // if the number of states is greater / equal(as state starts from 0) than
+ // residency_buckets in atom combine the initial states
+ if (max_state >= kMaxStatsResidencyCount) {
+ // buckets = [max_state -kMaxStatsResidencyCount + 1, ...max_state]
+ // idx = [1, .. max_state - (max_state - kMaxStatsResidencyCount + 1) + 1]
+ // idx = [1, .. kMaxStatsResidencyCount]
+ const auto starting_state = max_state - kMaxStatsResidencyCount + 1;
+ std::vector<int> thresholds(kMaxStatsResidencyCount);
+ std::iota(thresholds.begin(), thresholds.end(), starting_state);
+ const auto logging_name = cdev + kCompressedThresholdSuffix.data();
+ ThresholdList<int> threshold_list(logging_name, thresholds);
+ sensor_cdev_request_stats_map_[sensor][cdev]
+ .stats_by_custom_threshold.emplace_back(threshold_list);
+ } else {
+ // buckets = [0, 1, 2, 3, ...max_state]
+ const auto default_threshold_time_in_state_size = max_state + 1;
+ sensor_cdev_request_stats_map_[sensor][cdev].stats_by_default_threshold =
+ StatsRecord(default_threshold_time_in_state_size);
+ }
LOG(INFO) << "Sensor Cdev user vote stats on basis of all state initialized for ["
<< sensor << "-" << cdev << "]";
}