Correct threads equals cpu

This commit is contained in:
tidwall 2018-11-10 17:14:34 -07:00
parent d065b979da
commit 7cc9154eb8
1 changed files with 7 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/klauspost/cpuid"
"github.com/tidwall/buntdb" "github.com/tidwall/buntdb"
"github.com/tidwall/evio" "github.com/tidwall/evio"
"github.com/tidwall/geojson" "github.com/tidwall/geojson"
@ -294,7 +295,12 @@ func (server *Server) isProtected() bool {
func (server *Server) evioServe() error { func (server *Server) evioServe() error {
var events evio.Events var events evio.Events
if core.NumThreads == 0 { if core.NumThreads == 0 {
events.NumLoops = -1 cores := cpuid.CPU.PhysicalCores
if cores == 0 {
events.NumLoops = -1
} else {
events.NumLoops = cores
}
} else { } else {
events.NumLoops = core.NumThreads events.NumLoops = core.NumThreads
} }