Statsd: Remove storage of bucketNum
Past buckets had a field mBucketNum, storing the "bucket number" they represented. Currently, the concept of bucket number is used by Anomaly Detection (although this may not be necessary), but these stored values are not used at all, so removing them will save RAM. Test: statsd tests still pass Bug: 74607818 Change-Id: Iacc343bc39c5035f6e2f236c03de1d91606eff4c
This commit is contained in:
@@ -249,7 +249,6 @@ void CountMetricProducer::flushCurrentBucketLocked(const uint64_t& eventTimeNs)
|
||||
} else {
|
||||
info.mBucketEndNs = fullBucketEndTimeNs;
|
||||
}
|
||||
info.mBucketNum = mCurrentBucketNum;
|
||||
for (const auto& counter : *mCurrentSlicedCounter) {
|
||||
info.mCount = counter.second;
|
||||
auto& bucketList = mPastBuckets[counter.first];
|
||||
|
||||
@@ -36,7 +36,6 @@ struct CountBucket {
|
||||
int64_t mBucketStartNs;
|
||||
int64_t mBucketEndNs;
|
||||
int64_t mCount;
|
||||
uint64_t mBucketNum;
|
||||
};
|
||||
|
||||
class CountMetricProducer : public MetricProducer {
|
||||
|
||||
@@ -393,7 +393,6 @@ void GaugeMetricProducer::flushCurrentBucketLocked(const uint64_t& eventTimeNs)
|
||||
} else {
|
||||
info.mBucketEndNs = fullBucketEndTimeNs;
|
||||
}
|
||||
info.mBucketNum = mCurrentBucketNum;
|
||||
|
||||
for (const auto& slice : *mCurrentSlicedBucket) {
|
||||
info.mGaugeAtoms = slice.second;
|
||||
|
||||
@@ -44,7 +44,6 @@ struct GaugeBucket {
|
||||
int64_t mBucketStartNs;
|
||||
int64_t mBucketEndNs;
|
||||
std::vector<GaugeAtom> mGaugeAtoms;
|
||||
uint64_t mBucketNum;
|
||||
};
|
||||
|
||||
typedef std::unordered_map<MetricDimensionKey, std::vector<GaugeAtom>>
|
||||
|
||||
@@ -355,7 +355,6 @@ void ValueMetricProducer::flushCurrentBucketLocked(const uint64_t& eventTimeNs)
|
||||
} else {
|
||||
info.mBucketEndNs = fullBucketEndTimeNs;
|
||||
}
|
||||
info.mBucketNum = mCurrentBucketNum;
|
||||
|
||||
int tainted = 0;
|
||||
for (const auto& slice : mCurrentSlicedBucket) {
|
||||
|
||||
@@ -34,7 +34,6 @@ struct ValueBucket {
|
||||
int64_t mBucketStartNs;
|
||||
int64_t mBucketEndNs;
|
||||
int64_t mValue;
|
||||
uint64_t mBucketNum;
|
||||
};
|
||||
|
||||
class ValueMetricProducer : public virtual MetricProducer, public virtual PullDataReceiver {
|
||||
|
||||
@@ -55,7 +55,6 @@ struct DurationBucket {
|
||||
uint64_t mBucketStartNs;
|
||||
uint64_t mBucketEndNs;
|
||||
uint64_t mDuration;
|
||||
uint64_t mBucketNum;
|
||||
};
|
||||
|
||||
class DurationTracker {
|
||||
|
||||
@@ -219,7 +219,6 @@ bool MaxDurationTracker::flushCurrentBucket(
|
||||
DurationBucket info;
|
||||
info.mBucketStartNs = mCurrentBucketStartTimeNs;
|
||||
info.mBucketEndNs = currentBucketEndTimeNs;
|
||||
info.mBucketNum = mCurrentBucketNum;
|
||||
info.mDuration = mDuration;
|
||||
(*output)[mEventKey].push_back(info);
|
||||
VLOG(" final duration for last bucket: %lld", (long long)mDuration);
|
||||
|
||||
@@ -165,13 +165,12 @@ bool OringDurationTracker::flushCurrentBucket(
|
||||
DurationBucket current_info;
|
||||
current_info.mBucketStartNs = mCurrentBucketStartTimeNs;
|
||||
current_info.mBucketEndNs = currentBucketEndTimeNs;
|
||||
current_info.mBucketNum = mCurrentBucketNum;
|
||||
current_info.mDuration = mDuration;
|
||||
(*output)[mEventKey].push_back(current_info);
|
||||
mDurationFullBucket += mDuration;
|
||||
if (eventTimeNs > fullBucketEnd) {
|
||||
// End of full bucket, can send to anomaly tracker now.
|
||||
addPastBucketToAnomalyTrackers(mDurationFullBucket, current_info.mBucketNum);
|
||||
addPastBucketToAnomalyTrackers(mDurationFullBucket, mCurrentBucketNum);
|
||||
mDurationFullBucket = 0;
|
||||
}
|
||||
VLOG(" duration: %lld", (long long)current_info.mDuration);
|
||||
@@ -182,12 +181,11 @@ bool OringDurationTracker::flushCurrentBucket(
|
||||
DurationBucket info;
|
||||
info.mBucketStartNs = fullBucketEnd + mBucketSizeNs * (i - 1);
|
||||
info.mBucketEndNs = info.mBucketStartNs + mBucketSizeNs;
|
||||
info.mBucketNum = mCurrentBucketNum + i;
|
||||
info.mDuration = mBucketSizeNs;
|
||||
(*output)[mEventKey].push_back(info);
|
||||
// Safe to send these buckets to anomaly tracker since they must be full buckets.
|
||||
// If it's a partial bucket, numBucketsForward would be 0.
|
||||
addPastBucketToAnomalyTrackers(info.mDuration, info.mBucketNum);
|
||||
addPastBucketToAnomalyTrackers(info.mDuration, mCurrentBucketNum + i);
|
||||
VLOG(" add filling bucket with duration %lld", (long long)info.mDuration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,6 @@ TEST(GaugeMetricProducerTest, TestNoCondition) {
|
||||
it++;
|
||||
EXPECT_EQ(INT, it->mValue.getType());
|
||||
EXPECT_EQ(11L, it->mValue.int_value);
|
||||
EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.begin()->second.back().mBucketNum);
|
||||
|
||||
gaugeProducer.flushIfNeededLocked(bucket4StartTimeNs);
|
||||
EXPECT_EQ(0UL, gaugeProducer.mCurrentSlicedBucket->size());
|
||||
@@ -125,7 +124,6 @@ TEST(GaugeMetricProducerTest, TestNoCondition) {
|
||||
it++;
|
||||
EXPECT_EQ(INT, it->mValue.getType());
|
||||
EXPECT_EQ(25L, it->mValue.int_value);
|
||||
EXPECT_EQ(2UL, gaugeProducer.mPastBuckets.begin()->second.back().mBucketNum);
|
||||
}
|
||||
|
||||
TEST(GaugeMetricProducerTest, TestPushedEventsWithUpgrade) {
|
||||
@@ -337,7 +335,6 @@ TEST(GaugeMetricProducerTest, TestWithCondition) {
|
||||
.mGaugeAtoms.front()
|
||||
.mFields->begin()
|
||||
->mValue.int_value);
|
||||
EXPECT_EQ(1UL, gaugeProducer.mPastBuckets.begin()->second.back().mBucketNum);
|
||||
}
|
||||
|
||||
TEST(GaugeMetricProducerTest, TestAnomalyDetection) {
|
||||
|
||||
Reference in New Issue
Block a user