Skip to content

Commit 027f2e4

Browse files
committed
Remove snapshot of cores and maxprocs
Signed-off-by: Derek Collison <[email protected]>
1 parent f0e1585 commit 027f2e4

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

main.go

-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ func main() {
134134
s.Warnf("Failed to set GOMAXPROCS: %v", err)
135135
} else {
136136
defer undo()
137-
// Reset these from the snapshots from init for monitor.go
138-
server.SnapshotMonitorInfo()
139137
}
140138

141139
s.WaitForShutdown()

server/events.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"math/rand"
2424
"net/http"
25+
"runtime"
2526
"strconv"
2627
"strings"
2728
"sync"
@@ -603,7 +604,7 @@ func (s *Server) updateServerUsage(v *ServerStats) {
603604
defer s.mu.Lock()
604605
var vss int64
605606
pse.ProcUsage(&v.CPU, &v.Mem, &vss)
606-
v.Cores = numCores
607+
v.Cores = runtime.NumCPU()
607608
}
608609

609610
// Generate a route stat for our statz update.

server/monitor.go

+2-15
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@ import (
3636
"github.com/nats-io/nats-server/v2/server/pse"
3737
)
3838

39-
// Snapshot this
40-
var numCores int
41-
var maxProcs int
42-
43-
func SnapshotMonitorInfo() {
44-
numCores = runtime.NumCPU()
45-
maxProcs = runtime.GOMAXPROCS(0)
46-
}
47-
48-
func init() {
49-
SnapshotMonitorInfo()
50-
}
51-
5239
// Connz represents detailed information on current client connections.
5340
type Connz struct {
5441
ID string `json:"server_id"`
@@ -1528,8 +1515,8 @@ func (s *Server) createVarz(pcpu float64, rss int64) *Varz {
15281515
},
15291516
Start: s.start,
15301517
MaxSubs: opts.MaxSubs,
1531-
Cores: numCores,
1532-
MaxProcs: maxProcs,
1518+
Cores: runtime.NumCPU(),
1519+
MaxProcs: runtime.GOMAXPROCS(0),
15331520
Tags: opts.Tags,
15341521
TrustedOperatorsJwt: opts.operatorJWT,
15351522
TrustedOperatorsClaim: opts.TrustedOperators,

0 commit comments

Comments
 (0)