Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1899 +/- ##
==========================================
+ Coverage 93.67% 93.74% +0.06%
==========================================
Files 46 46
Lines 8869 8932 +63
==========================================
+ Hits 8308 8373 +65
+ Misses 561 559 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Test failure is known error, #1890 |
cakedev0
left a comment
There was a problem hiding this comment.
Thanks for working on this, AI found a couple of fairly important bugs, but they don't look too hard to fix.
About your coverage question: I think the bugs AI found show which kind of tests this threading-only path needs: errors and early exit, verbose, nested calls, BaseException, ...
|
One more issue with the fast path: because it ignores import time
import numpy as np
from joblib import Parallel, delayed
def load(i):
return np.full(2_000_000, i, dtype=np.float64) # 16 MB, e.g. a chunk read from disk
def process(x):
time.sleep(0.05)
return float(x[0])
Parallel(n_jobs=4, backend="threading")(delayed(process)(load(i)) for i in range(1000))Peak extra RSS: ~12GB on this branch, 144 MB on main. Streaming chunks into threads that release the GIL is a typical use of the threading backend, and the docstring presents I discussed this with @ogrisel IRL, and one idea is to take the fast path only when I also had my agent trying to honour One related point that the restriction doesn't solve: inside |
|
I really should've thought of that, sorry. I don't want to limit to
I think that will solve both cases. |
|
It's worth giving it a try. |
|
OK, updated with Memory usage is a bit higher than main branch for the example above, but same order of magnitude so this should fix the memory usage problem. |
|
(GitHub is being slow about noticing pushed commits.) |
|
Ugh, |
|
Ok, should be ready for review again; looks like the failure is in Loky? |
|
The new Could the call use Review of head 6ba5473. I executed the exact extracted PR parser and CPython v3.14.0 |
|
@B0yko if there is a human behind the bot, can you share a few details about your motivation and what you are trying to do? It seems like you are "AI-reviewing" PRs in a variety of unrelated repos, and I personally don't think this is very useful! See scikit-learn's automated contribution policy for more details. |
|
It's a real bug, but also yeah I'd just block people who have no direct interest in the repo. |
|
I wonder if expanded testing is catching existing bugs that weren't previously being caught? In any case I will look at errors in more detail next week. |
|
Got as far as figuring out that these are real bugs, seemingly caused by switch to ThreadPoolExecutor. Since Loky is also an executor modeling on that ought to help, but we'll see. |
|
Maybe easiest thing to do is have ThreadingBackend stick to ThreadPool and then... FastThreadingBackend or something that never gets instantiated by a user but gets instantiated behind the scenes and that uses ThreadPoolExecutor. And that also reduces risk that I introduced more obscure race conditions than the ones showing up in CI. |
|
Should be ready for review again. New scheme is less risky, as slow path is the same as it was before. |
|
Realized there is one difference in behavior between slow and fast path: on free-threaded Python, the |
|
I would suggest finishing this up in a follow-up, separate release than #1871, so the oversaturation work can get out the door faster. |
Fixes #1830
Backwards compatibility results in overhead that would be unnecessary if simply switching to using a
ThreadPoolExecutor/ThreadPooldirectly, but it's definitely a meaningful improvement. And follow-ups could probably do even better (caching the thread pool can be very helpful).Question for reviewers: Adding a different code path for some configurations undermines the test coverage somewhat. Which of these solutions would you prefer?
threadingbackend, which seems reasonable to me.Benchmarks
MiniBatchDictionaryLearningin scikit-learn (scikit-learn/scikit-learn#4769) on free-threaded PythonBenchmark code:
Details
joblib
mainbranchThis PR
New
benchmarks/bench_simple_parallel.pyin PRDetails
mainbranchPR