Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
gh-102024: Reduced _idle_semaphore.release calls#102025
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-102024: Reduced _idle_semaphore.release calls#102025
Uh oh!
There was an error while loading.Please reload this page.
Conversation
bedevere-bot commentedFeb 18, 2023
Most changes to Pythonrequire a NEWS entry. Please add it using theblurb_it web app or theblurb command-line tool. |
ghost commentedFeb 18, 2023 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
bedevere-bot commentedFeb 18, 2023
Most changes to Pythonrequire a NEWS entry. Please add it using theblurb_it web app or theblurb command-line tool. |
Uh oh!
There was an error while loading.Please reload this page.
bedevere-bot commentedFeb 18, 2023
Most changes to Pythonrequire a NEWS entry. Please add it using theblurb_it web app or theblurb command-line tool. |
Thanks! One more important thing is missing: benchmarks. |
arhadthedev commentedFeb 19, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@sobolevn BTW is there any newcomer |
jackcvr commentedFeb 19, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Added some benchmarks. In my tests there is noticeable boost for submits to one thread. |
sobolevn commentedFeb 19, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@arhadthedev I don't know :( |
_idle_semaphore.release() is called if only work_queue is empty
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.
Thanks, this looks good to me. I have this exact same change in some custom thread pool code I use :-)
I'm a little confused by your benchmarking. I'm not sure why you'd expect the only submit case to speed up (and I can't repro a speed up on that case locally), without shutting down the executor. Of course, if you add the shutdown, I can measure a win (though ofc the size of win varies based on task count, task size, thread count).
Uh oh!
There was an error while loading.Please reload this page.
…res/thread.pyCo-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
bedevere-bot commentedMay 24, 2023
🤖 New build scheduled with the buildbot fleet by@hauntsaninja for commitafbdad6 🤖 If you want to schedule another build, you need to add the🔨 test-with-buildbots label again. |
Reduced _idle_semaphore.release calls in concurrent.futures.thread._worker_idle_semaphore.release() is now only called if only work_queue is empty.---------(cherry picked from commit0242e9a)Co-authored-by: Andrii Kuzmin <jack.cvr@gmail.com>Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
bedevere-bot commentedMay 26, 2023
GH-104959 is a backport of this pull request to the3.12 branch. |
…104959)gh-102024: Reduced _idle_semaphore.release calls (GH-102025)Reduced _idle_semaphore.release calls in concurrent.futures.thread._worker_idle_semaphore.release() is now only called if only work_queue is empty.---------(cherry picked from commit0242e9a)Co-authored-by: Andrii Kuzmin <jack.cvr@gmail.com>Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
_idle_semaphore.release() is called if only work_queue is empty
Benchmarks:
submit_only:
before:
W=1: 100000 loops, best of 10: 17.6 usec per loop
W=2: 100000 loops, best of 10: 10.5 usec per loop
W=4: 100000 loops, best of 10: 10.5 usec per loop
after:
W=1: 100000 loops, best of 10: 7.42 usec per loop
W=2: 100000 loops, best of 10: 7.5 usec per loop
W=4: 100000 loops, best of 10: 7.5 usec per loop
submit_then_wait:
before:
W=1: 10 loops, best of 10: 110 msec per loop
W=2: 10 loops, best of 10: 100 msec per loop
W=4: 10 loops, best of 10: 114 msec per loop
after:
W=1: 10 loops, best of 10: 85.2 msec per loop
W=2: 10 loops, best of 10: 83.9 msec per loop
W=4: 10 loops, best of 10: 86.5 msec per loop