You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For my use case I would like to ensure that when I create a thread pool with min_threads > 0, that the minimum number of workers are created immediately.
I have a draft PR (here) that implements a similar API for the CRuby implementation (I left the JRuby implementation for later). It adds both methods, as well as a prestart option to the initializer.
Is this an API change you would consider accepting?
The advantage is that you get slightly improved latency on handling the first few items that are posted to the pool. On my system, I see about a 0.5ms improvement to handling the first few items when using prestart.
I think a small place to start would be to expose a Ruby equivalent of #prestartCoreThread: which creates a single thread unless max threads is reached.
Then one could manage the lifecycle decision themselves of whether they want to do something like:
executor=Concurrent::ThreadPoolExecutor.new(max_threads: 5)# immediately, or maybe later...executor.max_length.times{executor.add_worker}# or...executor.min_length.times{executor.add_worker}# or...arbitrary_number.times{executor.add_worker}
Activity
eregon commentedon Jan 17, 2024
What is the advantage of doing so?
The disadvantage is it likely causes extra resource consumption (CPU & memory).
catlee commentedon Jan 17, 2024
The advantage is that you get slightly improved latency on handling the first few items that are posted to the pool. On my system, I see about a 0.5ms improvement to handling the first few items when using prestart.
eregon commentedon Jan 17, 2024
I see. Could you share a repro for that? I'd like to try it locally.
catlee commentedon Jan 17, 2024
Here's how I'm trying to measure the impact:
bensheldon commentedon Dec 11, 2025
I think a small place to start would be to expose a Ruby equivalent of
#prestartCoreThread: which creates a single thread unless max threads is reached.Then one could manage the lifecycle decision themselves of whether they want to do something like: