From 2a3fd4ea87b260eb459a1ad0377c2899fb54b39f Mon Sep 17 00:00:00 2001 From: Andrey Bronin Date: Thu, 10 Sep 2020 15:31:38 +0300 Subject: [PATCH 1/3] ignoring metrics namespace config param --- ledger-core/metrics/metrics.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ledger-core/metrics/metrics.go b/ledger-core/metrics/metrics.go index 2e42919633..fc857c17a9 100644 --- a/ledger-core/metrics/metrics.go +++ b/ledger-core/metrics/metrics.go @@ -67,8 +67,9 @@ func (m *Metrics) Init(ctx context.Context) error { zpages.Handle(mux, "/debug") } + inslogger.FromContext(ctx).Warn("ignoring config param INSOLAR_METRICS_NAMESPACE = %s", m.config.Namespace) _, err := insmetrics.RegisterPrometheus( - m.config.Namespace, + insolarNamespace, m.registry, m.config.ReportingPeriod, errLogger, From a6ee1f7d1574c6049283ca2b6bb240126353677f Mon Sep 17 00:00:00 2001 From: Sergey Morozov Date: Tue, 15 Sep 2020 16:09:04 +0300 Subject: [PATCH 2/3] PLAT-822: added MaxRunners param to node config (#768) One can set it using env var `INSOLAR_VIRTUAL_MAXRUNNERS=n` --- ledger-core/configuration/configuration.go | 3 +++ .../configuration/testdata/changed.yml | 2 ++ .../configuration/testdata/default.yml | 2 ++ ledger-core/configuration/virtual.go | 21 +++++++++++++++++++ .../10node/configuration/virtual-config.yaml | 2 ++ .../15node/configuration/virtual-config.yaml | 2 ++ .../20node/configuration/virtual-config.yaml | 2 ++ .../40node/configuration/virtual-config.yaml | 2 ++ .../5node/configuration/virtual-config.yaml | 2 ++ .../80node/configuration/virtual-config.yaml | 2 ++ .../configuration/virtual-config.yaml | 4 +++- .../server/internal/virtual/app_factory.go | 5 +++-- 12 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 ledger-core/configuration/virtual.go diff --git a/ledger-core/configuration/configuration.go b/ledger-core/configuration/configuration.go index 3daab3ae1e..a4a4d142e1 100644 --- a/ledger-core/configuration/configuration.go +++ b/ledger-core/configuration/configuration.go @@ -40,6 +40,7 @@ type CommonAppConfig struct { type VirtualNodeConfig struct { CommonAppConfig LogicRunner LogicRunner + Virtual Virtual } type LightNodeConfig struct { @@ -66,6 +67,7 @@ type Configuration struct { Log Log Metrics Metrics LogicRunner LogicRunner + Virtual Virtual APIRunner APIRunner AdminAPIRunner APIRunner TestWalletAPI TestWalletAPI @@ -101,6 +103,7 @@ func NewConfiguration() Configuration { Log: NewLog(), Metrics: NewMetrics(), LogicRunner: NewLogicRunner(), + Virtual: NewVirtual(), APIRunner: NewAPIRunner(false), AdminAPIRunner: NewAPIRunner(true), AvailabilityChecker: NewAvailabilityChecker(), diff --git a/ledger-core/configuration/testdata/changed.yml b/ledger-core/configuration/testdata/changed.yml index 246863a616..87e54b5021 100644 --- a/ledger-core/configuration/testdata/changed.yml +++ b/ledger-core/configuration/testdata/changed.yml @@ -13,6 +13,8 @@ service: cachedirectory: network_cache ledger: lightchainlimit: 5 +virtual: + maxrunners: 0 log: level: Debug adapter: zerolog diff --git a/ledger-core/configuration/testdata/default.yml b/ledger-core/configuration/testdata/default.yml index 51bdd6832c..6b25cfcadd 100644 --- a/ledger-core/configuration/testdata/default.yml +++ b/ledger-core/configuration/testdata/default.yml @@ -13,6 +13,8 @@ service: cachedirectory: network_cache ledger: lightchainlimit: 5 +virtual: + maxrunners: 0 log: level: Info adapter: zerolog diff --git a/ledger-core/configuration/virtual.go b/ledger-core/configuration/virtual.go new file mode 100644 index 0000000000..6065215320 --- /dev/null +++ b/ledger-core/configuration/virtual.go @@ -0,0 +1,21 @@ +// Copyright 2020 Insolar Network Ltd. +// All rights reserved. +// This material is licensed under the Insolar License version 1.0, +// available at https://github.com/insolar/assured-ledger/blob/master/LICENSE.md. + +package configuration + +// Virtual holds configuration for virtual. +type Virtual struct { + // MaxRunners limits number of contract executions running in parallel. + // If set to zero or a negative value, limit will be set automatically to + // `( runtime.NumCPU() - 2 ) but not less then 4`. + MaxRunners int +} + +// NewVirtual creates new default virtual configuration. +func NewVirtual() Virtual { + return Virtual{ + MaxRunners: 0, // auto + } +} diff --git a/ledger-core/scripts/deploy/kube/10node/configuration/virtual-config.yaml b/ledger-core/scripts/deploy/kube/10node/configuration/virtual-config.yaml index 386565d80a..c0aaaa70da 100644 --- a/ledger-core/scripts/deploy/kube/10node/configuration/virtual-config.yaml +++ b/ledger-core/scripts/deploy/kube/10node/configuration/virtual-config.yaml @@ -22,6 +22,8 @@ log: outputparams: "" buffersize: 0 llbuffersize: 0 +virtual: + maxrunners: 0 metrics: listenaddress: 0.0.0.0:9091 namespace: placeholder diff --git a/ledger-core/scripts/deploy/kube/15node/configuration/virtual-config.yaml b/ledger-core/scripts/deploy/kube/15node/configuration/virtual-config.yaml index 386565d80a..c0aaaa70da 100644 --- a/ledger-core/scripts/deploy/kube/15node/configuration/virtual-config.yaml +++ b/ledger-core/scripts/deploy/kube/15node/configuration/virtual-config.yaml @@ -22,6 +22,8 @@ log: outputparams: "" buffersize: 0 llbuffersize: 0 +virtual: + maxrunners: 0 metrics: listenaddress: 0.0.0.0:9091 namespace: placeholder diff --git a/ledger-core/scripts/deploy/kube/20node/configuration/virtual-config.yaml b/ledger-core/scripts/deploy/kube/20node/configuration/virtual-config.yaml index 386565d80a..c0aaaa70da 100644 --- a/ledger-core/scripts/deploy/kube/20node/configuration/virtual-config.yaml +++ b/ledger-core/scripts/deploy/kube/20node/configuration/virtual-config.yaml @@ -22,6 +22,8 @@ log: outputparams: "" buffersize: 0 llbuffersize: 0 +virtual: + maxrunners: 0 metrics: listenaddress: 0.0.0.0:9091 namespace: placeholder diff --git a/ledger-core/scripts/deploy/kube/40node/configuration/virtual-config.yaml b/ledger-core/scripts/deploy/kube/40node/configuration/virtual-config.yaml index 386565d80a..c0aaaa70da 100644 --- a/ledger-core/scripts/deploy/kube/40node/configuration/virtual-config.yaml +++ b/ledger-core/scripts/deploy/kube/40node/configuration/virtual-config.yaml @@ -22,6 +22,8 @@ log: outputparams: "" buffersize: 0 llbuffersize: 0 +virtual: + maxrunners: 0 metrics: listenaddress: 0.0.0.0:9091 namespace: placeholder diff --git a/ledger-core/scripts/deploy/kube/5node/configuration/virtual-config.yaml b/ledger-core/scripts/deploy/kube/5node/configuration/virtual-config.yaml index 386565d80a..c0aaaa70da 100644 --- a/ledger-core/scripts/deploy/kube/5node/configuration/virtual-config.yaml +++ b/ledger-core/scripts/deploy/kube/5node/configuration/virtual-config.yaml @@ -22,6 +22,8 @@ log: outputparams: "" buffersize: 0 llbuffersize: 0 +virtual: + maxrunners: 0 metrics: listenaddress: 0.0.0.0:9091 namespace: placeholder diff --git a/ledger-core/scripts/deploy/kube/80node/configuration/virtual-config.yaml b/ledger-core/scripts/deploy/kube/80node/configuration/virtual-config.yaml index 386565d80a..c0aaaa70da 100644 --- a/ledger-core/scripts/deploy/kube/80node/configuration/virtual-config.yaml +++ b/ledger-core/scripts/deploy/kube/80node/configuration/virtual-config.yaml @@ -22,6 +22,8 @@ log: outputparams: "" buffersize: 0 llbuffersize: 0 +virtual: + maxrunners: 0 metrics: listenaddress: 0.0.0.0:9091 namespace: placeholder diff --git a/ledger-core/scripts/deploy/kube/manifests/configuration/virtual-config.yaml b/ledger-core/scripts/deploy/kube/manifests/configuration/virtual-config.yaml index b79c67a529..34f0bfa78a 100644 --- a/ledger-core/scripts/deploy/kube/manifests/configuration/virtual-config.yaml +++ b/ledger-core/scripts/deploy/kube/manifests/configuration/virtual-config.yaml @@ -13,6 +13,8 @@ service: cachedirectory: network_cache ledger: lightchainlimit: 5 +virtual: + maxrunners: 0 log: level: Debug adapter: zerolog @@ -58,4 +60,4 @@ tracer: probabilityrate: 1 samplingrules: {} introspection: - addr: 0.0.0.0:55503 \ No newline at end of file + addr: 0.0.0.0:55503 diff --git a/ledger-core/server/internal/virtual/app_factory.go b/ledger-core/server/internal/virtual/app_factory.go index 6ebdd26d0b..b746932a31 100644 --- a/ledger-core/server/internal/virtual/app_factory.go +++ b/ledger-core/server/internal/virtual/app_factory.go @@ -29,8 +29,9 @@ func AppFactory(ctx context.Context, cfg configuration.Configuration, comps insa virtualDispatcher.Affinity = comps.AffinityHelper virtualDispatcher.AuthenticationService = authentication.NewService(ctx, comps.AffinityHelper) - // TODO: rewrite this after PLAT-432 - if n := runtime.NumCPU() - 2; n > 4 { + if cfg.Virtual.MaxRunners > 0 { + virtualDispatcher.MaxRunners = cfg.Virtual.MaxRunners + } else if n := runtime.NumCPU() - 2; n > 4 { virtualDispatcher.MaxRunners = n } else { virtualDispatcher.MaxRunners = 4 From 5193fba96d745fb887a367bf0d9a7d42521e519b Mon Sep 17 00:00:00 2001 From: Ivan Shibitov Date: Wed, 16 Sep 2020 17:48:52 +0300 Subject: [PATCH 3/3] print max runners --- ledger-core/server/internal/virtual/app_factory.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ledger-core/server/internal/virtual/app_factory.go b/ledger-core/server/internal/virtual/app_factory.go index b746932a31..82851226d1 100644 --- a/ledger-core/server/internal/virtual/app_factory.go +++ b/ledger-core/server/internal/virtual/app_factory.go @@ -7,6 +7,7 @@ package virtual import ( "context" + "fmt" "runtime" "github.com/insolar/assured-ledger/ledger-core/application/testwalletapi" @@ -37,6 +38,8 @@ func AppFactory(ctx context.Context, cfg configuration.Configuration, comps insa virtualDispatcher.MaxRunners = 4 } + fmt.Println("======= MAX RUNNERS: ", virtualDispatcher.MaxRunners) + testAPI := testwalletapi.NewTestWalletServer(cfg.TestWalletAPI, virtualDispatcher, comps.BeatHistory) // ComponentManager can only work with by-pointer objects