googleapis / googleapis/google-cloud-java

[sdk-platform-java] Investigate InstantiatingGrpcChannelProvider's `isOnComputeEngine()` invocation on every channel creation

未关闭
#12,430 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
priority: p2 type: feature request
主要语言
Java
星标
2.1k
派生
1.2k
平均合并
1 天 23 小时
30 天内合并 PR
154

描述

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.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。