Skip to content

Commit c7f4b43

Browse files
committed
Preserve the 10 threads limit
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
1 parent fd1f80b commit c7f4b43

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

libmamba/include/mamba/core/thread_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace mamba
7373
*
7474
* The `threads` parameter follows the same semantics as `extract_threads`:
7575
* - `threads > 0`: user explicitly requested exactly this many threads (never capped);
76-
* - `threads == 0`: use the maximum concurrency available to this process;
76+
* - `threads == 0`: use `min(10, available_concurrency)` as a conservative default;
7777
* - `threads < 0`: use (available_concurrency + threads).
7878
*
7979
* Only the auto/relative forms (`threads <= 0`) are clamped to the range

libmamba/src/api/configuration.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,8 @@ namespace mamba
15271527
.set_rc_configurable()
15281528
.description(
15291529
"Number of threads for parallel shard fetching (default: 0 (auto)). "
1530-
"0 means: use process-affinity-based concurrency."
1530+
"If set to 0, the number of threads is chosen automatically as the "
1531+
"minimum between 10 and the number of CPUs available to the process"
15311532
));
15321533

15331534
// Network
@@ -1764,9 +1765,8 @@ namespace mamba
17641765
.description("Defines the number of threads for package download")
17651766
.long_description(unindent(R"(
17661767
Defines the number of threads for package download.
1767-
If set to 0, the number of threads is chosen automatically
1768-
based on the CPUs available to the current process (for example,
1769-
when using `taskset`). It has to be non-negative.)")));
1768+
If set to 0, the number of threads is chosen automatically as the
1769+
minimum between 10 and the number of CPUs available to the process.")));
17701770
17711771
insert(Configurable("extract_threads", &m_context.threads_params.extract_threads)
17721772
.group("Extract, Link & Install")
@@ -1778,9 +1778,9 @@ namespace mamba
17781778
Defines the number of threads for package extraction.
17791779
Positive values give the exact number of threads.
17801780
Negative values are interpreted as (available CPUs for this process
1781-
minus the absolute value). Zero (the default) means the number of
1782-
threads is chosen automatically based on the CPUs available to the
1783-
current process (for example, when using `taskset`).)")));
1781+
minus the absolute value).
1782+
If set to 0, the number of threads is chosen automatically as the
1783+
minimum between 10 and the number of CPUs available to the process)")));
17841784

17851785
insert(Configurable("allow_softlinks", &m_context.link_params.allow_softlinks)
17861786
.group("Extract, Link & Install")

libmamba/src/core/thread_utils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ namespace mamba
223223
std::ptrdiff_t requested = 0;
224224
if (requested_n_threads == 0)
225225
{
226-
requested = available;
226+
// Default to at most 10 threads so that shard-based and other parallel
227+
// operations don't oversubscribe very wide machines by default.
228+
requested = std::min<std::ptrdiff_t>(available, 10);
227229
}
228230
else // (requested_n_threads < 0)
229231
{

0 commit comments

Comments
 (0)