Threading refactor (8/8): reuse user-configured executor for user-callback dispatch#8
Open
igorbernstein2 wants to merge 2 commits into
Open
Conversation
mutianf
approved these changes
Jun 29, 2026
igorbernstein2
force-pushed
the
threading-refactor-phase-8
branch
from
June 30, 2026 15:39
482fd48 to
80158c8
Compare
ShimImpl now sources the userCallbackExecutor from the StubSettings when the caller has configured one — either via InstantiatingGrpcChannelProvider's setExecutor (PR googleapis#13557 exposed the getter on TransportChannelProvider) or the legacy StubSettings#setExecutorProvider. Ownership follows the source: transport-set is borrowed by convention; the legacy ExecutorProvider honors shouldAutoClose(). When neither is set the existing behavior is preserved — ShimImpl owns a dedicated bigtable-callback-shim cached pool. Client.userCallbackExecutor widens from Resource<ExecutorService> to Resource<Executor> to accept the borrowed handle; downstream consumers already require only Executor. The standalone Client.create(ClientSettings) path is unchanged: ClientSettings carries no executor wiring to source from.
igorbernstein2
force-pushed
the
threading-refactor-phase-7
branch
from
June 30, 2026 17:49
62b89be to
39bbfb4
Compare
igorbernstein2
force-pushed
the
threading-refactor-phase-8
branch
from
June 30, 2026 17:49
80158c8 to
dad737a
Compare
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
Phase 8 of 8. When the caller configures an executor on their
StubSettingsorInstantiatingGrpcChannelProvider, reuse it for user-callback dispatch instead of always allocating a separatebigtable-callback-shimcached pool. Closes the TODO atClient.java:92-94that had been blocked on a missing gax API (now landed via googleapis/google-cloud-java#13557).What's in here
refactor: reuse user-configured executor for user-callback dispatchShimImpl.createnow picks the user-callback executor via a newselectUserCallbackExecutor(transportProvider, executorProvider)helper. Priority: transport-set executor (InstantiatingGrpcChannelProvider#getExecutor, exposed by gax PR googleapis#13557) → legacyStubSettings#getExecutorProvider→ fresh cached pool. Ownership follows the source: transport-set is borrowed (Resource.createShared); legacy honorsExecutorProvider#shouldAutoClose(); the fallback cached pool is owned byClientas before.Client.userCallbackExecutorwidens fromResource<ExecutorService>toResource<Executor>to accept the borrowed handle.Detection signals
Both are crisp without class-identity checks:
transportProvider.getExecutor() != null→ user calledsetExecutoron the channel provider.stubSettings.getExecutorProvider() != null→ user called the deprecatedsetExecutorProvider(gax tracks this viadeprecatedExecutorProviderSetinStubSettings.java:139-141, returningnullfromgetExecutorProvider()otherwise).Tests
ShimImplTest(new) covers all four branches ofselectUserCallbackExecutor: transport-set, legacy withshouldAutoClose=false, legacy withshouldAutoClose=true, and the fallback owned pool (asserts thread-name prefix and thatclose()shuts it down).The standalone
Client.create(ClientSettings)path is unchanged —ClientSettingscarries no executor wiring to source from.Stack position
threading-refactor-phase-7