Clarify Dispatcher executor sizing requirements in KDoc#9454
Open
leno23 wants to merge 1 commit into
Open
Conversation
The previous wording implied that an executor sized to maxRequests is sufficient. In practice, promoteAndExecute() submits the next call from a worker thread before it returns to the queue, which can cause RejectedExecutionException with SynchronousQueue and a fixed-size pool. Fixes square#9443 Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Dispatcherclass KDoc to explain that an executor sized exactly tomaxRequestsis not sufficient when paired withSynchronousQueue.maxPoolSize=Int.MAX_VALUEand suggest safe alternatives (2 × maxRequestsor a queueing executor).Fixes #9443
Problem
The previous wording ("should be able to run maxRequests number of calls concurrently") led users to configure
ThreadPoolExecutor(maxRequests, maxRequests, ..., SynchronousQueue), which can reject submissions withInterruptedIOException("executor rejected")under sustained load. This happens becausepromoteAndExecute()submits the next promoted call from a worker thread before it returns to the queue.Test plan