diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2022-03-28 15:55:55 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2022-03-28 15:55:55 +0300 |
commit | f99ae8abf6f317892065e99463c179364c462383 (patch) | |
tree | 51b8b2328df1e3d8e254b849e11bb4c458fbba94 /internal/sidechannel | |
parent | 36aaf4e475fdcc4ae89f14772662fa89125d7716 (diff) |
sidechannel: use default yamux max window size
This changes the sidechannel client to not create unnecessarily large
buffers for received data. The previous behavior was to lazily buffer
up to 16MB of response data, which can lead to bloat in the client.
Changelog: other
Diffstat (limited to 'internal/sidechannel')
-rw-r--r-- | internal/sidechannel/sidechannel.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/internal/sidechannel/sidechannel.go b/internal/sidechannel/sidechannel.go index 74c7d0ab8..5cffe9efc 100644 --- a/internal/sidechannel/sidechannel.go +++ b/internal/sidechannel/sidechannel.go @@ -9,6 +9,7 @@ import ( "strconv" "time" + "github.com/hashicorp/yamux" "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/v14/internal/backchannel" "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/client" @@ -133,12 +134,23 @@ func NewServerHandshaker(registry *Registry) *ServerHandshaker { // NewClientHandshaker is used to enable sidechannel support on outbound // gRPC connections. func NewClientHandshaker(logger *logrus.Entry, registry *Registry) client.Handshaker { - return backchannel.NewClientHandshaker( + return backchannel.NewClientHandshakerWithYamuxConfig( logger, func() backchannel.Server { lm := listenmux.New(insecure.NewCredentials()) lm.Register(NewServerHandshaker(registry)) return grpc.NewServer(grpc.Creds(lm)) }, + func(cfg *yamux.Config) { + // Backchannel sets a very large custom window size (16MB). This is not + // necessary for sidechannels because we use one stream per connection. + // Worse, this is wasteful, because a client that is serving many + // concurrent sidechannel calls may end up lazily creating a 16MB buffer + // for each ongoing call. See + // https://gitlab.com/gitlab-org/gitaly/-/issues/4132. To prevent this + // waste we change this value back to 256KB which is the default and + // minimum value. + cfg.MaxStreamWindowSize = 256 * 1024 + }, ) } |