From: Sara Golemon Date: Wed, 24 Jun 2015 17:48:20 +0000 (-0700) Subject: Don't hardcode thread limit in ServerBootstrap X-Git-Tag: v0.48.0~14 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=2c111cff3015b80a86ab16d3f1edee934bc25e59 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 --- 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