Skip to content

Commit 8c8484c

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: D87911300 fbshipit-source-id: 92f68edc736fe1f10940e115a750f72e09a4a60c
1 parent 8375989 commit 8c8484c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

third-party/mcrouter/src/mcrouter/StandaloneUtils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <vector>
2020

2121
#include <folly/Conv.h>
22+
#include <folly/system/HardwareConcurrency.h>
2223

2324
#include "mcrouter/CarbonRouterInstance.h"
2425
#include "mcrouter/McrouterLogFailure.h"
@@ -459,7 +460,7 @@ void setupStandaloneMcrouter(
459460
standaloneOptions.updateFromDict(standaloneOptionsDict);
460461

461462
if (standaloneOptions.core_multiplier > 0) {
462-
auto c = std::thread::hardware_concurrency();
463+
auto c = folly::hardware_concurrency();
463464
if (!standaloneOptions.core_multiplier_threshold ||
464465
c >= standaloneOptions.core_multiplier_threshold) {
465466
libmcrouterOptions.num_proxies = c * standaloneOptions.core_multiplier;

third-party/mcrouter/src/mcrouter/options.cpp

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

1515
#include <folly/Conv.h>
1616
#include <folly/String.h>
17+
#include <folly/system/HardwareConcurrency.h>
1718

1819
#include "mcrouter/Proxy.h"
1920
#include "mcrouter/lib/fbi/cpp/LogFailure.h"
@@ -301,7 +302,7 @@ namespace options {
301302

302303
string substituteTemplates(string str) {
303304
if (str.find(kTempCpuCores) != string::npos) {
304-
auto c = std::thread::hardware_concurrency();
305+
auto c = folly::hardware_concurrency();
305306
if (c == 0) {
306307
LOG_FAILURE(
307308
"mcrouter",

0 commit comments

Comments
 (0)