refactor: one thread per core by default
Diff
README.md | 30 +++++++++++++++---------------
src/config.rs | 4 ++--
src/server.rs | 6 ++++--
3 files changed, 21 insertions(+), 19 deletions(-)
@@ -40,19 +40,19 @@ Server can be configured either via environment variables or their equivalent co
### Environment Variables
### Command-line arguments
@@ -99,9 +99,9 @@ OPTIONS:
-n, --threads-multiplier <threads-multiplier>
Number of worker threads multiplier that'll be multiplied by the number of system CPUs using the formula:
`worker threads = number of CPUs * n` where `n` is the value that changes here. When multiplier value is 0
or 1 then the `number of CPUs` is used. Number of worker threads result should be a number between 1 and
or 1 then one thread per core is used. Number of worker threads result should be a number between 1 and
32,768 though it is advised to keep this value on the smaller side [env: SERVER_THREADS_MULTIPLIER=]
[default: 8]
[default: 1]
```
## Docker stack
@@ -17,12 +17,12 @@ pub struct Config {
#[structopt(
long,
short = "n",
default_value = "8",
default_value = "1",
env = "SERVER_THREADS_MULTIPLIER"
)]
pub threads_multiplier: usize,
@@ -23,9 +23,11 @@ impl Server {
CONFIG.set(Config::from_args()).unwrap();
let opts = Config::global();
let cpus = num_cpus::get();
let threads = match opts.threads_multiplier {
0 | 1 => 1,
_ => num_cpus::get() * opts.threads_multiplier,
0 | 1 => cpus,
n => cpus * n,
};
Self { threads }