diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index dd7f1bddaf..ee7d0abd7e 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -403,6 +403,8 @@ func initShardOptions(c *cfg) { writeCacheOpts = []writecache.Option{ writecache.WithPath(writeCacheCfg.Path()), writecache.WithLogger(c.log), + writecache.WithMaxBatchSize(writeCacheCfg.BoltDB().MaxBatchSize()), + writecache.WithMaxBatchDelay(writeCacheCfg.BoltDB().MaxBatchDelay()), writecache.WithMaxMemSize(writeCacheCfg.MemSize()), writecache.WithMaxObjectSize(writeCacheCfg.MaxObjectSize()), writecache.WithSmallObjectSize(writeCacheCfg.SmallObjectSize()), diff --git a/pkg/local_object_storage/writecache/options.go b/pkg/local_object_storage/writecache/options.go index 71ecb4427c..64e1feba9c 100644 --- a/pkg/local_object_storage/writecache/options.go +++ b/pkg/local_object_storage/writecache/options.go @@ -1,6 +1,8 @@ package writecache import ( + "time" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" "go.uber.org/zap" @@ -31,6 +33,10 @@ type options struct { maxCacheSize uint64 // objCounters is an ObjectCounters instance needed for cache size estimation. objCounters ObjectCounters + // maxBatchSize is the maximum batch size for the small object database. + maxBatchSize int + // maxBatchDelay is the maximum batch wait time for the small object database. + maxBatchDelay time.Duration } // WithLogger sets logger. @@ -107,3 +113,21 @@ func WithMaxCacheSize(sz uint64) Option { o.maxCacheSize = sz } } + +// WithMaxBatchSize sets max batch size for the small object database. +func WithMaxBatchSize(sz int) Option { + return func(o *options) { + if sz > 0 { + o.maxBatchSize = sz + } + } +} + +// WithMaxBatchDelay sets max batch delay for the small object database. +func WithMaxBatchDelay(d time.Duration) Option { + return func(o *options) { + if d > 0 { + o.maxBatchDelay = d + } + } +} diff --git a/pkg/local_object_storage/writecache/storage.go b/pkg/local_object_storage/writecache/storage.go index 4f2458c7cd..48c88e80fa 100644 --- a/pkg/local_object_storage/writecache/storage.go +++ b/pkg/local_object_storage/writecache/storage.go @@ -38,6 +38,9 @@ func (c *cache) openStore() error { return fmt.Errorf("could not open database: %w", err) } + c.db.MaxBatchSize = c.maxBatchSize + c.db.MaxBatchDelay = c.maxBatchDelay + err = c.db.Update(func(tx *bbolt.Tx) error { _, err := tx.CreateBucketIfNotExists(defaultBucket) return err diff --git a/pkg/local_object_storage/writecache/writecache.go b/pkg/local_object_storage/writecache/writecache.go index 763f58bfc8..52e0f8e81d 100644 --- a/pkg/local_object_storage/writecache/writecache.go +++ b/pkg/local_object_storage/writecache/writecache.go @@ -6,6 +6,7 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" + "go.etcd.io/bbolt" "go.uber.org/zap" ) @@ -98,6 +99,8 @@ func New(opts ...Option) Cache { smallObjectSize: smallObjectSize, workersCount: defaultFlushWorkersCount, maxCacheSize: maxCacheSizeBytes, + maxBatchSize: bbolt.DefaultMaxBatchSize, + maxBatchDelay: bbolt.DefaultMaxBatchDelay, }, }