GeezerVison is showing github.com — Asynchronous pruning for RubyThreadPoolExecutor by joshuay03 · Pull Request #1082 · ruby-concurrency/concurrent-ruby
Conversation
joshuay03
commented
Feb 8, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Closes #1066
Closes #1075
Alternative to #1079
Implementation is based on the discussion in the linked issues.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
dentarg and benaitcheson reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
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.
Finally taking a look at this, sorry for the delay
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
The Queue stuff looks ready to me, i.e. I reviewed and approve that part.
The pool changes it's hard for me to tell because I haven't had time to understand the implementation in details (and likely won't have time for that soon).
It would be great if another concurrent-ruby maintainer could help review that (and they should feel free to merge this PR after they approve)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
@bensheldon Could you review this?
Or any other concurrent-ruby maintainer more familiar with RubyThreadPoolExecutor of course :)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
eregon reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
I went through this and I think it looks good. I'm very excited about this new behavior 🙇🏻
- The Ruby TimeoutQueue implementation looks solid and resilient to idle wakeups and matches the interface of the native Ruby Queue-with-timeout.
- The pruning behavior in RubyThreadPoolExecutor looks correct. I spent a lot of time trying to understand the
prunable behavior, but I think I get it now; I wasn't able to think up a scenario where it wouldn't result in unintended behavior.
- Test cleanup looks defensible 👍🏻
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
joshuay03 reacted with heart emoji
|
|
def prune_worker(worker)
|
|
|
synchronize do
|
|
|
if ns_prunable_capacity > 0
|
|
|
remove_worker worker
|
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.
I think synchronize should be safe to nest, but noting that remove_worker also calls synchronize. Noting this because I've reviewed this twice and each time I've wanted to trace what was happening, which makes me think that having an ns_remove_worker might be clearer, but I don't feel strongly about it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
joshuay03 reacted with thumbs up emoji
joshuay03
Dec 10, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, MutexLockableObject#synchronize has been implemented to be re-entrant within the same thread:
|
if @__Lock__.owned? |
|
yield |
I decided to reuse remove_worker because of this re-entrancy guarantee, since it's also called independently in the thread loop. I think I'll keep it this way.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@joshuay03 I'll let you merge this yourself now that you're a maintainer of concurrent-ruby :)
|
joshuay03 reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thank you both for the reviews!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Feb 10, 2026
Reviewers
eregon
eregon left review comments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|