feat(spanner): set manual affinity incase of gRPC-GCP extenstion by harshachinta · Pull Request #3215 · googleapis/java-spanner (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation5 Commits3 Checks26 Files changed
Conversation
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
[ Show hidden characters]({{ revealButtonHref }})
@@ -529,6 +531,10 @@ private static String parseGrpcGcpApiConfig() { |
---|
private static GcpManagedChannelOptions grpcGcpOptionsWithMetrics(SpannerOptions options) { |
GcpManagedChannelOptions grpcGcpOptions = |
MoreObjects.firstNonNull(options.getGrpcGcpOptions(), new GcpManagedChannelOptions()); |
GcpChannelPoolOptions gcpChanelPoolOptions = |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GcpChannelPoolOptions gcpChanelPoolOptions = |
---|
GcpChannelPoolOptions gcpChannelPoolOptions = |
.getCallOptions() |
---|
.withOption( |
GcpManagedChannel.AFFINITY_KEY, |
Option.CHANNEL_HINT.getLong(options).toString())); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This channel hint can be any random Long, meaning that we might be using a very large range of different channel hints. That again means that we might be adding an unbounded set of channel hints to the map in grpc-gcp. We should add a computation here that makes sure that the set of hints is limited (e.g. do something like hint % options.getNumChannels()
).
See
context = context.withChannelAffinity(Option.CHANNEL_HINT.getLong(options).intValue()); |
---|
// Set channel affinity in gRPC-GCP. This is a no-op for GAX. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is it possible to only do this if grpc-gcp is being used? I know that it is a no-op for gax, and so does not affect anything in that way, but context.withCallOptions(..)
always creates a new CallContext
instance. That means that we reserve a small bit of additional memory for every RPC that we invoke that then needs to be cleaned up again afterwards. (And yes, that's a bit of a pre-emptive optimization, so if it is not possible or hard, then please ignore this comment, but if there's a simple if-condition that we can use, then let's do that.)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made changes to do it only when grpcgcp is enabled. Can you please take a look?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Labels
Issues related to the googleapis/java-spanner API.
Pull request size is small.
2 participants