treewide: add checkPhaseThreadLimitHook to more things used in parallel checks

This commit is contained in:
Grimmauld
2026-07-09 09:54:01 +02:00
parent 1d05796574
commit b96ed4d602
6 changed files with 63 additions and 0 deletions
+10
View File
@@ -5,6 +5,12 @@
perl,
python3,
# sets BLIS_NUM_THREADS and OMP_NUM_THREADS for packages
# invoking blis during checkPhase/installCheckPhase to
# avoid overloading builders with excessive parallelism
# See also: https://github.com/flame/blis/blob/b8b75b4e19459f5d618b57aa814ca38b1d82eb82/docs/Multithreading.md#specifying-multithreading
checkPhaseThreadLimitHook,
# Enable BLAS interface with 64-bit integer width.
blas64 ? false,
@@ -36,6 +42,10 @@ stdenv.mkDerivation (finalAttrs: {
python3
];
propagatedNativeBuildInputs = [
checkPhaseThreadLimitHook
];
doCheck = true;
enableParallelBuilding = true;
+9
View File
@@ -8,6 +8,11 @@
_7zz,
cctools,
validatePkgConfig,
# sets MKL_NUM_THREADS for packages
# invoking mkl during checkPhase/installCheckPhase to
# avoid overloading builders with excessive parallelism
# See also: https://www.intel.com/content/www/us/en/docs/onemkl/developer-guide-linux/2023-0/mkl-domain-num-threads.html
checkPhaseThreadLimitHook,
enableStatic ? stdenv.hostPlatform.isStatic,
}:
@@ -86,6 +91,10 @@ stdenvNoCC.mkDerivation (
[ rpmextract ]
);
propagatedNativeBuildInputs = [
checkPhaseThreadLimitHook
];
buildPhase =
if stdenvNoCC.hostPlatform.isDarwin then
''
@@ -4,6 +4,11 @@
fetchFromGitHub,
fetchpatch,
cmake,
# sets OPENBLAS_NUM_THREADS and OMP_NUM_THREADS for packages
# invoking openblas during checkPhase/installCheckPhase to
# avoid overloading builders with excessive parallelism
# See also: https://github.com/OpenMathLib/OpenBLAS/blob/e7b45174355edec1f04de1cabcf5ca6a98ea7fbc/USAGE.md#how-can-i-use-openblas-in-multi-threaded-applications
checkPhaseThreadLimitHook,
# Most packages depending on openblas expect integer width to match
# pointer width, but some expect to use 32-bit integers always
# (for compatibility with reference BLAS).
@@ -232,6 +237,10 @@ stdenv.mkDerivation (finalAttrs: {
cmake
];
propagatedNativeBuildInputs = [
checkPhaseThreadLimitHook
];
buildInputs = lib.optional (stdenv.cc.isClang && config.USE_OPENMP) openmp;
depsBuildBuild = [
@@ -5,6 +5,14 @@
pythonAtLeast,
stdenv,
# sets various thread limit env vars for packages
# invoking joblib during checkPhase/installCheckPhase to
# avoid overloading builders with excessive parallelism
# See also:
# https://github.com/joblib/joblib/blob/b030e4e1ed6a227c0e587c31b266c03b3b692372/joblib/_parallel_backends.py#L59-L67
# https://github.com/joblib/joblib/blob/b030e4e1ed6a227c0e587c31b266c03b3b692372/joblib/_parallel_backends.py#L221-L248
checkPhaseThreadLimitHook,
# build-system
setuptools,
@@ -40,6 +48,14 @@ buildPythonPackage rec {
threadpoolctl
];
propagatedNativeBuildInputs = [
checkPhaseThreadLimitHook
];
# joblib expects to set thread limits itself while checking for propagation of thread limit environment variables.
# Setting these via checkPhaseThreadLimitHook on joblib itself causes tests to fail, but we do want the hook to propagate.
dontLimitCheckPhaseThreads = true;
enabledTestPaths = [ "joblib/test" ];
disabledTests = [
@@ -8,6 +8,12 @@
# nativeBuildInputs
setuptools,
# sets NUMBA_NUM_THREADS and OMP_NUM_THREADS for packages
# invoking numba during checkPhase/installCheckPhase to
# avoid overloading builders with excessive parallelism
# See also: https://numba.readthedocs.io/en/stable/reference/envvars.html#threading-control
checkPhaseThreadLimitHook,
# dependencies
llvmlite,
numpy,
@@ -104,6 +110,10 @@ buildPythonPackage (finalAttrs: {
writableTmpDirAsHomeHook
];
propagatedNativeBuildInputs = [
checkPhaseThreadLimitHook
];
# https://github.com/NixOS/nixpkgs/issues/255262
preCheck = ''
cd $out
@@ -5,6 +5,11 @@
numpy,
pytestCheckHook,
setuptools,
# sets NUMEXPR_NUM_THREADS and OMP_NUM_THREADS for packages
# invoking numexpr during checkPhase/installCheckPhase to
# avoid overloading builders with excessive parallelism
# See also: https://numexpr.readthedocs.io/en/latest/user_guide.html#threadpool-configuration
checkPhaseThreadLimitHook,
}:
buildPythonPackage rec {
@@ -31,6 +36,10 @@ buildPythonPackage rec {
nativeCheckInputs = [ pytestCheckHook ];
propagatedNativeBuildInputs = [
checkPhaseThreadLimitHook
];
preCheck = ''
pushd $out
'';