Default async future completion executor is effectively single-threaded #968
Labels
bug
This issue is a bug.
pending-release
This issue will be fixed by an approved PR that hasn't been released yet.
The default async future completion executor is effectively single-thread with the current construction.
Expected Behavior
The intent appears to be an executor that grows from 0 to 50 workers, and then queues 10,000 additional requests. However, that is not the behavior of ThreadPoolExecutor with the given configuration.
With the configuration above, the executor is limited to its core pool size (0), after which it must fill its queue (capacity 10,000), and only when the queue is full does the executor grow to the max pool size (50).
The underlying implementation in ThreadPoolExecutor ensures there is at least one worker after submission to the queue, even if core pool size is zero, hence the single-threaded behavior (as opposed to complete inoperability).
Current Behavior
Consider the following unit test:
Output:
Now consider this alternative construction, which seems to reflect the original intent:
Output:
Context
Identified while debugging an application and noticing that requests using
thenApply
orthenCompose
on aCompletableFuture
returned by the SDK were being funneled through a single thread in thesdk-async-response
thread pool.Your Environment
The text was updated successfully, but these errors were encountered: