From d656d136098f779724cec5aa23a36fac5d72a7d2 Mon Sep 17 00:00:00 2001 From: Francesc Alted Date: Tue, 14 Jan 2025 11:51:46 +0100 Subject: [PATCH] Some fine tuning on the number of threads --- src/blosc2/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/blosc2/__init__.py b/src/blosc2/__init__.py index 760eaf97..4a985a1c 100644 --- a/src/blosc2/__init__.py +++ b/src/blosc2/__init__.py @@ -12,6 +12,8 @@ from enum import Enum +import numexpr + from .version import __version__ __version__ = __version__ @@ -195,7 +197,9 @@ class Tuner(Enum): # Protection against too many threads nthreads = min(nthreads, 32) # Experiments say that, when using a large number of threads, it is better to not use them all -nthreads -= nthreads // 8 +if nthreads > 16: + nthreads -= nthreads // 8 +numexpr.set_num_threads(nthreads) # This import must be before ndarray and schunk from .storage import ( # noqa: I001