Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
50320:9c5e743e400c | 50321:14b57943ae6d |
---|---|
45 root_dir: PathBuf, | 45 root_dir: PathBuf, |
46 ignore_files: Vec<PathBuf>, | 46 ignore_files: Vec<PathBuf>, |
47 options: StatusOptions, | 47 options: StatusOptions, |
48 ) -> Result<(DirstateStatus<'dirstate>, Vec<PatternFileWarning>), StatusError> | 48 ) -> Result<(DirstateStatus<'dirstate>, Vec<PatternFileWarning>), StatusError> |
49 { | 49 { |
50 // Force the global rayon threadpool to not exceed 16 concurrent threads. | 50 // Also cap for a Python caller of this function, but don't complain if |
51 // This is a stop-gap measure until we figure out why using more than 16 | 51 // the global threadpool has already been set since this code path is also |
52 // threads makes `status` slower for each additional thread. | 52 // being used by `rhg`, which calls this early. |
53 // We use `ok()` in case the global threadpool has already been | 53 let _ = crate::utils::cap_default_rayon_threads(); |
54 // instantiated in `rhg` or some other caller. | |
55 // TODO find the underlying cause and fix it, then remove this. | |
56 rayon::ThreadPoolBuilder::new() | |
57 .num_threads(16.min(rayon::current_num_threads())) | |
58 .build_global() | |
59 .ok(); | |
60 | 54 |
61 let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = | 55 let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = |
62 if options.list_ignored || options.list_unknown { | 56 if options.list_ignored || options.list_unknown { |
63 let (ignore_fn, warnings, changed) = match dmap.dirstate_version { | 57 let (ignore_fn, warnings, changed) = match dmap.dirstate_version { |
64 DirstateVersion::V1 => { | 58 DirstateVersion::V1 => { |