Repository navigation
BUG: Add size check for threaded array assignment - #24257
Conversation
…umber of elements exceeds threshold
|
I meant lets not set up benchmark with a threadpool. I think adding a benchmark with a huge number of small arrays or lists to concatenate would make sense. (I think we have concatenation benchmarks, so it may just be expanding those, or even checking that we do.) I might think that integrating the size calculation into |
|
If I'm reading this right, Here's the relevant benchmark before/after: Before size thresholdAfter size thresholdIn summary, ~50% runtime reduction for concatenate with a large number of small arrays. |
aec24a9 to
c859917
Compare
|
Close/reopen to rerun tests since so many failed when it was made. Probably a bit more benchmarks than necessary, but LGTM. |
|
@seberg As far as I can tell, these errors aren't related to the pull request. Is there anything I need to do in order to get this wrapped up? |
|
No, it would probably need a rebase to fix them up. I am OK with this, I had half hoped to calculate the size outside, but it seems worthwhile either way. One interesting angle (if you are interested!); Reading the Cython mailing list, I saw that at least with Python 3.11+ (maybe 3.10) GIL locking/unlocking seems vastly faster and there might actually be a point to lower the threshold, but that probably shouldn't stop this. So putting it in thanks, the biggest holdup was me being on vacation (and similar). |
|
If I had the time, I'd love to optimize some more. Unfortunately my work is more application-driven at the moment, so it's only when I come across a specific issue like this that I can justify spending some time on it. Either way, contributing certainly helped with my familiarity of the process - so it should at least be easier for me to contribute in the future. Thanks for all the help throughout! |
Many small array assignments releasing the GIL can cause slowdowns, and in multithreaded environments, can cause significant thread contention.
Add a size check to array assignment such that only assignments that exceed a certain number of elements (512) will release the GIL.
Closes gh-24252.