Repository navigation
Conversation
itamarst
marked this pull request as ready for review
August 13, 2026 17:50
Contributor
Author
|
I considered reducing joblib overhead in joblib itself, but it's very complex, with a lot of backwards compatibility requirements; this is much simpler and much less constrained by the need to support every edge case. And scikit-learn only uses a subset of joblib's functionality, which also makes it easier. |
Contributor
Author
|
Since this PR includes two distinct questions—a new API and a new parallelism site—I'm going to put it on hold, and instead have a PR that just converts existing parallelism into a faster API. And then can revisit this if/when new API is merged. |
itamarst
marked this pull request as draft
September 9, 2026 17:46
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR does two things:
joblib.Parallelhas very significant per-operation overhead, which is fine for the usual use case of a few large chunks of work, but becomes a problem if you have lots of small fast functions to call. See the benchmark results for numbers.Note that much of the code in both CountVectorizer and HashingVectorizer is still single-threaded, so in theory more could be done to speed these up.
All benchmarks were run with 12 cores, on Python 3.14 free-threaded.
Questions for reviewer:
Benchmarks
Baseline on
mainbranchparallel_thread_map()in this PRconcurrent.futures.ThreadPoolExecutoris faster:Other alternative thread pool benchmarks
Way too slow: sklearn.utils.parallel.Parallel
This actually makes things worse, because the overhead is so high:
Faster, but not yet ready for real-world usage:
spinningjennyspinningjennyis a faster alternative to stdlibThreadPoolExecutor. Still just a prototype, so missing features and not quite ready to use, but just to give an example of what is possible: