Statsd cpu optimizaton
- cache the changed dimensions in condition tracker.
- avoid query condition wizard when unnecessary.
- avoid copy dimension keys in condition key generation.
Test: statsd tests.
BUG: b/73959649
Change-Id: I17d68e2a82643de3f421309841e75f84c6fd8f43
diff --git a/cmds/statsd/src/HashableDimensionKey.h b/cmds/statsd/src/HashableDimensionKey.h
index 57bdf68..4cfed88 100644
--- a/cmds/statsd/src/HashableDimensionKey.h
+++ b/cmds/statsd/src/HashableDimensionKey.h
@@ -65,10 +65,6 @@
std::string toString() const;
- inline const char* c_str() const {
- return toString().c_str();
- }
-
bool operator==(const HashableDimensionKey& that) const;
bool operator<(const HashableDimensionKey& that) const;
@@ -104,6 +100,10 @@
return mDimensionKeyInCondition;
}
+ inline void setDimensionKeyInCondition(const HashableDimensionKey& key) {
+ mDimensionKeyInCondition = key;
+ }
+
bool hasDimensionKeyInCondition() const {
return mDimensionKeyInCondition.getValues().size() > 0;
}
@@ -112,9 +112,6 @@
bool operator<(const MetricDimensionKey& that) const;
- inline const char* c_str() const {
- return toString().c_str();
- }
private:
HashableDimensionKey mDimensionKeyInWhat;
HashableDimensionKey mDimensionKeyInCondition;
@@ -134,6 +131,9 @@
*/
bool filterValues(const std::vector<Matcher>& matcherFields, const std::vector<FieldValue>& values,
std::vector<HashableDimensionKey>* output);
+// This function is used when there is at most one output dimension key. (no ANY matcher)
+bool filterValues(const std::vector<Matcher>& matcherFields, const std::vector<FieldValue>& values,
+ HashableDimensionKey* output);
/**
* Filter the values from FieldValues using the matchers.
@@ -146,7 +146,7 @@
void getDimensionForCondition(const std::vector<FieldValue>& eventValues,
const Metric2Condition& links,
- std::vector<HashableDimensionKey>* conditionDimension);
+ HashableDimensionKey* conditionDimension);
} // namespace statsd
} // namespace os