nomad: use CPU count to determine pool size
This commit is contained in:
parent
1076fb44d9
commit
3746bf7cd3
|
@ -101,8 +101,9 @@ func (s *Server) establishLeadership(stopCh chan struct{}) error {
|
||||||
// Disable workers to free half the cores for use in the plan queue and
|
// Disable workers to free half the cores for use in the plan queue and
|
||||||
// evaluation broker
|
// evaluation broker
|
||||||
if numWorkers := len(s.workers); numWorkers > 1 {
|
if numWorkers := len(s.workers); numWorkers > 1 {
|
||||||
// Disabling half the workers frees half the CPUs.
|
// Disabling 3/4 of the workers frees CPU for raft and the
|
||||||
for i := 0; i < numWorkers/2; i++ {
|
// plan applier which uses 1/2 the cores.
|
||||||
|
for i := 0; i < (3 * numWorkers / 4); i++ {
|
||||||
s.workers[i].SetPause(true)
|
s.workers[i].SetPause(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package nomad
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/armon/go-metrics"
|
"github.com/armon/go-metrics"
|
||||||
|
@ -42,7 +43,13 @@ func (s *Server) planApply() {
|
||||||
// holds an optimistic state which includes that plan application.
|
// holds an optimistic state which includes that plan application.
|
||||||
var waitCh chan struct{}
|
var waitCh chan struct{}
|
||||||
var snap *state.StateSnapshot
|
var snap *state.StateSnapshot
|
||||||
pool := NewEvaluatePool(workerPoolSize, workerPoolBufferSize)
|
|
||||||
|
// Setup a worker pool with half the cores, with at least 1
|
||||||
|
poolSize := runtime.NumCPU() / 2
|
||||||
|
if poolSize == 0 {
|
||||||
|
poolSize = 1
|
||||||
|
}
|
||||||
|
pool := NewEvaluatePool(poolSize, workerPoolBufferSize)
|
||||||
defer pool.Shutdown()
|
defer pool.Shutdown()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -6,9 +6,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// workerPoolSize is the size of the worker pool
|
|
||||||
workerPoolSize = 2
|
|
||||||
|
|
||||||
// workerPoolBufferSize is the size of the buffers used to push
|
// workerPoolBufferSize is the size of the buffers used to push
|
||||||
// request to the workers and to collect the responses. It should
|
// request to the workers and to collect the responses. It should
|
||||||
// be large enough just to keep things busy
|
// be large enough just to keep things busy
|
||||||
|
|
|
@ -10,6 +10,11 @@ import (
|
||||||
"github.com/hashicorp/raft"
|
"github.com/hashicorp/raft"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// workerPoolSize is the size of the worker pool
|
||||||
|
workerPoolSize = 2
|
||||||
|
)
|
||||||
|
|
||||||
// planWaitFuture is used to wait for the Raft future to complete
|
// planWaitFuture is used to wait for the Raft future to complete
|
||||||
func planWaitFuture(future raft.ApplyFuture) (uint64, error) {
|
func planWaitFuture(future raft.ApplyFuture) (uint64, error) {
|
||||||
if err := future.Error(); err != nil {
|
if err := future.Error(); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue