Skip to content

Commit f663ca0

Browse files
Merge pull request #29 from nextmv-io/merschformann/higher-number-of-default-threads
Removes artificial sub-run bottleneck
2 parents 108a46d + 64ae32a commit f663ca0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

nextpipe/threads.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@
1313
The module also provides a thread local storage variable for thread-specific data.
1414
"""
1515

16-
import multiprocessing
1716
import threading
1817
from collections.abc import Callable
1918
from typing import Any, Optional
2019

20+
DEFAULT_MAX_THREADS = 24
21+
"""
22+
Default maximum number of threads for the thread pool. This is set to 24, to allow
23+
parallel execution of sub-runs in the pipeline (as these are typically not CPU-bound). A
24+
lower value more fit for the respective hardware is recommended when running many
25+
CPU-bound steps.
26+
"""
27+
2128
thread_local = threading.local()
2229
"""Thread-local storage.
2330
@@ -176,11 +183,11 @@ def __init__(self, max_threads: int = 0):
176183
----------
177184
max_threads : int, optional
178185
Maximum number of threads to use, by default 0.
179-
If <= 0, uses the number of CPU cores.
186+
If <= 0, DEFAULT_MAX_THREADS is used.
180187
"""
181188

182189
if max_threads <= 0:
183-
max_threads = multiprocessing.cpu_count()
190+
max_threads = DEFAULT_MAX_THREADS
184191
self.max_threads = max_threads
185192
self.counter = 0 # Used to assign unique IDs to threads
186193
self.waiting = {}

0 commit comments

Comments
 (0)