Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/dirstate_tree/status.rs @ 50321:14b57943ae6d stable
rust: fix thread cap (for real this time)
Both e2f8ed37201c and c52435820bbd failed to put a *default* ceiling on
the number of threads used by Rayon to prevent a contention issue.
Calling `rayon::available_parallelism()` creates the global threadpool,
which made our whole dance useless last time.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 23 Mar 2023 19:10:15 +0100 |
parents | edcc35a4f1dc |
children | 5efccea9cf38 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/status.rs Wed Mar 22 17:18:32 2023 +0000 +++ b/rust/hg-core/src/dirstate_tree/status.rs Thu Mar 23 19:10:15 2023 +0100 @@ -47,16 +47,10 @@ options: StatusOptions, ) -> Result<(DirstateStatus<'dirstate>, Vec<PatternFileWarning>), StatusError> { - // Force the global rayon threadpool to not exceed 16 concurrent threads. - // This is a stop-gap measure until we figure out why using more than 16 - // threads makes `status` slower for each additional thread. - // We use `ok()` in case the global threadpool has already been - // instantiated in `rhg` or some other caller. - // TODO find the underlying cause and fix it, then remove this. - rayon::ThreadPoolBuilder::new() - .num_threads(16.min(rayon::current_num_threads())) - .build_global() - .ok(); + // Also cap for a Python caller of this function, but don't complain if + // the global threadpool has already been set since this code path is also + // being used by `rhg`, which calls this early. + let _ = crate::utils::cap_default_rayon_threads(); let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = if options.list_ignored || options.list_unknown {