-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MNT use new threadpoolctl API (global threadpool controller) #21206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MNT use new threadpoolctl API (global threadpool controller) #21206
Conversation
I will have a look now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Maybe you could expand the comment a bit by stating the expected per-call overhead with and without the dynamic libraries lookups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good for #20254, LGTM!
threadpoolctl 3.0.0 has been released. This PR is ready for review |
To avoid merging code that isn't used or tested, could you please make |
Since there is a performance benefit, what do you think of updating the required version for threadpoolctl to 3.0 in scikit-learn 1.1? |
The new API of threadpoolctl allows to not look for the shared libraries at each call to
threadpool_(limits/info)
. The idea is that in scikit-learn the BLAS and OpenMP libraries are loaded during the import and won't change during the lifetime of a program using sklearn. It means that we can reuse their handlers for all subsequent call to threadpoolctl.The goal is to reduce some unnecessary overhead, which can be as high as check_array in some extreme situations like in #20254 when running neighbors prediction on a single test sample.
@jjerphan could you try the new threadpoolctl api in your PR, via the fixes introduced in this PR ?
It's already available in the master branch of https://github.com/joblib/threadpoolctl
You should now import threadpool_limits from utils._threadpoolctl_fixes.
This PR is in draft state. Its current purpose is to check that the new api solves the perf issues in sklearn. Then, if it does, we'll need to release a new version of threadpoolctl before considering merging this.