GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Asynchronous pruning for RubyThreadPoolExecutor by joshuay03 · Pull Request #1082 · ruby-concurrency/concurrent-ruby

Conversation

@joshuay03

@joshuay03 joshuay03 commented Feb 8, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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
All reactions
  • 👀 2 reactions
@joshuay03
joshuay03 force-pushed the better-ruby-thread-pool-executor-pruning branch 15 times, most recently from b6e5656 to f90d46d Compare February 9, 2025 04:23
joshuay03
joshuay03 commented Feb 9, 2025
View reviewed changes
Comment thread lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

@joshuay03
joshuay03 force-pushed the better-ruby-thread-pool-executor-pruning branch 14 times, most recently from c5eca7d to 89b67f4 Compare February 14, 2025 15:54
@joshuay03
joshuay03 force-pushed the better-ruby-thread-pool-executor-pruning branch 4 times, most recently from fd02056 to 6cedac3 Compare March 17, 2025 08:52
eregon
eregon reviewed Mar 25, 2025
View reviewed changes

@eregon eregon left a comment

Copy link
Copy Markdown
Member

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.

All reactions
Comment thread lib/concurrent-ruby/concurrent/collection/ruby_timeout_queue.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/concurrent-ruby/concurrent/collection/ruby_timeout_queue.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

eregon
eregon reviewed Mar 25, 2025
View reviewed changes
Comment thread lib/concurrent-ruby/concurrent/collection/ruby_timeout_queue.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

@joshuay03
joshuay03 force-pushed the better-ruby-thread-pool-executor-pruning branch 4 times, most recently from defd0f7 to 9739e9a Compare March 26, 2025 09:34
eregon
eregon reviewed Mar 26, 2025
View reviewed changes
Comment thread lib/concurrent-ruby/concurrent/collection/ruby_timeout_queue.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

@joshuay03
joshuay03 force-pushed the better-ruby-thread-pool-executor-pruning branch from 9739e9a to 6aa4ee5 Compare March 26, 2025 09:40
eregon
eregon reviewed Mar 28, 2025
View reviewed changes

@eregon eregon left a comment

Copy link
Copy Markdown
Member

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.

All reactions
Comment thread lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb Resolved

Uh oh!

There was an error while loading. Please reload this page.

@joshuay03
joshuay03 force-pushed the better-ruby-thread-pool-executor-pruning branch 2 times, most recently from 101b66e to e4f5794 Compare April 2, 2025 13:45
@joshuay03
Asynchronous pruning for RubyThreadPoolExecutor
cb37798
@joshuay03 joshuay03 mentioned this pull request Nov 4, 2025
Should this be merged in concurrent-ruby? joshuay03/atomic-ruby#3
Closed
@eregon

eregon commented Nov 19, 2025

Copy link
Copy Markdown
Member

@bensheldon Could you review this?
Or any other concurrent-ruby maintainer more familiar with RubyThreadPoolExecutor of course :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bensheldon

bensheldon commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

@eregon yes, I will review.

eregon reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bensheldon
bensheldon approved these changes Dec 9, 2025
View reviewed changes

@bensheldon bensheldon left a comment

Copy link
Copy Markdown
Contributor

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
All reactions
  • ❤️ 1 reaction
Comment thread lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb
def prune_worker(worker)
synchronize do
if ns_prunable_capacity > 0
remove_worker worker

@bensheldon bensheldon Nov 30, 2025

Copy link
Copy Markdown
Contributor

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
All reactions
  • 👍 1 reaction

@joshuay03 joshuay03 Dec 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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:

concurrent-ruby/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb

Lines 45 to 46 in e25e34c

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.

All reactions
@eregon

eregon commented Dec 10, 2025

Copy link
Copy Markdown
Member

@joshuay03 I'll let you merge this yourself now that you're a maintainer of concurrent-ruby :)

joshuay03 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshuay03

joshuay03 commented Dec 10, 2025

Copy link
Copy Markdown
Contributor Author

Thank you both for the reviews!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joshuay03 joshuay03 mentioned this pull request Dec 15, 2025
Require concurrent-ruby >= 1.3.6 in activesupport rails/rails#56374
Closed
4 tasks done
This was referenced Feb 10, 2026
[Snyk] Security upgrade releasinator from 0.6.3 to 0.6.4 kingjay66/PayPal-PHP-SDK#3
Open
[Snyk] Security upgrade github-pages from 192 to 193 kingjay66/gplcc#5
Open
[Snyk] Security upgrade github-pages from 231 to 232 kingjay66/twinagle#11
Open
[Snyk] Security upgrade github-pages from 226 to 227 naiba4/dexie.js-web#11
Open
[Snyk] Security upgrade github-pages from 207 to 208 kingjay66/github-slideshow#16
Open
[Snyk] Security upgrade github-pages from 198 to 199 kingjay66/kbarchive#6
Open
@TechnicallyIncorrect1 TechnicallyIncorrect1 mentioned this pull request Jun 24, 2026
Bump concurrent-ruby from 1.3.4 to 1.3.7 NationalSecurityAgency/nationalsecurityagency.github.io#74
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bensheldon bensheldon bensheldon approved these changes
@eregon eregon eregon left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

CachedThreadPool does not spin down idle threads Unexpected pruning behaviour with consecutive task batches

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@joshuay03 @eregon @bensheldon
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.