diff options
author | Robin Hsu <robinhsu@google.com> | 2022-07-06 12:44:34 +0800 |
---|---|---|
committer | Robin Hsu <robinhsu@google.com> | 2022-08-23 08:14:42 +0000 |
commit | 6a8de948f151cda6033454809de332582c0a6272 (patch) | |
tree | 5881bf9a167a8c651f6e1a50bdc2e71977af0a8b | |
parent | fdb36c83b5bf220c8fdd234fe52f285587458d9d (diff) |
pixelstat: MM metrics: framework change
Some small change in the MM metrics framework:
* Previously preparing atom by a vector "values", and the vector is
keep resized per module added in. This CL calculates the last index
and allocate space for the vector once for all. Note that
later on, if we want to add or remove some metrics, we need to change
the last index to keep it sync to the last metric proto file.
* Add version for 'PixelMmMetricsPerHour' and 'PixelMmMetricsPerday'
(and it is the last metrics as defined in the design doc)
Test: n/a
Bug: 234564667
Signed-off-by: Robin Hsu <robinhsu@google.com>
Change-Id: I35da187f9318e8aed089c3676d8c6df815913f02
-rw-r--r-- | pixelstats/MmMetricsReporter.cpp | 23 | ||||
-rw-r--r-- | pixelstats/include/pixelstats/MmMetricsReporter.h | 2 |
2 files changed, 15 insertions, 10 deletions
diff --git a/pixelstats/MmMetricsReporter.cpp b/pixelstats/MmMetricsReporter.cpp index 4a2a087..c93f0d9 100644 --- a/pixelstats/MmMetricsReporter.cpp +++ b/pixelstats/MmMetricsReporter.cpp @@ -312,16 +312,14 @@ void MmMetricsReporter::logPixelMmMetricsPerHour(const std::shared_ptr<IStats> & uint64_t ion_total_pools = getIonTotalPools(); uint64_t gpu_memory = getGpuMemory(); - std::vector<VendorAtomValue> values; - fillAtomValues(kMmMetricsPerHourInfo, vmstat, &prev_hour_vmstat_, &values); - - // resize values to add the following fields + // allocate enough values[] entries for the metrics. VendorAtomValue tmp; tmp.set<VendorAtomValue::longValue>(0); - int size = PixelMmMetricsPerHour::kGpuMemoryFieldNumber - kVendorAtomOffset + 1; - if (values.size() < size) { - values.resize(size, tmp); - } + int last_value_index = + PixelMmMetricsPerHour::kPsiMemSomeAvg300AvgFieldNumber - kVendorAtomOffset; + std::vector<VendorAtomValue> values(last_value_index + 1, tmp); + + fillAtomValues(kMmMetricsPerHourInfo, vmstat, &prev_hour_vmstat_, &values); tmp.set<VendorAtomValue::longValue>(ion_total_pools); values[PixelMmMetricsPerHour::kIonTotalPoolsFieldNumber - kVendorAtomOffset] = tmp; tmp.set<VendorAtomValue::longValue>(gpu_memory); @@ -340,8 +338,15 @@ void MmMetricsReporter::logPixelMmMetricsPerDay(const std::shared_ptr<IStats> &s if (vmstat.size() == 0) return; - std::vector<VendorAtomValue> values; bool is_first_atom = (prev_day_vmstat_.size() == 0) ? true : false; + + // allocate enough values[] entries for the metrics. + VendorAtomValue tmp; + tmp.set<VendorAtomValue::longValue>(0); + int last_value_index = + PixelMmMetricsPerDay::kThpDeferredSplitPageFieldNumber - kVendorAtomOffset; + std::vector<VendorAtomValue> values(last_value_index + 1, tmp); + fillAtomValues(kMmMetricsPerDayInfo, vmstat, &prev_day_vmstat_, &values); std::map<std::string, uint64_t> pixel_vmstat = diff --git a/pixelstats/include/pixelstats/MmMetricsReporter.h b/pixelstats/include/pixelstats/MmMetricsReporter.h index 89f12f5..d867086 100644 --- a/pixelstats/include/pixelstats/MmMetricsReporter.h +++ b/pixelstats/include/pixelstats/MmMetricsReporter.h @@ -107,7 +107,7 @@ class MmMetricsReporter { // Proto messages are 1-indexed and VendorAtom field numbers start at 2, so // store everything in the values array at the index of the field number // -2. - const int kVendorAtomOffset = 2; + static constexpr int kVendorAtomOffset = 2; std::map<std::string, uint64_t> prev_hour_vmstat_; std::map<std::string, uint64_t> prev_day_vmstat_; |