rust-status: fix thread count ceiling stable
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 05 Dec 2022 17:28:40 +0100
branchstable
changeset 49763 c52435820bbd
parent 49695 2c346c1c75ec
child 49773 13c0e3b4fd35
rust-status: fix thread count ceiling This was forcing 16 threads instead of creating a ceiling, which is wrong when either the available parallelism of the platform is lower or when the user wants to set it explicitly (like we do in `run-tests.py`)
rust/hg-core/src/dirstate_tree/status.rs
--- a/rust/hg-core/src/dirstate_tree/status.rs	Thu Dec 01 18:01:24 2022 +0400
+++ b/rust/hg-core/src/dirstate_tree/status.rs	Mon Dec 05 17:28:40 2022 +0100
@@ -56,7 +56,7 @@
     // instantiated in `rhg` or some other caller.
     // TODO find the underlying cause and fix it, then remove this.
     rayon::ThreadPoolBuilder::new()
-        .num_threads(16)
+        .num_threads(16.min(rayon::current_num_threads()))
         .build_global()
         .ok();