diff --git a/presto-native-execution/presto_cpp/main/PrestoServer.cpp b/presto-native-execution/presto_cpp/main/PrestoServer.cpp index 358baf53cde32..bb09538e44d46 100644 --- a/presto-native-execution/presto_cpp/main/PrestoServer.cpp +++ b/presto-native-execution/presto_cpp/main/PrestoServer.cpp @@ -931,7 +931,7 @@ class BatchThreadFactory : public folly::NamedThreadFactory { #endif void PrestoServer::initializeThreadPools() { - const auto hwConcurrency = folly::hardware_concurrency(); + const auto hwConcurrency = folly::available_concurrency(); auto* systemConfig = SystemConfig::instance(); const auto numDriverCpuThreads = std::max( @@ -975,7 +975,7 @@ void PrestoServer::initializeThreadPools() { } const auto numExchangeHttpClientIoThreads = std::max( systemConfig->exchangeHttpClientNumIoThreadsHwMultiplier() * - folly::hardware_concurrency(), + folly::available_concurrency(), 1); exchangeHttpIoExecutor_ = std::make_unique( numExchangeHttpClientIoThreads, @@ -995,7 +995,7 @@ void PrestoServer::initializeThreadPools() { const auto numExchangeHttpClientCpuThreads = std::max( systemConfig->exchangeHttpClientNumCpuThreadsHwMultiplier() * - folly::hardware_concurrency(), + folly::available_concurrency(), 1); exchangeHttpCpuExecutor_ = std::make_unique( @@ -1367,7 +1367,7 @@ std::vector PrestoServer::registerVeloxConnectors( const auto numConnectorCpuThreads = std::max( SystemConfig::instance()->connectorNumCpuThreadsHwMultiplier() * - folly::hardware_concurrency(), + folly::available_concurrency(), 0); if (numConnectorCpuThreads > 0) { connectorCpuExecutor_ = std::make_unique( @@ -1381,7 +1381,7 @@ std::vector PrestoServer::registerVeloxConnectors( const auto numConnectorIoThreads = std::max( SystemConfig::instance()->connectorNumIoThreadsHwMultiplier() * - folly::hardware_concurrency(), + folly::available_concurrency(), 0); if (numConnectorIoThreads > 0) { connectorIoExecutor_ = std::make_unique( @@ -1707,7 +1707,7 @@ void PrestoServer::checkOverload() { memOverloaded_ = memOverloaded; } - static const auto hwConcurrency = folly::hardware_concurrency(); + static const auto hwConcurrency = folly::available_concurrency(); const auto overloadedThresholdCpuPct = systemConfig->workerOverloadedThresholdCpuPct(); const auto overloadedThresholdQueuedDrivers = hwConcurrency * @@ -1902,7 +1902,7 @@ protocol::NodeStatus PrestoServer::fetchNodeStatus() { address_, address_, **memoryInfo_.rlock(), - (int)folly::hardware_concurrency(), + (int)folly::available_concurrency(), cpuLoadPct, cpuLoadPct, pool_ ? pool_->usedBytes() : 0, diff --git a/presto-native-execution/presto_cpp/main/common/Configs.cpp b/presto-native-execution/presto_cpp/main/common/Configs.cpp index 1a6af3918b1a8..43b11998c7901 100644 --- a/presto-native-execution/presto_cpp/main/common/Configs.cpp +++ b/presto-native-execution/presto_cpp/main/common/Configs.cpp @@ -40,9 +40,9 @@ std::string bool2String(bool value) { } uint32_t hardwareConcurrency() { - const auto numLogicalCores = folly::hardware_concurrency(); - // The spec says folly::hardware_concurrency() might return 0. - // But we depend on folly::hardware_concurrency() to create executors. + const auto numLogicalCores = folly::available_concurrency(); + // The spec says folly::available_concurrency() might return 0. + // But we depend on folly::available_concurrency() to create executors. // Check to ensure numThreads is > 0. VELOX_CHECK_GT(numLogicalCores, 0); return numLogicalCores; diff --git a/presto-native-execution/presto_cpp/main/common/tests/ConfigTest.cpp b/presto-native-execution/presto_cpp/main/common/tests/ConfigTest.cpp index 8eca5a8de78ff..a8923156a9753 100644 --- a/presto-native-execution/presto_cpp/main/common/tests/ConfigTest.cpp +++ b/presto-native-execution/presto_cpp/main/common/tests/ConfigTest.cpp @@ -225,7 +225,7 @@ TEST_F(ConfigTest, optionalNodeConfigs) { TEST_F(ConfigTest, optionalSystemConfigsWithDefault) { SystemConfig config; init(config, {}); - ASSERT_EQ(config.maxDriversPerTask(), folly::hardware_concurrency()); + ASSERT_EQ(config.maxDriversPerTask(), folly::available_concurrency()); init(config, {{std::string(SystemConfig::kMaxDriversPerTask), "1024"}}); ASSERT_EQ(config.maxDriversPerTask(), 1024); } diff --git a/presto-native-execution/presto_cpp/main/tests/ServerOperationTest.cpp b/presto-native-execution/presto_cpp/main/tests/ServerOperationTest.cpp index cc1b3b5a26f49..c054f850a7e03 100644 --- a/presto-native-execution/presto_cpp/main/tests/ServerOperationTest.cpp +++ b/presto-native-execution/presto_cpp/main/tests/ServerOperationTest.cpp @@ -246,7 +246,7 @@ TEST_F(ServerOperationTest, systemConfigEndpoint) { {.target = ServerOperation::Target::kSystemConfig, .action = ServerOperation::Action::kGetProperty}, &httpMessage); - EXPECT_EQ(std::stoi(getPropertyResponse), folly::hardware_concurrency()); + EXPECT_EQ(std::stoi(getPropertyResponse), folly::available_concurrency()); } TEST_F(ServerOperationTest, veloxQueryConfigEndpoint) { @@ -270,7 +270,7 @@ TEST_F(ServerOperationTest, veloxQueryConfigEndpoint) { {.target = ServerOperation::Target::kVeloxQueryConfig, .action = ServerOperation::Action::kGetProperty}, &httpMessage); - EXPECT_EQ(std::stoi(getPropertyResponse), folly::hardware_concurrency()); + EXPECT_EQ(std::stoi(getPropertyResponse), folly::available_concurrency()); // Setting a registered property returns a message with "velox query config" // wording (verifying the copy-paste bug fix from systemConfigOperation). diff --git a/presto-native-execution/presto_cpp/main/tool/trace/tests/BroadcastWriteReplayerTest.cpp b/presto-native-execution/presto_cpp/main/tool/trace/tests/BroadcastWriteReplayerTest.cpp index b3399f7e9e0b4..e3d6d164958dd 100644 --- a/presto-native-execution/presto_cpp/main/tool/trace/tests/BroadcastWriteReplayerTest.cpp +++ b/presto-native-execution/presto_cpp/main/tool/trace/tests/BroadcastWriteReplayerTest.cpp @@ -308,7 +308,7 @@ class BroadcastWriteReplayerTest : public HiveConnectorTestBase { void SetUp() override { HiveConnectorTestBase::SetUp(); executor_ = std::make_unique( - folly::hardware_concurrency()); + folly::available_concurrency()); // Clear mock writers from any previous test clearMockWriters(); } diff --git a/presto-native-execution/presto_cpp/main/tool/trace/tests/PartitionAndSerializeReplayerTest.cpp b/presto-native-execution/presto_cpp/main/tool/trace/tests/PartitionAndSerializeReplayerTest.cpp index 5e5961e704ba1..cd2670b303362 100644 --- a/presto-native-execution/presto_cpp/main/tool/trace/tests/PartitionAndSerializeReplayerTest.cpp +++ b/presto-native-execution/presto_cpp/main/tool/trace/tests/PartitionAndSerializeReplayerTest.cpp @@ -144,7 +144,7 @@ class PartitionAndSerializeReplayerTest : public HiveConnectorTestBase { void SetUp() override { HiveConnectorTestBase::SetUp(); executor_ = std::make_unique( - folly::hardware_concurrency()); + folly::available_concurrency()); } void TearDown() override {