Skip to content

Commit

Permalink
Put cheap check first in testingTriggerSpill() (#10646)
Browse files Browse the repository at this point in the history
Summary:
testingTriggerSpill() uses 1% cpu in meta internal profiling on release build. This is due to the expensive regex check it does upon entrance of this method. Move pct check up to avoid regex check to reduce the cpu consumption.

Pull Request resolved: #10646

Reviewed By: kevinwilfong

Differential Revision: D60613614

Pulled By: tanjialiang

fbshipit-source-id: 23cbfc89b575343b7e7da1dd7d0eaef63a1ec705
  • Loading branch information
tanjialiang authored and facebook-github-bot committed Aug 2, 2024
1 parent 07bfc61 commit f7e1f35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions velox/exec/Spill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,7 @@ tsan_atomic<uint32_t>& injectedSpillCount() {
}

bool testingTriggerSpill(const std::string& pool) {
// Do not evaluate further if trigger is not set.
if (!pool.empty() && !RE2::FullMatch(pool, testingSpillPoolRegExp())) {
return false;
}

// Put cheap check first to reduce CPU consumption in release code.
if (testingSpillPct() <= 0) {
return false;
}
Expand All @@ -355,6 +351,10 @@ bool testingTriggerSpill(const std::string& pool) {
return false;
}

if (!pool.empty() && !RE2::FullMatch(pool, testingSpillPoolRegExp())) {
return false;
}

++injectedSpillCount();
return true;
}
Expand Down

0 comments on commit f7e1f35

Please sign in to comment.