You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stats: Optimize stat-matcher rejection by prefix #17027
bool checkAndRememberRejection(StatName stat_name) {
if (stat_name is in rejection_set_) {
return true; // reject a stat-name we've already seen.
}
std::string elaborated_name = symbol_table_.toString(stat_name); // expensive & takes lock
if (stat_matcher_.test(elaborated_name)) {
rejection_set_.insert(stat_name); // costs memory
return true;
}
return true;
}
The implementation is more complex and expensive than this because there's a rejection set both in thread_local_store.cc's central cache and also in its TLS caches. And there's also a trivial optimization for when all stats are rejected (which will result in a somewhat dysfunctional Envoy for various reasons).
One interesting use-case is to drop all cluster-stats using a prefix-match of "cluster.". We can optimize this case because we could compute a StatName for the prefix up front when populating the stat-matcher, and we could use SymbolTableImpl::Encoding::decodeSymbols to match a StatName for "cluster.foo" against a prefix "cluster." without allocating memory or taking a lock.
This would also eliminate (I think) the need to bother with remembering the rejected stats in a map.
Note: similar optimization could also be made for suffix-matches like ".foo" or even internal matches like ".foo." or ".foo.bar.". However they would add code complexity so I'm just thinking now have doing what's needed for cluster-matching, but may turn out to be useful in the future.
Activity
stats: optimize stats-matchers instantiated with "prefix." pattern, t…
stats: optimize stats-matchers instantiated with "prefix." pattern, t…