fix/355-increase-tree-service-client-cache-size #359
5 changed files with 72 additions and 8 deletions
|
@ -64,12 +64,16 @@ func (c *httpComponent) shutdown() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *httpComponent) reload() {
|
func (c *httpComponent) needReload() bool {
|
||||||
log.Info(fmt.Sprintf("reload %s", c.name))
|
|
||||||
enabled := cfg.GetBool(c.name + enabledKeyPostfix)
|
enabled := cfg.GetBool(c.name + enabledKeyPostfix)
|
||||||
address := cfg.GetString(c.name + addressKeyPostfix)
|
address := cfg.GetString(c.name + addressKeyPostfix)
|
||||||
dur := cfg.GetDuration(c.name + shutdownTimeoutKeyPostfix)
|
dur := cfg.GetDuration(c.name + shutdownTimeoutKeyPostfix)
|
||||||
if enabled != c.enabled || enabled && (address != c.address || dur != c.shutdownDur) {
|
return enabled != c.enabled || enabled && (address != c.address || dur != c.shutdownDur)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *httpComponent) reload() {
|
||||||
|
log.Info(fmt.Sprintf("reload %s", c.name))
|
||||||
|
if c.needReload() {
|
||||||
log.Info(fmt.Sprintf("%s config updated", c.name))
|
log.Info(fmt.Sprintf("%s config updated", c.name))
|
||||||
if err := c.shutdown(); err != nil {
|
if err := c.shutdown(); err != nil {
|
||||||
log.Debug(logs.FrostFSIRCouldNotShutdownHTTPServer,
|
log.Debug(logs.FrostFSIRCouldNotShutdownHTTPServer,
|
||||||
|
|
|
@ -30,7 +30,7 @@ var (
|
||||||
intErr = make(chan error) // internal inner ring errors
|
intErr = make(chan error) // internal inner ring errors
|
||||||
logPrm = new(logger.Prm)
|
logPrm = new(logger.Prm)
|
||||||
innerRing *innerring.Server
|
innerRing *innerring.Server
|
||||||
pprofCmp *httpComponent
|
pprofCmp *pprofComponent
|
||||||
metricsCmp *httpComponent
|
metricsCmp *httpComponent
|
||||||
log *logger.Logger
|
log *logger.Logger
|
||||||
cfg *viper.Viper
|
cfg *viper.Viper
|
||||||
|
|
|
@ -1,12 +1,68 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
httputil "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/http"
|
httputil "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/http"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newPprofComponent() *httpComponent {
|
type pprofComponent struct {
|
||||||
return &httpComponent{
|
httpComponent
|
||||||
name: "pprof",
|
blockRate int
|
||||||
handler: httputil.Handler(),
|
mutexRate int
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
pprofBlockRateKey = "pprof.block_rate"
|
||||||
|
pprofMutexRateKey = "pprof.mutex_rate"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newPprofComponent() *pprofComponent {
|
||||||
|
return &pprofComponent{
|
||||||
|
httpComponent: httpComponent{
|
||||||
|
name: "pprof",
|
||||||
|
handler: httputil.Handler(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *pprofComponent) init() {
|
||||||
|
c.httpComponent.init()
|
||||||
|
|
||||||
|
if c.enabled {
|
||||||
|
c.blockRate = cfg.GetInt(pprofBlockRateKey)
|
||||||
|
c.mutexRate = cfg.GetInt(pprofMutexRateKey)
|
||||||
|
runtime.SetBlockProfileRate(c.blockRate)
|
||||||
|
runtime.SetMutexProfileFraction(c.mutexRate)
|
||||||
|
} else {
|
||||||
|
c.blockRate = 0
|
||||||
|
c.mutexRate = 0
|
||||||
|
runtime.SetBlockProfileRate(0)
|
||||||
|
runtime.SetMutexProfileFraction(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *pprofComponent) needReload() bool {
|
||||||
|
blockRate := cfg.GetInt(pprofBlockRateKey)
|
||||||
|
mutexRate := cfg.GetInt(pprofMutexRateKey)
|
||||||
|
return c.httpComponent.needReload() ||
|
||||||
|
c.enabled && (c.blockRate != blockRate || c.mutexRate != mutexRate)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *pprofComponent) reload() {
|
||||||
|
log.Info(fmt.Sprintf("reload %s", c.name))
|
||||||
|
if c.needReload() {
|
||||||
|
log.Info(fmt.Sprintf("%s config updated", c.name))
|
||||||
|
if err := c.shutdown(); err != nil {
|
||||||
|
log.Debug(logs.FrostFSIRCouldNotShutdownHTTPServer,
|
||||||
|
zap.String("error", err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.init()
|
||||||
|
c.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,8 @@ FROSTFS_IR_CONTRACTS_ALPHABET_ZHIVETE=f584699bc2ff457d339fb09f16217042c1a42101
|
||||||
FROSTFS_IR_PPROF_ENABLED=true
|
FROSTFS_IR_PPROF_ENABLED=true
|
||||||
FROSTFS_IR_PPROF_ADDRESS=localhost:6060
|
FROSTFS_IR_PPROF_ADDRESS=localhost:6060
|
||||||
FROSTFS_IR_PPROF_SHUTDOWN_TIMEOUT=30s
|
FROSTFS_IR_PPROF_SHUTDOWN_TIMEOUT=30s
|
||||||
|
FROSTFS_IR_PPROF_BLOCK_RATE=10000
|
||||||
|
FROSTFS_IR_PPROF_MUTEX_RATE=10000
|
||||||
|
|
||||||
FROSTFS_IR_PROMETHEUS_ENABLED=true
|
FROSTFS_IR_PROMETHEUS_ENABLED=true
|
||||||
FROSTFS_IR_PROMETHEUS_ADDRESS=localhost:9090
|
FROSTFS_IR_PROMETHEUS_ADDRESS=localhost:9090
|
||||||
|
|
|
@ -113,6 +113,8 @@ pprof:
|
||||||
enabled: true
|
enabled: true
|
||||||
address: localhost:6060 # Endpoint for application pprof profiling; disabled by default
|
address: localhost:6060 # Endpoint for application pprof profiling; disabled by default
|
||||||
shutdown_timeout: 30s # Timeout for profiling HTTP server graceful shutdown
|
shutdown_timeout: 30s # Timeout for profiling HTTP server graceful shutdown
|
||||||
|
block_rate: 10000 # sampling rate: an average of one blocking event per rate nanoseconds spent blocked is reported; "1" reports every blocking event; "0" disables profiler
|
||||||
|
mutex_rate: 10000 # sampling rate: on average 1/rate events are reported; "0" disables profiler
|
||||||
|
|
||||||
prometheus:
|
prometheus:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
Loading…
Reference in a new issue