From 7cc9154eb8b173adcf1a7c5fa0d0192150bd36a1 Mon Sep 17 00:00:00 2001 From: tidwall Date: Sat, 10 Nov 2018 17:14:34 -0700 Subject: [PATCH] Correct threads equals cpu --- internal/server/server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/server/server.go b/internal/server/server.go index 3ed61699..520116c5 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -22,6 +22,7 @@ import ( "sync/atomic" "time" + "github.com/klauspost/cpuid" "github.com/tidwall/buntdb" "github.com/tidwall/evio" "github.com/tidwall/geojson" @@ -294,7 +295,12 @@ func (server *Server) isProtected() bool { func (server *Server) evioServe() error { var events evio.Events if core.NumThreads == 0 { - events.NumLoops = -1 + cores := cpuid.CPU.PhysicalCores + if cores == 0 { + events.NumLoops = -1 + } else { + events.NumLoops = cores + } } else { events.NumLoops = core.NumThreads }