Skip to content
Myr

Merge pull request #1412 from tmccombs/limit-default-threads

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Limit default threads

authored by Thayne McCombs · committed by GitHub · parents c96b1af, 5ee6365 · Browse files · 2 files+18 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+18 added−1 removed

  • other:+18 added−1 removed

2 files+18 added−1 removed

modified:src/cli.rs+14 added-1 removed
717 unmodified lines
718 // Note that the minimum value for a NonZeroUsize is 1.719 // Unfortunately, we can't do `NonZeroUsize::new(1).unwrap()`720 // in a const context.721 const FALLBACK_PARALLELISM: NonZeroUsize = NonZeroUsize::MIN;722 // As the number of threads increases, the startup time suffers from723 // initializing the threads, and we get diminishing returns from additional724 // parallelism. So set a maximum number of threads to use by default.725 //726 // This value is based on some empirical observations, but the ideal value727 // probably depends on the exact hardware in use.728 //729 // Safety: The literal "20" is known not to be zero.730 const MAX_DEFAULT_THREADS: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(20) };731732 std::cmp::min(722 std::thread::available_parallelism().unwrap_or(FALLBACK_PARALLELISM)733 std::thread::available_parallelism().unwrap_or(FALLBACK_PARALLELISM),734 MAX_DEFAULT_THREADS,735 )736}737738#[derive(Copy, Clone, PartialEq, Eq, ValueEnum)]739pub enum FileType {
156 unmodified lines
modified:CHANGELOG.md+4 added
3 unmodified lines
45- Breaking: `.git/` is now ignored by default when using `--hidden` / `-H`, use `--no-ignore` / `-I` or6 `--no-ignore-vcs` to override, see #1387 and #1396 (@skoriop)789## Bugfixes1011## Changes1213- The default number of threads is now constrained to be at most 16. This should improve startup time on14 systems with many CPU cores. (#1203)1516## Other1718# v8.7.119
693 unmodified lines