Skip to content

Commit

Permalink
cut legacy ServiceData::getRegexCountersOptimized()
Browse files Browse the repository at this point in the history
Summary: Now that `ServiceData::getRegexCountersOptimized()` and `ServiceData::getRegexCounters()` are identical and all call-sites are adjusted, remove the unused name.

Reviewed By: dmm-fb

Differential Revision: D64485623

fbshipit-source-id: 372ffb9c362139c4d9307ed65c1bf7a07fcedf39
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Jan 8, 2025
1 parent 85cdf32 commit 71b0c19
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 32 deletions.
15 changes: 1 addition & 14 deletions fb303/ServiceData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,19 +459,13 @@ map<string, int64_t> ServiceData::getSelectedCounters(
void ServiceData::getRegexCounters(
map<string, int64_t>& _return,
const string& regex) const {
getRegexCountersOptimized(_return, regex);
}

void ServiceData::getRegexCountersOptimized(
map<string, int64_t>& output,
const string& regex) const {
const auto key = folly::RegexMatchCache::regex_key_and_view(regex);
const auto now = folly::RegexMatchCache::clock::now();
std::vector<std::string> keys;
detail::cachedFindMatches(keys, counters_, key, now);
quantileMap_.getRegexKeys(keys, key, now);
dynamicCounters_.getRegexKeys(keys, key, now);
getSelectedCounters(output, keys);
getSelectedCounters(_return, keys);
}

map<string, int64_t> ServiceData::getRegexCounters(const string& regex) const {
Expand All @@ -480,13 +474,6 @@ map<string, int64_t> ServiceData::getRegexCounters(const string& regex) const {
return _return;
}

map<string, int64_t> ServiceData::getRegexCountersOptimized(
const string& regex) const {
map<string, int64_t> output;
getRegexCountersOptimized(output, regex);
return output;
}

void ServiceData::trimRegexCache(const std::chrono::seconds maxstale) {
const auto now = folly::RegexMatchCache::clock::now();
const auto expiry = now - maxstale;
Expand Down
7 changes: 0 additions & 7 deletions fb303/ServiceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,6 @@ class ServiceData {
std::map<std::string, int64_t> getRegexCounters(
const std::string& regex) const;

/*** Optimized version of getRegexCounters,
which caches the matching keys for subsequent calls ***/
void getRegexCountersOptimized(
std::map<std::string, int64_t>& _return,
const std::string& regex) const;
std::map<std::string, int64_t> getRegexCountersOptimized(
const std::string& regex) const;
void trimRegexCache(std::chrono::seconds maxstale);
/*** Returns true if a counter exists with the specified name */
bool hasCounter(folly::StringPiece key) const;
Expand Down
7 changes: 3 additions & 4 deletions fb303/test/GetRegexCountersBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BENCHMARK(GetRegexCountersBenchmarkSubset, iters) {
startup.dismiss();
for (int iter = 0; iter < iters; iter++) {
std::map<std::string, int64_t> counters =
fb303Data.getRegexCountersOptimized("matching.*");
fb303Data.getRegexCounters("matching.*");
}
}

Expand All @@ -60,7 +60,7 @@ BENCHMARK(GetRegexCountersBenchmarkOne, iters) {
startup.dismiss();
for (int iter = 0; iter < iters; iter++) {
std::map<std::string, int64_t> counters =
fb303Data.getRegexCountersOptimized("matchingCounter1");
fb303Data.getRegexCounters("matchingCounter1");
}
}

Expand All @@ -70,8 +70,7 @@ BENCHMARK(GetRegexCountersBenchmarkAll, iters) {
prepareData();
startup.dismiss();
for (int iter = 0; iter < iters; iter++) {
std::map<std::string, int64_t> counters =
fb303Data.getRegexCountersOptimized(".*");
std::map<std::string, int64_t> counters = fb303Data.getRegexCounters(".*");
}
}

Expand Down
8 changes: 1 addition & 7 deletions fb303/test/GetRegexCountersMtBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ DEFINE_uint32(batch, 32, "Number of operations per batch");
DEFINE_uint32(batches, 1024, "Number of batches per run");
DEFINE_uint32(counters, 20000, "Number of unique counters");
DEFINE_string(prefix, "sso_spills_over_counter_", "Prefix of counter names");
DEFINE_bool(opt, true, "Use getRegexCountersOptimized()");

namespace {

Expand Down Expand Up @@ -106,12 +105,7 @@ void doWork(
// 20% get counters by regex and check them
else if (dice < 21) {
const string& regex = (dice & 1) ? kRegex1 : kRegex0;
std::map<string, int64_t> got;
if (FLAGS_opt) {
serviceData.getRegexCountersOptimized(got, regex);
} else {
serviceData.getRegexCounters(got, regex);
}
auto got = serviceData.getRegexCounters(regex);
if (got.size() == 0) {
++errors;
} else {
Expand Down

0 comments on commit 71b0c19

Please sign in to comment.