From 18add2472703fb6c400d642fad40b64ef82175ae Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 16 Feb 2021 14:40:06 +0300 Subject: [PATCH] [#378] cmd/node: Configure GC options Add `GC_REMOVER_BATCH_SIZE` and `GC_REMOVER_SLEEP_INTERVAL` config values to shard's config section. Signed-off-by: Leonard Lyubich --- cmd/neofs-node/config.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 7d095f1e1..6c8d4b187 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -32,6 +32,7 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/services/control" tokenStorage "github.com/nspcc-dev/neofs-node/pkg/services/session/storage" "github.com/nspcc-dev/neofs-node/pkg/services/util/response" + util2 "github.com/nspcc-dev/neofs-node/pkg/util" "github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/profiler" "github.com/panjf2000/ants/v2" @@ -137,6 +138,10 @@ const ( cfgMetaBaseSection = "metabase" cfgMetaBasePath = "path" cfgMetaBasePerm = "perm" + + cfgGCSection = "gc" + cfgGCRemoverBatchSize = "remover_batch_size" + cfgGCRemoverSleepInt = "remover_sleep_interval" ) const ( @@ -560,6 +565,16 @@ func initShardOptions(c *cfg) { fatalOnErr(os.MkdirAll(path.Dir(metaPath), metaPerm)) + gcPrefix := configPath(prefix, cfgGCSection) + + rmBatchSize := c.viper.GetInt( + configPath(gcPrefix, cfgGCRemoverBatchSize), + ) + + rmSleepInterval := c.viper.GetDuration( + configPath(gcPrefix, cfgGCRemoverSleepInt), + ) + opts = append(opts, []shard.Option{ shard.WithLogger(c.log), shard.WithBlobStorOptions( @@ -588,6 +603,14 @@ func initShardOptions(c *cfg) { blobstor.WithBlobovniczaShallowDepth(0), blobstor.WithBlobovniczaShallowWidth(1), ), + shard.WithRemoverBatchSize(rmBatchSize), + shard.WithGCRemoverSleepInterval(rmSleepInterval), + shard.WithGCWorkerPoolInitializer(func(sz int) util2.WorkerPool { + pool, err := ants.NewPool(sz) + fatalOnErr(err) + + return pool + }), }) c.log.Info("storage shard options", @@ -600,6 +623,8 @@ func initShardOptions(c *cfg) { zap.Uint64("BLOB small size limit", smallSzLimit), zap.String("metabase path", metaPath), zap.Stringer("metabase permissions", metaPerm), + zap.Int("GC remover batch size", rmBatchSize), + zap.Duration("GC remover sleep interval", rmSleepInterval), ) }