From 46a214d065f872f31f68cd147619490ea3d9fd9a Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Fri, 25 Aug 2023 09:36:08 +0300 Subject: [PATCH] [#149] pool: Configure homomorphic hash and buffer size Signed-off-by: Denis Kirillov --- pool/object_put_pool_transformer.go | 1 - pool/pool.go | 34 ++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/pool/object_put_pool_transformer.go b/pool/object_put_pool_transformer.go index c6add151..52c6813b 100644 --- a/pool/object_put_pool_transformer.go +++ b/pool/object_put_pool_transformer.go @@ -20,7 +20,6 @@ type logger interface { type PrmObjectPutClientCutInit struct { PrmObjectPut - withoutHomomorphicHash bool } func (c *clientWrapper) objectPutInitTransformer(prm PrmObjectPutClientCutInit) (*objectWriterTransformer, error) { diff --git a/pool/pool.go b/pool/pool.go index 70f789ea..4f8a42a8 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -634,6 +634,10 @@ func (c *clientWrapper) networkInfo(ctx context.Context, _ prmNetworkInfo) (netm // objectPut writes object to FrostFS. func (c *clientWrapper) objectPut(ctx context.Context, prm PrmObjectPut) (oid.ID, error) { + if prm.bufferMaxSize == 0 { + prm.bufferMaxSize = defaultBufferMaxSizeForPut + } + if prm.clientCut { return c.objectPutClientCut(ctx, prm) } @@ -679,10 +683,8 @@ func (c *clientWrapper) objectPutServerCut(ctx context.Context, prm PrmObjectPut } if prm.payload != nil { - const defaultBufferSizePut = 3 << 20 // default grpc message size, configure? - - if sz == 0 || sz > defaultBufferSizePut { - sz = defaultBufferSizePut + if sz == 0 || sz > prm.bufferMaxSize { + sz = prm.bufferMaxSize } buf := make([]byte, sz) @@ -748,10 +750,8 @@ func (c *clientWrapper) objectPutClientCut(ctx context.Context, prm PrmObjectPut } if prm.payload != nil { - const defaultBufferSizePut = 64 * 1024 // it's buffer size in s3-gw, configure? - - if sz == 0 || sz > defaultBufferSizePut { - sz = defaultBufferSizePut + if sz == 0 || sz > prm.bufferMaxSize { + sz = prm.bufferMaxSize } buf := make([]byte, sz) @@ -1409,6 +1409,10 @@ type PrmObjectPut struct { clientCut bool networkInfo netmap.NetworkInfo + + withoutHomomorphicHash bool + + bufferMaxSize uint64 } // SetHeader specifies header of the object. @@ -1443,6 +1447,18 @@ func (x *PrmObjectPut) SetClientCut(clientCut bool) { x.clientCut = clientCut } +// WithoutHomomorphicHash if set to true do not use Tillich-ZĂ©mor hash for payload. +func (x *PrmObjectPut) WithoutHomomorphicHash(v bool) { + x.withoutHomomorphicHash = v +} + +// SetBufferMaxSize sets max buffer size to read payload. +// This value isn't used if object size is set explicitly and less than this value. +// Default value 3MB. +func (x *PrmObjectPut) SetBufferMaxSize(size uint64) { + x.bufferMaxSize = size +} + func (x *PrmObjectPut) setNetworkInfo(ni netmap.NetworkInfo) { x.networkInfo = ni } @@ -1760,6 +1776,8 @@ const ( defaultHealthcheckTimeout = 4 * time.Second defaultDialTimeout = 5 * time.Second defaultStreamTimeout = 10 * time.Second + + defaultBufferMaxSizeForPut = 3 * 1024 * 1024 // 3 MB ) // NewPool creates connection pool using parameters.