From 2c111cff3015b80a86ab16d3f1edee934bc25e59 Mon Sep 17 00:00:00 2001 From: Sara Golemon Date: Wed, 24 Jun 2015 10:48:20 -0700 Subject: [PATCH] Don't hardcode thread limit in ServerBootstrap Summary: This was set to 32 which probably works fine for the majority of FB servers, but not everyone's system is so endowed. Closes #119 Reviewed By: @fredemmott Differential Revision: D2187008 --- folly/wangle/bootstrap/ServerBootstrap.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/folly/wangle/bootstrap/ServerBootstrap.h b/folly/wangle/bootstrap/ServerBootstrap.h index 3b7f6b0a..2c2a6b47 100644 --- a/folly/wangle/bootstrap/ServerBootstrap.h +++ b/folly/wangle/bootstrap/ServerBootstrap.h @@ -120,8 +120,13 @@ class ServerBootstrap { 1, std::make_shared("Acceptor Thread")); } if (!io_group) { + auto threads = std::thread::hardware_concurrency(); + if (threads <= 0) { + // Reasonable mid-point for concurrency when actual value unknown + threads = 8; + } io_group = std::make_shared( - 32, std::make_shared("IO Thread")); + threads, std::make_shared("IO Thread")); } // TODO better config checking -- 2.34.1