Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

InstantiatingGrpcChannelProvider requires ScheduledExecutorService for no good reason #1055

Closed
ChuntaoLu opened this issue May 14, 2020 · 6 comments · Fixed by #1098
Closed
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@ChuntaoLu
Copy link

The InstantiatingGrpcChannelProvider.withExecutor method requires ScheduledExecutorService, and similarly the InstantiatingGrpcChannelProvider$Builder. setExecutorProvider requires a ExecutorProvider(which provides ScheduledExecutorService), but this requirement seems overly strict, because the executor is only used for ManagedChannelBuilder.executor, which takes Executor rather than ScheduledExecutorService.

This unnecessary restriction prevents users from providing a more performant executor (e.g. ForkJoinPool) than ScheduledThreadPoolExecutor when building a gRPC channel.

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels May 15, 2020
@hkdevandla hkdevandla added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels May 20, 2020
@hkdevandla
Copy link
Member

@miraleung , can you please take a look? Thanks!

@yoshi-automation yoshi-automation removed the 🚨 This issue needs some love. label May 20, 2020
@igorbernstein2
Copy link
Contributor

I think this is a subset of the work I started here (but never finished):
#869

Feel free to pull out the relevant parts from it to address this issue

@hkdevandla
Copy link
Member

Thanks for the info. I'm wondering if this should be considered as a feature request (as it seems more like optimization). @miraleung , please let us know your thoughts.

CC'ed @vam-google

@miraleung
Copy link
Contributor

FYI, BatcherFactory and ScheduledRetryingExecutor both take ScheduledExecutorService in their constructors, via Callables.java. Relying on the creation site and casting this isn't sufficient, a more involved refactoring is probably needed.

@miraleung miraleung added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Jun 1, 2020
@igorbernstein2
Copy link
Contributor

@miraleung I think that gax tangles 2 unrelated executors together. I think that the roles need to untangled. The transports need an executor for immediate actions, while retries & batching need to schedule non-latency sensitive work.

There are 2 places to set the executor: stub settings and the transport provider. StubSettings will propagate its executor to both places (retries & transport). This means that you can make the transport provider take a regular executor w/o breaking anything. In the general case people will still set a ScheduleExecutor on StubSettings which will be propagated to and shared by retries & transport. However users like @ChuntaoLu can set a more optimized executor directly on the transport

@miraleung
Copy link
Contributor

Gotcha, thanks Igor.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants