-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spawn io_service threads according to number cpu cores #878
Comments
No, because not everyone is building on production server. Better if we can detect it at runtime, or alternatively, add a configurable parameter. |
std::thread::hardware_concurrency() gives you a guess, although it is not accurate on all platforms. Most implementations I've seen rely on this method. And if it returns 0, 2 is used. IMO: use the logic above, and let configuration parameters (config file or command line) override it. |
@jmjatlanta boost has boost::thread::hardware_concurrency too, but I don't know if it has the same problem. |
Yeah, I mean through compiler flag, macro defined, etc.. pass the cpu cores to code, substitute the constant |
What about: In absence of a configurable parameter, That will almost always give 1 free thread for other things, and will scale with number of cores. |
I'm still thinking it's best to use the boost implementation instead of std. https://github.com/steinwurf/boost/blob/master/libs/thread/src/pthread/thread.cpp#L549 Now I see, boost::thread::physical_concurrency() too. |
Issue #878 permit configuration of io threads
Done with #927. |
The
default_io_service_scope
fixedly spawns 8 threads for io_servcie, while with cpu less than 8 cores, performance may discount due to context switches.So the good practice maybe detecting host's cpu core number at building stage, and spawning the corresponding threads, i.e. io_service-per-core.
The text was updated successfully, but these errors were encountered: