mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-29 19:17:20 +00:00
Server: Use min instead of max to limit the number of threads (#17421)
## Summary Prevent overcommit by using max 4 threads as intended. Unintuitively, `.max()` returns the maximum value of `self` and the argument (not limiting to the argument). To limit the value to 4, one needs to use `.min()`. https://doc.rust-lang.org/std/cmp/trait.Ord.html#method.max
This commit is contained in:
parent
9c47b6dbb0
commit
58807b2980
2 changed files with 2 additions and 2 deletions
|
|
@ -30,7 +30,7 @@ pub fn run_server() -> anyhow::Result<()> {
|
|||
// by default, we set the number of worker threads to `num_cpus`, with a maximum of 4.
|
||||
let worker_threads = std::thread::available_parallelism()
|
||||
.unwrap_or(four)
|
||||
.max(four);
|
||||
.min(four);
|
||||
|
||||
Server::new(worker_threads)
|
||||
.context("Failed to start server")?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue