Skip to content

Commit

Permalink
gnmi/client: add bdp flag
Browse files Browse the repository at this point in the history
Setting this flag to false will disable BDP and dynamic windows
 for the grpc connection that the client uses.
This is a workaround for grpc/grpc-go#5358
 which affects clients with high-latency.

Change-Id: Id43097bd32df6801fbbc0011886589a06d883903
  • Loading branch information
brianneville committed May 25, 2022
1 parent 23de196 commit 48e9df1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions gnmi/client.go
Expand Up @@ -64,6 +64,7 @@ type Config struct {
Username string
TLS bool
Compression string
BDP bool
DialOptions []grpc.DialOption
Token string
GRPCMetadata map[string]string
Expand Down Expand Up @@ -164,6 +165,23 @@ func (a *accessTokenCred) RequireTransportSecurity() bool { return true }
func DialContext(ctx context.Context, cfg *Config) (pb.GNMIClient, error) {
opts := append([]grpc.DialOption(nil), cfg.DialOptions...)

if !cfg.BDP {
// By default, the client and server will dynamically adjust the connection's
// window size using the Bandwidth Delay Product (BDP).
// See: https://grpc.io/blog/grpc-go-perf-improvements/
// The default values for InitialWindowSize and InitialConnWindowSize are 65535.
// If values less than 65535 are used, then BDP and dynamic windows are enabled.
// Here, we disable the BDP and dynamic windows by setting these values >= 65535.
// We set these values to (1 << 20) * 16 as this is the largest window size that
// the BDP estimator could ever use.
// See: https://github.com/grpc/grpc-go/blob/master/internal/transport/bdp_estimator.go
const maxWindowSize int32 = (1 << 20) * 16
opts = append(opts,
grpc.WithInitialWindowSize(maxWindowSize),
grpc.WithInitialConnWindowSize(maxWindowSize),
)
}

switch cfg.Compression {
case "":
case "gzip":
Expand Down
2 changes: 2 additions & 0 deletions gnmi/client/client.go
Expand Up @@ -60,6 +60,8 @@ func Main() {
flag.StringVar(&cfg.Compression, "compression", "", "Compression method. "+
`Supported options: "" and "gzip"`)
flag.BoolVar(&cfg.TLS, "tls", false, "Enable TLS")
flag.BoolVar(&cfg.BDP, "bdp", true,
"Enable Bandwidth Delay Product (BDP) estimation and dynamic flow control window")

subscribeOptions := &gnmi.SubscribeOptions{}
flag.StringVar(&subscribeOptions.Prefix, "prefix", "", "Subscribe prefix path")
Expand Down

0 comments on commit 48e9df1

Please sign in to comment.