Merge "Up the dimension key limit for CpuTimePerUidFreq" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
dafbeecaf7
@@ -92,6 +92,10 @@ const int FIELD_ID_UID_MAP_BYTES_USED = 3;
|
|||||||
const int FIELD_ID_UID_MAP_DROPPED_SNAPSHOTS = 4;
|
const int FIELD_ID_UID_MAP_DROPPED_SNAPSHOTS = 4;
|
||||||
const int FIELD_ID_UID_MAP_DROPPED_CHANGES = 5;
|
const int FIELD_ID_UID_MAP_DROPPED_CHANGES = 5;
|
||||||
|
|
||||||
|
const std::map<int, std::pair<size_t, size_t>> StatsdStats::kAtomDimensionKeySizeLimitMap = {
|
||||||
|
{android::util::CPU_TIME_PER_UID_FREQ, {6000, 10000}},
|
||||||
|
};
|
||||||
|
|
||||||
// TODO: add stats for pulled atoms.
|
// TODO: add stats for pulled atoms.
|
||||||
StatsdStats::StatsdStats() {
|
StatsdStats::StatsdStats() {
|
||||||
mPushedAtomStats.resize(android::util::kMaxPushedAtomId + 1);
|
mPushedAtomStats.resize(android::util::kMaxPushedAtomId + 1);
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ public:
|
|||||||
const static int kDimensionKeySizeSoftLimit = 300;
|
const static int kDimensionKeySizeSoftLimit = 300;
|
||||||
const static int kDimensionKeySizeHardLimit = 500;
|
const static int kDimensionKeySizeHardLimit = 500;
|
||||||
|
|
||||||
|
// Per atom dimension key size limit
|
||||||
|
static const std::map<int, std::pair<size_t, size_t>> kAtomDimensionKeySizeLimitMap;
|
||||||
|
|
||||||
const static int kMaxConfigCount = 10;
|
const static int kMaxConfigCount = 10;
|
||||||
const static int kMaxAlertCountPerConfig = 100;
|
const static int kMaxAlertCountPerConfig = 100;
|
||||||
const static int kMaxConditionCountPerConfig = 200;
|
const static int kMaxConditionCountPerConfig = 200;
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
#define DEBUG false // STOPSHIP if true
|
#define DEBUG false // STOPSHIP if true
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
#include "../guardrail/StatsdStats.h"
|
||||||
#include "GaugeMetricProducer.h"
|
#include "GaugeMetricProducer.h"
|
||||||
#include "guardrail/StatsdStats.h"
|
#include "../stats_log_util.h"
|
||||||
#include "stats_log_util.h"
|
|
||||||
|
|
||||||
#include <cutils/log.h>
|
#include <cutils/log.h>
|
||||||
|
|
||||||
@@ -60,12 +60,20 @@ const int FIELD_ID_WALL_CLOCK_ATOM_TIMESTAMP = 5;
|
|||||||
|
|
||||||
GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric& metric,
|
GaugeMetricProducer::GaugeMetricProducer(const ConfigKey& key, const GaugeMetric& metric,
|
||||||
const int conditionIndex,
|
const int conditionIndex,
|
||||||
const sp<ConditionWizard>& wizard,
|
const sp<ConditionWizard>& wizard, const int pullTagId,
|
||||||
const int pullTagId, const uint64_t startTimeNs,
|
const uint64_t startTimeNs,
|
||||||
shared_ptr<StatsPullerManager> statsPullerManager)
|
shared_ptr<StatsPullerManager> statsPullerManager)
|
||||||
: MetricProducer(metric.id(), key, startTimeNs, conditionIndex, wizard),
|
: MetricProducer(metric.id(), key, startTimeNs, conditionIndex, wizard),
|
||||||
mStatsPullerManager(statsPullerManager),
|
mStatsPullerManager(statsPullerManager),
|
||||||
mPullTagId(pullTagId) {
|
mPullTagId(pullTagId),
|
||||||
|
mDimensionSoftLimit(StatsdStats::kAtomDimensionKeySizeLimitMap.find(pullTagId) !=
|
||||||
|
StatsdStats::kAtomDimensionKeySizeLimitMap.end()
|
||||||
|
? StatsdStats::kAtomDimensionKeySizeLimitMap.at(pullTagId).first
|
||||||
|
: StatsdStats::kDimensionKeySizeSoftLimit),
|
||||||
|
mDimensionHardLimit(StatsdStats::kAtomDimensionKeySizeLimitMap.find(pullTagId) !=
|
||||||
|
StatsdStats::kAtomDimensionKeySizeLimitMap.end()
|
||||||
|
? StatsdStats::kAtomDimensionKeySizeLimitMap.at(pullTagId).second
|
||||||
|
: StatsdStats::kDimensionKeySizeHardLimit) {
|
||||||
mCurrentSlicedBucket = std::make_shared<DimToGaugeAtomsMap>();
|
mCurrentSlicedBucket = std::make_shared<DimToGaugeAtomsMap>();
|
||||||
mCurrentSlicedBucketForAnomaly = std::make_shared<DimToValMap>();
|
mCurrentSlicedBucketForAnomaly = std::make_shared<DimToValMap>();
|
||||||
int64_t bucketSizeMills = 0;
|
int64_t bucketSizeMills = 0;
|
||||||
@@ -305,11 +313,11 @@ bool GaugeMetricProducer::hitGuardRailLocked(const MetricDimensionKey& newKey) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 1. Report the tuple count if the tuple count > soft limit
|
// 1. Report the tuple count if the tuple count > soft limit
|
||||||
if (mCurrentSlicedBucket->size() > StatsdStats::kDimensionKeySizeSoftLimit - 1) {
|
if (mCurrentSlicedBucket->size() > mDimensionSoftLimit - 1) {
|
||||||
size_t newTupleCount = mCurrentSlicedBucket->size() + 1;
|
size_t newTupleCount = mCurrentSlicedBucket->size() + 1;
|
||||||
StatsdStats::getInstance().noteMetricDimensionSize(mConfigKey, mMetricId, newTupleCount);
|
StatsdStats::getInstance().noteMetricDimensionSize(mConfigKey, mMetricId, newTupleCount);
|
||||||
// 2. Don't add more tuples, we are above the allowed threshold. Drop the data.
|
// 2. Don't add more tuples, we are above the allowed threshold. Drop the data.
|
||||||
if (newTupleCount > StatsdStats::kDimensionKeySizeHardLimit) {
|
if (newTupleCount > mDimensionHardLimit) {
|
||||||
ALOGE("GaugeMetric %lld dropping data for dimension key %s",
|
ALOGE("GaugeMetric %lld dropping data for dimension key %s",
|
||||||
(long long)mMetricId, newKey.toString().c_str());
|
(long long)mMetricId, newKey.toString().c_str());
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -150,6 +150,10 @@ private:
|
|||||||
|
|
||||||
static const size_t kBucketSize = sizeof(GaugeBucket{});
|
static const size_t kBucketSize = sizeof(GaugeBucket{});
|
||||||
|
|
||||||
|
const size_t mDimensionSoftLimit;
|
||||||
|
|
||||||
|
const size_t mDimensionHardLimit;
|
||||||
|
|
||||||
FRIEND_TEST(GaugeMetricProducerTest, TestWithCondition);
|
FRIEND_TEST(GaugeMetricProducerTest, TestWithCondition);
|
||||||
FRIEND_TEST(GaugeMetricProducerTest, TestNoCondition);
|
FRIEND_TEST(GaugeMetricProducerTest, TestNoCondition);
|
||||||
FRIEND_TEST(GaugeMetricProducerTest, TestPushedEventsWithUpgrade);
|
FRIEND_TEST(GaugeMetricProducerTest, TestPushedEventsWithUpgrade);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
#include "ValueMetricProducer.h"
|
#include "ValueMetricProducer.h"
|
||||||
#include "guardrail/StatsdStats.h"
|
#include "../guardrail/StatsdStats.h"
|
||||||
#include "stats_log_util.h"
|
#include "../stats_log_util.h"
|
||||||
|
|
||||||
#include <cutils/log.h>
|
#include <cutils/log.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@@ -68,7 +68,15 @@ ValueMetricProducer::ValueMetricProducer(const ConfigKey& key, const ValueMetric
|
|||||||
: MetricProducer(metric.id(), key, startTimeNs, conditionIndex, wizard),
|
: MetricProducer(metric.id(), key, startTimeNs, conditionIndex, wizard),
|
||||||
mValueField(metric.value_field()),
|
mValueField(metric.value_field()),
|
||||||
mStatsPullerManager(statsPullerManager),
|
mStatsPullerManager(statsPullerManager),
|
||||||
mPullTagId(pullTagId) {
|
mPullTagId(pullTagId),
|
||||||
|
mDimensionSoftLimit(StatsdStats::kAtomDimensionKeySizeLimitMap.find(pullTagId) !=
|
||||||
|
StatsdStats::kAtomDimensionKeySizeLimitMap.end()
|
||||||
|
? StatsdStats::kAtomDimensionKeySizeLimitMap.at(pullTagId).first
|
||||||
|
: StatsdStats::kDimensionKeySizeSoftLimit),
|
||||||
|
mDimensionHardLimit(StatsdStats::kAtomDimensionKeySizeLimitMap.find(pullTagId) !=
|
||||||
|
StatsdStats::kAtomDimensionKeySizeLimitMap.end()
|
||||||
|
? StatsdStats::kAtomDimensionKeySizeLimitMap.at(pullTagId).second
|
||||||
|
: StatsdStats::kDimensionKeySizeHardLimit) {
|
||||||
// TODO: valuemetric for pushed events may need unlimited bucket length
|
// TODO: valuemetric for pushed events may need unlimited bucket length
|
||||||
int64_t bucketSizeMills = 0;
|
int64_t bucketSizeMills = 0;
|
||||||
if (metric.has_bucket()) {
|
if (metric.has_bucket()) {
|
||||||
@@ -266,11 +274,11 @@ bool ValueMetricProducer::hitGuardRailLocked(const MetricDimensionKey& newKey) {
|
|||||||
if (mCurrentSlicedBucket.find(newKey) != mCurrentSlicedBucket.end()) {
|
if (mCurrentSlicedBucket.find(newKey) != mCurrentSlicedBucket.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mCurrentSlicedBucket.size() > StatsdStats::kDimensionKeySizeSoftLimit - 1) {
|
if (mCurrentSlicedBucket.size() > mDimensionSoftLimit - 1) {
|
||||||
size_t newTupleCount = mCurrentSlicedBucket.size() + 1;
|
size_t newTupleCount = mCurrentSlicedBucket.size() + 1;
|
||||||
StatsdStats::getInstance().noteMetricDimensionSize(mConfigKey, mMetricId, newTupleCount);
|
StatsdStats::getInstance().noteMetricDimensionSize(mConfigKey, mMetricId, newTupleCount);
|
||||||
// 2. Don't add more tuples, we are above the allowed threshold. Drop the data.
|
// 2. Don't add more tuples, we are above the allowed threshold. Drop the data.
|
||||||
if (newTupleCount > StatsdStats::kDimensionKeySizeHardLimit) {
|
if (newTupleCount > mDimensionHardLimit) {
|
||||||
ALOGE("ValueMetric %lld dropping data for dimension key %s",
|
ALOGE("ValueMetric %lld dropping data for dimension key %s",
|
||||||
(long long)mMetricId, newKey.toString().c_str());
|
(long long)mMetricId, newKey.toString().c_str());
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -149,6 +149,10 @@ private:
|
|||||||
|
|
||||||
static const size_t kBucketSize = sizeof(ValueBucket{});
|
static const size_t kBucketSize = sizeof(ValueBucket{});
|
||||||
|
|
||||||
|
const size_t mDimensionSoftLimit;
|
||||||
|
|
||||||
|
const size_t mDimensionHardLimit;
|
||||||
|
|
||||||
FRIEND_TEST(ValueMetricProducerTest, TestNonDimensionalEvents);
|
FRIEND_TEST(ValueMetricProducerTest, TestNonDimensionalEvents);
|
||||||
FRIEND_TEST(ValueMetricProducerTest, TestEventsWithNonSlicedCondition);
|
FRIEND_TEST(ValueMetricProducerTest, TestEventsWithNonSlicedCondition);
|
||||||
FRIEND_TEST(ValueMetricProducerTest, TestPushedEventsWithUpgrade);
|
FRIEND_TEST(ValueMetricProducerTest, TestPushedEventsWithUpgrade);
|
||||||
|
|||||||
Reference in New Issue
Block a user