From 79509f82f62584e917fadda3bc9f7ce2741b1a42 Mon Sep 17 00:00:00 2001 From: Evgenii Baidakov Date: Tue, 17 Oct 2023 11:15:34 +0400 Subject: [PATCH] cache: Pre-allocated buffer for SDK client Signed-off-by: Evgenii Baidakov --- cmd/neofs-node/config.go | 7 +++++++ pkg/network/cache/client.go | 1 + pkg/network/cache/multi.go | 2 ++ 3 files changed, 10 insertions(+) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index b0d3c9b6ec0..25e82a94d27 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -545,11 +545,18 @@ func initCfg(appCfg *config.Config) *cfg { ) fatalOnErr(err) + var buffers sync.Pool + buffers.New = func() any { + b := make([]byte, cache.DefaultBufferSize) + return &b + } + cacheOpts := cache.ClientCacheOpts{ DialTimeout: apiclientconfig.DialTimeout(appCfg), StreamTimeout: apiclientconfig.StreamTimeout(appCfg), AllowExternal: apiclientconfig.AllowExternal(appCfg), ReconnectTimeout: apiclientconfig.ReconnectTimeout(appCfg), + Buffers: &buffers, } c.shared = shared{ key: key, diff --git a/pkg/network/cache/client.go b/pkg/network/cache/client.go index 0f0d3f9cd16..8b3231e83d9 100644 --- a/pkg/network/cache/client.go +++ b/pkg/network/cache/client.go @@ -26,6 +26,7 @@ type ( ReconnectTimeout time.Duration ResponseCallback func(client.ResponseMetaInfo) error AllowExternal bool + Buffers *sync.Pool } ) diff --git a/pkg/network/cache/multi.go b/pkg/network/cache/multi.go index 8ad7ce03dea..db3b52b1620 100644 --- a/pkg/network/cache/multi.go +++ b/pkg/network/cache/multi.go @@ -58,6 +58,8 @@ func (x *multiClient) createForAddress(addr network.Address) (clientcore.Client, prmDial client.PrmDial ) + prmInit.SetSignMessageBuffers(x.opts.Buffers) + prmDial.SetServerURI(addr.URIAddr()) if x.opts.DialTimeout > 0 {