Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate InstantiatingGrpcChannelProvider's isOnComputeEngine() invocation on every channel creation #2883

Open
lqiu96 opened this issue Jun 12, 2024 · 0 comments
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

@lqiu96
Copy link
Contributor

lqiu96 commented Jun 12, 2024

When a gRPC channel is created, the logic will invoke the canUseDirectPath() method: https://github.com/googleapis/sdk-platform-java/blob/af10a9ef26a5fd9f24fc5341d144b8ee00ff3d00/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java#L476-L48. This call has a check to isOnComputeEngine() which will read a system file for GCE properties.

We may be able to improve performance a bit as we may only need to read this file once. It may be even more performant for ChannelPools which constantly resize the channels as it'll repeatedly create new channels (and read a file every time).

Consider making the isOnComputeEngine() call non-static and introduce a way to cache the systemProduceName value once it's read the first time. Subsequent calls will not need to read the file and can simply return the cached value.

@lqiu96 lqiu96 added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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

No branches or pull requests

1 participant