Skip to content

Commit 15879ed

Browse files
yfeldblummeta-codesync[bot]
authored andcommitted
migrate rename to folly::available_concurrency in velox (#16678)
Summary: Pull Request resolved: #16678 Pull Request resolved: #16393 The name `hardware_concurrency`, while parallel to `std::thread::hardware_concurrency`, may be misleading. Migrate to the name `available_concurrency`. Reviewed By: kgpai Differential Revision: D93263930 fbshipit-source-id: cf2f11655575ef8230e6293dfc11ba845ea8cf9f
1 parent 7961300 commit 15879ed

22 files changed

+27
-27
lines changed

velox/common/base/tests/ConcurrentCounterTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ConcurrentCounterTest : public testing::TestWithParam<bool> {
4949

5050
void setupCounter() {
5151
counter_ = std::make_unique<ConcurrentCounter<int64_t>>(
52-
folly::hardware_concurrency());
52+
folly::available_concurrency());
5353
}
5454

5555
const bool useUpdateFn_{GetParam()};
@@ -73,8 +73,8 @@ TEST_P(ConcurrentCounterTest, multithread) {
7373
const int32_t numUpdatesPerThread = 5'000;
7474
std::vector<int> numThreads;
7575
numThreads.push_back(1);
76-
numThreads.push_back(folly::hardware_concurrency());
77-
numThreads.push_back(folly::hardware_concurrency() * 2);
76+
numThreads.push_back(folly::available_concurrency());
77+
numThreads.push_back(folly::available_concurrency() * 2);
7878
for (int numThreads : numThreads) {
7979
SCOPED_TRACE(fmt::format("numThreads: {}", numThreads));
8080
counter_->testingClear();

velox/common/file/FileSystems.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class LocalFileSystem : public FileSystem {
9191
std::max(
9292
1,
9393
static_cast<int32_t>(
94-
folly::hardware_concurrency() / 2)),
94+
folly::available_concurrency() / 2)),
9595
std::make_shared<folly::NamedThreadFactory>(
9696
"LocalReadahead"))
9797
: nullptr) {}

velox/common/file/tests/FileTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class LocalFileTest : public ::testing::TestWithParam<bool> {
201201
const bool useFaultyFs_;
202202
const std::unique_ptr<folly::CPUThreadPoolExecutor> executor_ =
203203
std::make_unique<folly::CPUThreadPoolExecutor>(
204-
std::max(1, static_cast<int32_t>(folly::hardware_concurrency() / 2)),
204+
std::max(1, static_cast<int32_t>(folly::available_concurrency() / 2)),
205205
std::make_shared<folly::NamedThreadFactory>(
206206
"LocalFileReadAheadTest"));
207207
};

velox/common/memory/MallocAllocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ MallocAllocator::MallocAllocator(size_t capacity, uint32_t reservationByteLimit)
3434
decrementUsageWithReservationFunc(counter, decrement, lock);
3535
return true;
3636
}),
37-
reservations_(folly::hardware_concurrency()) {}
37+
reservations_(folly::available_concurrency()) {}
3838

3939
MallocAllocator::~MallocAllocator() {
4040
// TODO: Remove the check when memory leak issue is resolved.

velox/common/memory/SharedArbitrator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ SharedArbitrator::SharedArbitrator(const Config& config)
297297
"memoryReclaimThreadsHwMultiplier_ needs to be positive");
298298

299299
const uint64_t numReclaimThreads = std::max<size_t>(
300-
1, folly::hardware_concurrency() * memoryReclaimThreadsHwMultiplier_);
300+
1, folly::available_concurrency() * memoryReclaimThreadsHwMultiplier_);
301301
memoryReclaimExecutor_ = std::make_unique<folly::CPUThreadPoolExecutor>(
302302
numReclaimThreads,
303303
std::make_shared<folly::NamedThreadFactory>("MemoryReclaim"));

velox/connectors/hive/tests/HiveDataSinkTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class HiveDataSinkTest : public exec::test::HiveConnectorTestBase {
7474
setupMemoryPools();
7575

7676
spillExecutor_ = std::make_unique<folly::IOThreadPoolExecutor>(
77-
folly::hardware_concurrency());
77+
folly::available_concurrency());
7878
}
7979

8080
void TearDown() override {

velox/examples/ScanAndSort.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ int main(int argc, char** argv) {
126126

127127
std::shared_ptr<folly::Executor> executor(
128128
std::make_shared<folly::CPUThreadPoolExecutor>(
129-
folly::hardware_concurrency()));
129+
folly::available_concurrency()));
130130

131131
// Task is the top-level execution concept. A task needs a taskId (as a
132132
// string), the plan fragment to execute, a destination (only used for

velox/exec/Cursor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class MultiThreadedTaskCursor : public TaskCursorBase {
275275
: TaskCursorBase(
276276
params,
277277
std::make_shared<folly::CPUThreadPoolExecutor>(
278-
folly::hardware_concurrency())),
278+
folly::available_concurrency())),
279279
maxDrivers_{params.maxDrivers},
280280
numConcurrentSplitGroups_{params.numConcurrentSplitGroups},
281281
numSplitGroups_{params.numSplitGroups} {
@@ -853,7 +853,7 @@ class TaskDebuggerParallelCursor : public TaskDebuggerCursorBase {
853853
: TaskDebuggerCursorBase(
854854
params,
855855
std::make_shared<folly::CPUThreadPoolExecutor>(
856-
folly::hardware_concurrency())),
856+
folly::available_concurrency())),
857857
maxDrivers_(params.maxDrivers),
858858
numConcurrentSplitGroups_(params.numConcurrentSplitGroups) {
859859
// Installs the required trace provider.

velox/exec/SpillStats.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
namespace facebook::velox::exec {
2525
namespace {
2626
std::vector<SpillStats>& allSpillStats() {
27-
static std::vector<SpillStats> spillStatsList(folly::hardware_concurrency());
27+
static std::vector<SpillStats> spillStatsList(folly::available_concurrency());
2828
return spillStatsList;
2929
}
3030

velox/exec/fuzzer/MemoryArbitrationFuzzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class MemoryArbitrationFuzzer {
274274
VectorFuzzer vectorFuzzer_;
275275
std::shared_ptr<folly::Executor> executor_{
276276
std::make_shared<folly::CPUThreadPoolExecutor>(
277-
folly::hardware_concurrency())};
277+
folly::available_concurrency())};
278278
folly::Synchronized<Stats> stats_;
279279
};
280280

0 commit comments

Comments
 (0)