Skip to content

Commit 7eb3282

Browse files
lexprfuncallmeta-codesync[bot]
authored andcommitted
use folly::hardware_concurrency instead of std::thread::hardware_concurrency
Summary: This change replaces calls of std::thread::hardware_concurrency with folly::hardware_concurrency when the caller wants the number of processors available to a job. This should be largely a no-change since most jobs use platform010 with glibc 2.34 where these functions behave identically. However, jobs on Aarch64 use glibc 2.40. There, the folly method continues to return the number of processors available to a job but the std version returns the number of processors known to the operating system, a different number when the job is stacked. Most of fbcode expects the folly behavior and this codemod only affects those callers. By making the switch to the folly method, code will behave the same when code is run on Aarch64 or when the glibc is upgraded on x86. Reviewed By: yfeldblum Differential Revision: D87904531 fbshipit-source-id: c8b29b8ea20d6036c8098d847569edcc1b95254d
1 parent 1559587 commit 7eb3282

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

third-party/wangle/src/wangle/bootstrap/ServerBootstrap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <folly/io/async/AsyncTransport.h>
2020
#include <folly/synchronization/Baton.h>
21+
#include <folly/system/HardwareConcurrency.h>
2122
#include <wangle/bootstrap/ServerBootstrap-inl.h>
2223
#include <wangle/channel/Pipeline.h>
2324
#include <iostream>
@@ -136,7 +137,7 @@ class ServerBootstrap {
136137
1, std::make_shared<folly::NamedThreadFactory>("Acceptor Thread"));
137138
}
138139
if (!io_group) {
139-
auto threads = std::thread::hardware_concurrency();
140+
auto threads = folly::hardware_concurrency();
140141
if (threads <= 0) {
141142
// Reasonable mid-point for concurrency when actual value unknown
142143
threads = 8;

0 commit comments

Comments
 (0)