Skip to content

Reuse idle threads in the GCS adapter default thread pool - #3255

Open
jmaeagle99 wants to merge 1 commit into
mainfrom
gcs-adapter-reuse-idle-threads
Open

jmaeagle99 wants to merge 1 commit into
mainfrom
gcs-adapter-reuse-idle-threads

Conversation

@jmaeagle99

Copy link
Copy Markdown
Contributor

What was changed

  • The GCS adapter's built-in thread pool now gives each call to an idle thread when one is waiting, starts a new thread only when none is idle, and queues calls once it reaches setThreadPoolMaxSize.
  • Threads still stop after a minute without work, and calls after close() are still rejected. The builder API and the default maximum of 400 are unchanged.

Why?

The pool merged in #3151 sets its core size equal to its maximum. ThreadPoolExecutor starts a new thread for every call until it reaches its core size, even while other threads sit idle. Idle threads then take turns at the queue, so each one gets work often enough never to time out. At a steady few storage calls per second, the pool grows to and stays at 400 threads even though only one or two calls run at a time. With this change the pool's size follows how many calls actually run at once, and 400 is only a ceiling for bursts.

Checklist

  1. How was this tested: Added a unit test that checks sequential calls reuse one pool thread; it fails against the previous pool, which used 20 threads for 20 calls.

  2. Any docs updates needed? No

@jmaeagle99
jmaeagle99 requested a review from a team as a code owner December 3, 2026 07:53

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant