[#493] node: Abolish configuration of pools of notification handlers

There is no need to use synchronous execution of notification handlers. Also
there is no understanding of how to assess the need to change the size of
the pools.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-12 11:28:23 +03:00 committed by Leonard Lyubich
parent 3ef5b0ff9c
commit 1f817d1cd2

View file

@ -85,18 +85,12 @@ const (
// config keys for cfgNetmap // config keys for cfgNetmap
cfgNetmapContract = "netmap.scripthash" cfgNetmapContract = "netmap.scripthash"
cfgNetmapWorkerPoolEnabled = "netmap.async_worker.enabled"
cfgNetmapWorkerPoolSize = "netmap.async_worker.size"
// config keys for cfgContainer // config keys for cfgContainer
cfgContainerContract = "container.scripthash" cfgContainerContract = "container.scripthash"
cfgContainerWorkerPoolEnabled = "container.async_worker.enabled"
cfgContainerWorkerPoolSize = "container.async_worker.size"
// config keys for cfgReputation // config keys for cfgReputation
cfgReputationContract = "reputation.scripthash" cfgReputationContract = "reputation.scripthash"
cfgReputationWorkerPoolEnabled = "reputation.async_worker.enabled"
cfgReputationWorkerPoolSize = "reputation.async_worker.size"
cfgGCQueueSize = "gc.queuesize" cfgGCQueueSize = "gc.queuesize"
cfgGCQueueTick = "gc.duration.sleep" cfgGCQueueTick = "gc.duration.sleep"
@ -164,6 +158,10 @@ const (
const maxMsgSize = 4 << 20 // transport msg limit 4 MiB const maxMsgSize = 4 << 20 // transport msg limit 4 MiB
// capacity of the pools of the morph notification handlers
// for each contract listener.
const notificationHandlerPoolSize = 10
type cfg struct { type cfg struct {
ctx context.Context ctx context.Context
@ -359,14 +357,13 @@ func initCfg(path string) *cfg {
state := newNetworkState() state := newNetworkState()
// initialize async workers if it is configured so containerWorkerPool, err := ants.NewPool(notificationHandlerPoolSize)
containerWorkerPool, err := initContainerWorkerPool(viperCfg)
fatalOnErr(err) fatalOnErr(err)
netmapWorkerPool, err := initNetmapWorkerPool(viperCfg) netmapWorkerPool, err := ants.NewPool(notificationHandlerPoolSize)
fatalOnErr(err) fatalOnErr(err)
reputationWorkerPool, err := initReputationWorkerPool(viperCfg) reputationWorkerPool, err := ants.NewPool(notificationHandlerPoolSize)
fatalOnErr(err) fatalOnErr(err)
relayOnly := viperCfg.GetBool(cfgReBootstrapRelay) relayOnly := viperCfg.GetBool(cfgReBootstrapRelay)
@ -460,15 +457,8 @@ func defaultConfiguration(v *viper.Viper) {
v.SetDefault(cfgAccountingContract, "1aeefe1d0dfade49740fff779c02cd4a0538ffb1") v.SetDefault(cfgAccountingContract, "1aeefe1d0dfade49740fff779c02cd4a0538ffb1")
v.SetDefault(cfgContainerContract, "9d2ca84d7fb88213c4baced5a6ed4dc402309039") v.SetDefault(cfgContainerContract, "9d2ca84d7fb88213c4baced5a6ed4dc402309039")
v.SetDefault(cfgContainerWorkerPoolEnabled, true)
v.SetDefault(cfgContainerWorkerPoolSize, 10)
v.SetDefault(cfgReputationWorkerPoolEnabled, true)
v.SetDefault(cfgReputationWorkerPoolSize, 10)
v.SetDefault(cfgNetmapContract, "75194459637323ea8837d2afe8225ec74a5658c3") v.SetDefault(cfgNetmapContract, "75194459637323ea8837d2afe8225ec74a5658c3")
v.SetDefault(cfgNetmapWorkerPoolEnabled, true)
v.SetDefault(cfgNetmapWorkerPoolSize, 10)
v.SetDefault(cfgLogLevel, "info") v.SetDefault(cfgLogLevel, "info")
@ -759,36 +749,6 @@ func initObjectPool(cfg *viper.Viper) (pool cfgObjectRoutines) {
return pool return pool
} }
func initNetmapWorkerPool(v *viper.Viper) (util2.WorkerPool, error) {
if v.GetBool(cfgNetmapWorkerPoolEnabled) {
// return async worker pool
return ants.NewPool(v.GetInt(cfgNetmapWorkerPoolSize))
}
// return sync worker pool
return util2.SyncWorkerPool{}, nil
}
func initContainerWorkerPool(v *viper.Viper) (util2.WorkerPool, error) {
if v.GetBool(cfgContainerWorkerPoolEnabled) {
// return async worker pool
return ants.NewPool(v.GetInt(cfgContainerWorkerPoolSize))
}
// return sync worker pool
return util2.SyncWorkerPool{}, nil
}
func initReputationWorkerPool(v *viper.Viper) (util2.WorkerPool, error) {
if v.GetBool(cfgReputationWorkerPoolEnabled) {
// return async worker pool
return ants.NewPool(v.GetInt(cfgReputationWorkerPoolSize))
}
// return sync worker pool
return util2.SyncWorkerPool{}, nil
}
func (c *cfg) LocalNodeInfo() (*netmapV2.NodeInfo, error) { func (c *cfg) LocalNodeInfo() (*netmapV2.NodeInfo, error) {
ni := c.localNodeInfo() ni := c.localNodeInfo()
return ni.ToV2(), nil return ni.ToV2(), nil