From 805862f4b726c13e57225c472e4992eab29a37aa Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 2 Feb 2024 20:28:05 +0300 Subject: [PATCH] [#956] node: Allow to reload goroutine pool sizes Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-node/config.go | 23 +++++++++++++++++++++++ internal/logs/logs.go | 1 + 2 files changed, 24 insertions(+) diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index e5881cc2..c41863ec 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -1235,6 +1235,7 @@ func (c *cfg) reloadConfig(ctx context.Context) { setRuntimeParameters(c) return nil }}) + components = append(components, dCmp{"pools", c.reloadPools}) components = append(components, dCmp{"tracing", func() error { updated, err := tracing.Setup(ctx, *tracingconfig.ToTracingConfig(c.appCfg)) if updated { @@ -1279,6 +1280,28 @@ func (c *cfg) reloadConfig(ctx context.Context) { c.log.Info(logs.FrostFSNodeConfigurationHasBeenReloadedSuccessfully) } +func (c *cfg) reloadPools() error { + newSize := objectconfig.Put(c.appCfg).PoolSizeLocal() + c.reloadPool(c.cfgObject.pool.putLocal, newSize, "object.put.local_pool_size") + + newSize = objectconfig.Put(c.appCfg).PoolSizeRemote() + c.reloadPool(c.cfgObject.pool.putRemote, newSize, "object.put.remote_pool_size") + + newSize = replicatorconfig.PoolSize(c.appCfg) + c.reloadPool(c.cfgObject.pool.replication, newSize, "replicator.pool_size") + + return nil +} + +func (c *cfg) reloadPool(p *ants.Pool, newSize int, name string) { + oldSize := p.Cap() + if oldSize != newSize { + c.log.Info(logs.FrostFSNodePoolConfigurationUpdate, zap.String("field", name), + zap.Int("old", oldSize), zap.Int("new", newSize)) + p.Tune(newSize) + } +} + func (c *cfg) reloadAppConfig() error { unlock := c.LockAppConfigExclusive() defer unlock() diff --git a/internal/logs/logs.go b/internal/logs/logs.go index e81976a3..c3d2e515 100644 --- a/internal/logs/logs.go +++ b/internal/logs/logs.go @@ -451,6 +451,7 @@ const ( FrostFSNodeLoggerConfigurationPreparation = "logger configuration preparation" FrostFSNodeTracingConfigationUpdated = "tracing configation updated" FrostFSNodeStorageEngineConfigurationUpdate = "storage engine configuration update" + FrostFSNodePoolConfigurationUpdate = "adjust pool configuration" FrostFSNodeUpdatedConfigurationApplying = "updated configuration applying" FrostFSNodeConfigurationHasBeenReloadedSuccessfully = "configuration has been reloaded successfully" FrostFSNodeReadNewlyCreatedContainerAfterTheNotification = "read newly created container after the notification"