Skip to content

Commit

Permalink
follow-up
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Dec 18, 2024
1 parent e8662f3 commit 576ce3c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions fs/throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ func ThrottlePct() (int, int64, float64) {
var (
load = sys.MaxLoad()
util = GetMaxUtil()
ncpu = sys.NumCPU()
highLoad = sys.HighLoadWM(ncpu)
highLoad = sys.HighLoadWM()
)
if load >= float64(highLoad) {
return 100, util, load
Expand Down
3 changes: 1 addition & 2 deletions memsys/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ func (r *MMSA) freeMemToOS(mingc int64, p int, forces ...bool) {

var (
load = sys.MaxLoad()
ncpu = sys.NumCPU()
highLoad = sys.HighLoadWM(ncpu)
highLoad = sys.HighLoadWM()
)
if !force {
// too busy and not too "pressured"
Expand Down
7 changes: 5 additions & 2 deletions sys/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// used with MaxLoad()
// floating point; compare with HighLoadWM() below
// floating point; HighLoad < HighLoadWM() < ExtremeLoad
const (
ExtremeLoad = 92
HighLoad = 82
Expand Down Expand Up @@ -61,7 +61,10 @@ func GoEnvMaxprocs() {

// "high-load watermark", to maybe throttle when MaxLoad() is above
// see also (ExtremeLoad, HighLoad) defaults
func HighLoadWM(ncpu int) int { return max(ncpu-ncpu>>3, 1) }
func HighLoadWM() int {
ncpu := NumCPU()
return max(ncpu-ncpu>>3, 1)
}

// return max(1 minute, 5 minute) load average
func MaxLoad() (load float64) {
Expand Down

0 comments on commit 576ce3c

Please sign in to comment.