Skip to content

Commit

Permalink
[aggregator] make sure worker pool is at least 1 (#1881)
Browse files Browse the repository at this point in the history
It is possible to configure the aggregator so that the worker pool size ends up being 0. In that case, the aggregator does not perform any work, but also do not return any error messages making it very hard to understand why nothing is happening
  • Loading branch information
alxric authored and robskillington committed Sep 15, 2019
1 parent f0be2c3 commit 0dea471
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cmd/services/m3aggregator/config/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package config
import (
"errors"
"fmt"
"math"
"net"
"os"
"runtime"
Expand Down Expand Up @@ -689,7 +690,12 @@ func (c flushManagerConfiguration) NewFlushManagerOptions(
opts = opts.SetMaxJitterFn(maxJitterFn)
}
if c.NumWorkersPerCPU != 0 {
workerPoolSize := int(float64(runtime.NumCPU()) * c.NumWorkersPerCPU)
runtimeCPU := float64(runtime.NumCPU())
numWorkers := c.NumWorkersPerCPU * runtimeCPU
workerPoolSize := int(math.Ceil(numWorkers))
if workerPoolSize < 1 {
workerPoolSize = 1
}
workerPool := sync.NewWorkerPool(workerPoolSize)
workerPool.Init()
opts = opts.SetWorkerPool(workerPool)
Expand Down

0 comments on commit 0dea471

Please sign in to comment.