Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions presto-native-execution/presto_cpp/main/PrestoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>(
Expand Down Expand Up @@ -975,7 +975,7 @@ void PrestoServer::initializeThreadPools() {
}
const auto numExchangeHttpClientIoThreads = std::max<size_t>(
systemConfig->exchangeHttpClientNumIoThreadsHwMultiplier() *
folly::hardware_concurrency(),
folly::available_concurrency(),
1);
exchangeHttpIoExecutor_ = std::make_unique<folly::IOThreadPoolExecutor>(
numExchangeHttpClientIoThreads,
Expand All @@ -995,7 +995,7 @@ void PrestoServer::initializeThreadPools() {

const auto numExchangeHttpClientCpuThreads = std::max<size_t>(
systemConfig->exchangeHttpClientNumCpuThreadsHwMultiplier() *
folly::hardware_concurrency(),
folly::available_concurrency(),
1);

exchangeHttpCpuExecutor_ = std::make_unique<folly::CPUThreadPoolExecutor>(
Expand Down Expand Up @@ -1367,7 +1367,7 @@ std::vector<std::string> PrestoServer::registerVeloxConnectors(

const auto numConnectorCpuThreads = std::max<size_t>(
SystemConfig::instance()->connectorNumCpuThreadsHwMultiplier() *
folly::hardware_concurrency(),
folly::available_concurrency(),
0);
if (numConnectorCpuThreads > 0) {
connectorCpuExecutor_ = std::make_unique<folly::CPUThreadPoolExecutor>(
Expand All @@ -1381,7 +1381,7 @@ std::vector<std::string> PrestoServer::registerVeloxConnectors(

const auto numConnectorIoThreads = std::max<size_t>(
SystemConfig::instance()->connectorNumIoThreadsHwMultiplier() *
folly::hardware_concurrency(),
folly::available_concurrency(),
0);
if (numConnectorIoThreads > 0) {
connectorIoExecutor_ = std::make_unique<folly::IOThreadPoolExecutor>(
Expand Down Expand Up @@ -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 *
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions presto-native-execution/presto_cpp/main/common/Configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class BroadcastWriteReplayerTest : public HiveConnectorTestBase {
void SetUp() override {
HiveConnectorTestBase::SetUp();
executor_ = std::make_unique<folly::CPUThreadPoolExecutor>(
folly::hardware_concurrency());
folly::available_concurrency());
// Clear mock writers from any previous test
clearMockWriters();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class PartitionAndSerializeReplayerTest : public HiveConnectorTestBase {
void SetUp() override {
HiveConnectorTestBase::SetUp();
executor_ = std::make_unique<folly::CPUThreadPoolExecutor>(
folly::hardware_concurrency());
folly::available_concurrency());
}

void TearDown() override {
Expand Down
Loading