comparison rust/hg-core/src/dirstate_tree/status.rs @ 48812:e2f8ed37201c stable

rust-status: cap the number of concurrent threads to 16 During benchmarking it was determined that the use of more threads is very advantageous... until we use more than 16. This is most likely due to some resource contention (thrashing, etc.). Until we have time to figure out and fix the underlying cause, let's just cap at 16 threads. Differential Revision: https://phab.mercurial-scm.org/D12384
author Rapha?l Gom?s <rgomes@octobus.net>
date Fri, 18 Mar 2022 16:15:44 +0100
parents 834c938227c6
children dd6b67d5c256
comparison
equal deleted inserted replaced
48811:4a8eff64860a 48812:e2f8ed37201c
45 matcher: &(dyn Matcher + Sync), 45 matcher: &(dyn Matcher + Sync),
46 root_dir: PathBuf, 46 root_dir: PathBuf,
47 ignore_files: Vec<PathBuf>, 47 ignore_files: Vec<PathBuf>,
48 options: StatusOptions, 48 options: StatusOptions,
49 ) -> Result<(DirstateStatus<'on_disk>, Vec<PatternFileWarning>), StatusError> { 49 ) -> Result<(DirstateStatus<'on_disk>, Vec<PatternFileWarning>), StatusError> {
50 // Force the global rayon threadpool to not exceed 16 concurrent threads.
51 // This is a stop-gap measure until we figure out why using more than 16
52 // threads makes `status` slower for each additional thread.
53 // We use `ok()` in case the global threadpool has already been
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)
58 .build_global()
59 .ok();
60
50 let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) = 61 let (ignore_fn, warnings, patterns_changed): (IgnoreFnType, _, _) =
51 if options.list_ignored || options.list_unknown { 62 if options.list_ignored || options.list_unknown {
52 let mut hasher = Sha1::new(); 63 let mut hasher = Sha1::new();
53 let (ignore_fn, warnings) = get_ignore_function( 64 let (ignore_fn, warnings) = get_ignore_function(
54 ignore_files, 65 ignore_files,