-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use task specific
rayon
threadpools and not the global threadpool (#…
…1872) The global `rayon` threadpool has a variable number of threads: - An environment variable can be used to specify the number: RAYON_NUM_THREADS - If not set, The number of CPUs on the executing system is used Relying on using the global pool may lead to a situation where the global threadpool does not have enough threads for `rover dev` to execute correctly. It's not realistic to expect customers to know how to set this environment variable and a better option is available. At each point in `rover` where we use `rayon`, create a thread pool which is task specific and explicitly sets the number of threads available to the pool. For example: ``` let tp = rayon::ThreadPoolBuilder::new() .num_threads(1) .thread_name(|idx| format!("router-runner-{idx}")) .build() .map_err(|err| { RoverError::new(anyhow!("could not create router runner thread pool: {err}",)) })?; ``` This has the added advantage of allowing us to provide a name for all the threads created by the pool which is helpful debugging information. Note: It might be that a more comprehensive answer to this problem is to not use `rayon` at all, but that's a bigger change than I want to consider for fixing this specific issue. also: - change the configuration of the `interprocess` crate so that non-blocking isn't available (it's broken) - close `stdin` on our spawned router to reduce risk of bad input - handle errors if we can't take `stdout` || `stderr` from our spawned router I've tested these changes manually on my laptop by setting RAYON_NUM_THREADS=2 and using `rover dev` without observing any hangs. Without these changes, `rover dev` hangs immediately. fixes: #1871
- Loading branch information
Showing
8 changed files
with
94 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters