Skip to content

Commit a0b943f

Browse files
duxiao1212facebook-github-bot
authored andcommitted
feat: Add stall thread monitoring to Spiller cpu pool (#26695)
Summary: as title Differential Revision: D87850298
1 parent 2e3c6cc commit a0b943f

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

presto-native-execution/presto_cpp/main/PrestoServer.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ void PrestoServer::run() {
548548
}
549549
if (spillerExecutor_ != nullptr) {
550550
PRESTO_STARTUP_LOG(INFO)
551-
<< "Spiller CPU executor '" << spillerExecutor_->getName() << "', has "
552-
<< spillerExecutor_->numThreads() << " threads.";
551+
<< "Spiller CPU executor '" << spillerCpuExecutor_->getName()
552+
<< "', has " << spillerCpuExecutor_->numThreads() << " threads.";
553553
} else {
554554
PRESTO_STARTUP_LOG(INFO) << "Spill executor was not configured.";
555555
}
@@ -560,7 +560,7 @@ void PrestoServer::run() {
560560
auto* asyncDataCache = velox::cache::AsyncDataCache::getInstance();
561561
periodicTaskManager_ = std::make_unique<PeriodicTaskManager>(
562562
driverCpuExecutor_,
563-
spillerExecutor_.get(),
563+
spillerCpuExecutor_,
564564
httpSrvIoExecutor_.get(),
565565
httpSrvCpuExecutor_.get(),
566566
exchangeHttpIoExecutor_.get(),
@@ -836,10 +836,11 @@ void PrestoServer::initializeThreadPools() {
836836
threadFactory = std::make_shared<folly::NamedThreadFactory>("Driver");
837837
}
838838

839-
auto driverExecutor = std::make_unique<folly::CPUThreadPoolExecutor>(
839+
driverExecutor_ = std::make_unique<folly::CPUThreadPoolExecutor>(
840840
numDriverCpuThreads, threadFactory);
841-
driverCpuExecutor_ = driverExecutor.get();
842-
driverExecutor_ = std::move(driverExecutor);
841+
driverCpuExecutor_ =
842+
velox::checked_pointer_cast<folly::CPUThreadPoolExecutor>(
843+
driverExecutor_.get());
843844

844845
const auto numIoThreads = std::max<size_t>(
845846
systemConfig->httpServerNumIoThreadsHwMultiplier() * hwConcurrency, 1);
@@ -857,8 +858,10 @@ void PrestoServer::initializeThreadPools() {
857858
spillerExecutor_ = std::make_unique<folly::CPUThreadPoolExecutor>(
858859
numSpillerCpuThreads,
859860
std::make_shared<folly::NamedThreadFactory>("Spiller"));
861+
spillerCpuExecutor_ =
862+
velox::checked_pointer_cast<folly::CPUThreadPoolExecutor>(
863+
spillerExecutor_.get());
860864
}
861-
862865
const auto numExchangeHttpClientIoThreads = std::max<size_t>(
863866
systemConfig->exchangeHttpClientNumIoThreadsHwMultiplier() *
864867
std::thread::hardware_concurrency(),

presto-native-execution/presto_cpp/main/PrestoServer.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,14 @@ class PrestoServer {
268268
// 'driverExecutor_'.
269269
folly::CPUThreadPoolExecutor* driverCpuExecutor_;
270270

271-
// Executor for spilling.
272-
std::unique_ptr<folly::CPUThreadPoolExecutor> spillerExecutor_;
271+
// Executor for spilling. The underlying thread pool executor is a
272+
// folly::CPUThreadPoolExecutor. The executor is stored as abstract type to
273+
// provide flexibility of thread pool monitoring. The underlying
274+
// folly::CPUThreadPoolExecutor can be obtained through 'spillerCpuExecutor_'.
275+
std::unique_ptr<folly::Executor> spillerExecutor_;
276+
// Raw pointer pointing to the underlying folly::CPUThreadPoolExecutor of
277+
// 'spillerExecutor_'.
278+
folly::CPUThreadPoolExecutor* spillerCpuExecutor_;
273279

274280
std::unique_ptr<VeloxPlanValidator> planValidator_;
275281

0 commit comments

Comments
 (0)