diff --git a/velox/exec/Spill.cpp b/velox/exec/Spill.cpp index ee0c9be573e3..f7776566864c 100644 --- a/velox/exec/Spill.cpp +++ b/velox/exec/Spill.cpp @@ -338,11 +338,7 @@ tsan_atomic& 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; } @@ -355,6 +351,10 @@ bool testingTriggerSpill(const std::string& pool) { return false; } + if (!pool.empty() && !RE2::FullMatch(pool, testingSpillPoolRegExp())) { + return false; + } + ++injectedSpillCount(); return true; }