Skip to content
Snippets Groups Projects
Unverified Commit 9696c899 authored by Angelo Capossele's avatar Angelo Capossele Committed by GitHub
Browse files

Change worker count to use GOMAXPROCS (#549)

* :zap: Reduce solidifier worker pool capacity

* :recycle: Use GOMAXPROCS

* :zap: Change worker count to use GOMAXPROCS

* :zap: Set DefaultRequestWorkerCount to GOMAXPROCS

* :rotating_light: Fix linter warnings

* :arrow_up: Update hive.go
parent 68fdcf49
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ require (
github.com/gobuffalo/packr/v2 v2.8.0
github.com/golang/protobuf v1.4.2
github.com/gorilla/websocket v1.4.2
github.com/iotaledger/hive.go v0.0.0-20200622211038-2db5f8e0532d
github.com/iotaledger/hive.go v0.0.0-20200625105326-310ea88f1337
github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/gommon v0.3.0
github.com/magiconair/properties v1.8.1
......
......@@ -231,6 +231,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/iotaledger/hive.go v0.0.0-20200622211038-2db5f8e0532d h1:cyxepG077Tg1wNfbhkRhXMK9WwaN4N0dDW7T8+d3oHA=
github.com/iotaledger/hive.go v0.0.0-20200622211038-2db5f8e0532d/go.mod h1:42UvBc41QBsuM7z1P1fABMonTJb7kGqkzshRebClQvA=
github.com/iotaledger/hive.go v0.0.0-20200625105326-310ea88f1337 h1:F6PzAkymPcKr1vJVK3/80wiVovjkL47c9FMjUOesXGA=
github.com/iotaledger/hive.go v0.0.0-20200625105326-310ea88f1337/go.mod h1:42UvBc41QBsuM7z1P1fABMonTJb7kGqkzshRebClQvA=
github.com/iotaledger/iota.go v1.0.0-beta.15 h1:HI8PqerEnO1CCIqmXHJ6zh1IaSFXU+S0qlUAEKshho8=
github.com/iotaledger/iota.go v1.0.0-beta.15/go.mod h1:Rn6v5hLAn8YBaJlRu1ZQdPAgKlshJR1PTeLQaft2778=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
......
......@@ -5,6 +5,6 @@ import (
)
const (
DefaultRequestWorkerCount = 1024
DefaultRetryInterval = 10 * time.Second
// DefaultRetryInterval defines the Default Retry Interval of the message requester.
DefaultRetryInterval = 10 * time.Second
)
package messagerequester
import (
"runtime"
"sync"
"time"
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
"github.com/iotaledger/hive.go/async"
"github.com/iotaledger/hive.go/events"
)
"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
var (
// DefaultRequestWorkerCount defines the Default Request Worker Count of the message reqeuster.
DefaultRequestWorkerCount = runtime.GOMAXPROCS(0)
)
// MessageRequester takes care of requesting messages.
......
......@@ -2,6 +2,7 @@ package tangle
import (
"container/list"
"runtime"
"time"
"github.com/iotaledger/hive.go/kvstore"
......@@ -65,7 +66,7 @@ func New(store kvstore.KVStore) (result *Tangle) {
Events: *newEvents(),
}
result.solidifierWorkerPool.Tune(1024)
result.solidifierWorkerPool.Tune(runtime.GOMAXPROCS(0))
return
}
......
......@@ -19,7 +19,7 @@ import (
func BenchmarkVerifyDataMessages(b *testing.B) {
var pool async.WorkerPool
pool.Tune(runtime.NumCPU() * 2)
pool.Tune(runtime.GOMAXPROCS(0))
factory := messagefactory.New(mapdb.NewMapDB(), []byte(messagelayer.DBSequenceNumber), identity.GenerateLocalIdentity(), messagefactory.TipSelectorFunc(func() (message.Id, message.Id) { return message.EmptyId, message.EmptyId }))
......
......@@ -78,7 +78,7 @@ func (nl nodes) AddEdge(a, b nodeID) {
// Diameter is the maximum length of a shortest path in the network
func (nl nodes) Diameter() int {
cpus := runtime.NumCPU()
cpus := runtime.GOMAXPROCS(0)
numNodes := len(nl)
nodesPerCPU := numNodes / cpus
......
......@@ -37,7 +37,7 @@ func createMetricHeartbeat() *packet.MetricHeartbeat {
OwnID: nodeID,
OS: runtime.GOOS,
Arch: runtime.GOARCH,
NumCPU: runtime.NumCPU(),
NumCPU: runtime.GOMAXPROCS(0),
// TODO: replace this with only the CPU usage of the GoShimmer process.
CPUUsage: func() (p float64) {
percent, err := cpu.Percent(time.Second, false)
......
......@@ -27,7 +27,7 @@ var (
fpcLiveFeedWorkerQueueSize = 300
fpcLiveFeedWorkerPool *workerpool.WorkerPool
fpcStoreFinalizedWorkerCount = runtime.NumCPU()
fpcStoreFinalizedWorkerCount = runtime.GOMAXPROCS(0)
fpcStoreFinalizedWorkerQueueSize = 300
fpcStoreFinalizedWorkerPool *workerpool.WorkerPool
......
......@@ -19,7 +19,7 @@ func testMetricHeartbeat() *MetricHeartbeat {
OwnID: nodeID[:],
OS: runtime.GOOS,
Arch: runtime.GOARCH,
NumCPU: runtime.NumCPU(),
NumCPU: runtime.GOMAXPROCS(0),
CPUUsage: func() (p float64) {
percent, err := cpu.Percent(time.Second, false)
if err == nil {
......
......@@ -82,7 +82,7 @@ func configure(plugin *node.Plugin) {
sendLogMsg(task.Param(0).(logger.Level), task.Param(1).(string), task.Param(2).(string))
task.Return(nil)
}, workerpool.WorkerCount(runtime.NumCPU()), workerpool.QueueSize(1000))
}, workerpool.WorkerCount(runtime.GOMAXPROCS(0)), workerpool.QueueSize(1000))
}
func run(plugin *node.Plugin) {
......
......@@ -10,7 +10,7 @@ require (
github.com/docker/go-units v0.4.0 // indirect
github.com/drand/drand v0.9.1
github.com/iotaledger/goshimmer v0.1.3
github.com/iotaledger/hive.go v0.0.0-20200622211038-2db5f8e0532d
github.com/iotaledger/hive.go v0.0.0-20200625105326-310ea88f1337
github.com/mr-tron/base58 v1.2.0
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/stretchr/testify v1.6.1
......
......@@ -262,6 +262,8 @@ github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/iotaledger/hive.go v0.0.0-20200622211038-2db5f8e0532d h1:cyxepG077Tg1wNfbhkRhXMK9WwaN4N0dDW7T8+d3oHA=
github.com/iotaledger/hive.go v0.0.0-20200622211038-2db5f8e0532d/go.mod h1:42UvBc41QBsuM7z1P1fABMonTJb7kGqkzshRebClQvA=
github.com/iotaledger/hive.go v0.0.0-20200625105326-310ea88f1337 h1:F6PzAkymPcKr1vJVK3/80wiVovjkL47c9FMjUOesXGA=
github.com/iotaledger/hive.go v0.0.0-20200625105326-310ea88f1337/go.mod h1:42UvBc41QBsuM7z1P1fABMonTJb7kGqkzshRebClQvA=
github.com/iotaledger/iota.go v1.0.0-beta.15/go.mod h1:Rn6v5hLAn8YBaJlRu1ZQdPAgKlshJR1PTeLQaft2778=
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment