Open
Description
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.
The Java interface for ThreadPoolExecutor
calls this "prestart". For example: prestartCoreThread
and prestartAllCoreThreads
: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html#prestartCoreThread--
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?
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: