Skip to content

Commit

Permalink
cache: Pre-allocated buffer for SDK client
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
  • Loading branch information
smallhive committed Nov 2, 2023
1 parent 4fefe67 commit 1809e15
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/neofs-node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,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,
Expand Down
1 change: 1 addition & 0 deletions pkg/network/cache/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type (
ReconnectTimeout time.Duration
ResponseCallback func(client.ResponseMetaInfo) error
AllowExternal bool
Buffers *sync.Pool
}
)

Expand Down
2 changes: 2 additions & 0 deletions pkg/network/cache/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1809e15

Please sign in to comment.