Skip to content

Commit

Permalink
Put cheap check first in testingTriggerSpill() (facebookincubator#10646
Browse files Browse the repository at this point in the history
…) (#494)

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: facebookincubator#10646

Reviewed By: kevinwilfong

Differential Revision: D60613614

Pulled By: tanjialiang

fbshipit-source-id: 23cbfc89b575343b7e7da1dd7d0eaef63a1ec705

Co-authored-by: Jialiang Tan <[email protected]>
  • Loading branch information
weiting-chen and tanjialiang authored Aug 20, 2024
1 parent 66e51f9 commit 88856e6
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 88856e6

Please sign in to comment.