Skip to content

openmpCheckPhaseHook: init - #535725

Merged
mweinelt merged 10 commits into
NixOS:stagingfrom
GrimmTheShrimp:omp-thread-limit
Jun 26, 2026
Merged

mweinelt merged 10 commits into
NixOS:stagingfrom
GrimmTheShrimp:omp-thread-limit

Conversation

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

Tests using blas/lapack stack (typically via numpy/scipy) may use OpenMP to do parallelism. This messes with our build scheduling on hydra, because OpenMP does not respect NIX_BUILD_CORES, causing massively overloaded systems. As a solution, openmpCheckPhaseHook is introduced, fixing OMP_NUM_THREADS to 1 by default. This should fix most of the issues we were seeing, at least from python things.

Things done

@GrimmTheShrimp
GrimmTheShrimp changed the base branch from master to staging June 26, 2026 16:22
@nixpkgs-ci nixpkgs-ci Bot closed this Jun 26, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Jun 26, 2026
@nixpkgs-ci nixpkgs-ci Bot added 2.status: merge conflict This PR has merge conflicts with the target branch 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 8.has: documentation This PR adds or changes documentation labels Jun 26, 2026
@GrimmTheShrimp
GrimmTheShrimp marked this pull request as ready for review June 26, 2026 16:44
@nixpkgs-ci
nixpkgs-ci Bot requested review from a team, TomaSajt, balsoft and sheepforce and removed request for a team June 26, 2026 16:50
@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 26, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team June 26, 2026 17:01

@mweinelt mweinelt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

@mweinelt
mweinelt added this pull request to the merge queue Jun 26, 2026
Merged via the queue into NixOS:staging with commit d862c13 Jun 26, 2026
24 checks passed
@sheepforce

Copy link
Copy Markdown
Member

While I understand the issue it causes for hydra, there was a good reason for us to have threqds set to 2 in the computational chemistry ecosystem: the subtle bugs OpenBLAS versions sometimes had in the past for specific kernels on some CPUs only manifested in parallel runs, while single threaded execution would be fine. But of course any real world execution of the program would use multi threading. Thus, in some cases setting checks to run single threaded may hide real bugs.

I'm not too happy with that change to all packages in chemistry ecosystem. What would be a good compromise to not overload hydra workers falsely but keep tests relevant?

@mweinelt

Copy link
Copy Markdown
Member

Feel free to re-set the value to two, if needed. That is still within reasonable bounds for hydra. We just needed a fix for very high cpu pressure on hydra fast.

@markuskowa

Copy link
Copy Markdown
Member

This is a good thing, but I also agree with @sheepforece that the default should be 2 cores.

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor Author

This PR was intended to catch most of the runaway OMP_NUM_THREADS situation. As part of that, i decided to remove all undocumented explicit definitions of OMP_NUM_THREADS as i suspected it was being copied around as a bandaid fix a lot, without real considerations being put in.

I also believe the default of 1 thread is sensible. It avoids a whole bunch of headaches of race conditions and other non-reproducible behavior.

sometimes had in the past for specific kernels on some CPUs only manifested in parallel runs,

I don't think this is ever a useful indicator for builds done on hydra. This may be a useful indicator during testing/updating, fair.

Two threads are manageable by hydra. If you want two threads, open a PR (against staging-next) and review-request me, we can do that relatively quickly. Put a comment why, so the rationale is documented. But the default wherever there isn't an explicit number should be 1 i think.

@balsoft balsoft moved this from Needs Review to Reviewed in Nixpkgs security review Jun 29, 2026
@mweinelt mweinelt added the backport staging-next-26.05 Backport PR automatically label Jul 8, 2026
@nixpkgs-ci

nixpkgs-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Backport failed for staging-next-26.05, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin staging-next-26.05
git worktree add -d .worktree/backport-535725-to-staging-next-26.05 origin/staging-next-26.05
cd .worktree/backport-535725-to-staging-next-26.05
git switch --create backport-535725-to-staging-next-26.05
git cherry-pick -x 8ff970916b975cfd1b79ff3751061526fe88614b 71fbdd6512fcf27434aa34bbb9a830c1a8a2068b 240ef095c6bc783e437fb69b74442db6219d0e49 559ae88af990e9cc835f791f1fca62283ac574a7 df838c503eaeb72f9a100ccf8e5914fe65a11502 b3944a1e306623cb152573d1aaad9ba569a9d67f ef8b8d8f58919deb3d462416e582dadafe3fb833 d5ae461bf7277e6fcbb5239e4b268ed2792e6ef2 cd137f1c889116425f507d709e709dead46dbcea 576031cf3c432361b33dff42e71ce639518a9219

@vcunat

vcunat commented Jul 14, 2026

Copy link
Copy Markdown
Member

test_omp_num_threads - AssertionError: 5 != 1

🤦🏽 https://hydra.nixos.org/build/337332390

@mweinelt

mweinelt commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Feel free to pick f6fa032 into staging and staging-next-26.05.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 6.topic: python Python is a high-level, general-purpose programming language. 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. backport staging-next-26.05 Backport PR automatically

Projects

Archived in project
Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants