1
0
mirror of https://github.com/golang/go synced 2024-11-12 03:50:21 -07:00

runtime: pace the scavenger according to 1% of overall CPU time

Currently the scavenger is paced to 1% of 1 CPU because it had
scalability problems. As of the last few CLs, that should be largely
resolved. This change resolves the TODO and paces the scavenger
according to 1% of overall CPU time.

This change is made separately to allow it to be more easily rolled
back.

Change-Id: I1ab4de24ba41c564960701634a128a813c55ece9
Reviewed-on: https://go-review.googlesource.com/c/go/+/358675
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Michael Anthony Knyszek 2021-10-25 21:49:05 +00:00 committed by Michael Knyszek
parent e48e4b4cbb
commit 6f32d2050d

View File

@ -272,13 +272,7 @@ func bgscavenge(c chan int) {
// idealFraction is the ideal % of overall application CPU time that we
// spend scavenging.
//
// TODO(mknyszek): Currently this is percent of one CPU (hence the division
// by gomaxprocs), but ideally this should be 1% of overall CPU time.
// Given a scalable memory allocator, it makes sense that the scavenger
// should scale with it; if you're allocating more frequently, then presumably
// you're also generating more work from the scavenger.
idealFraction := float64(scavengePercent) / 100.0 / float64(gomaxprocs)
idealFraction := float64(scavengePercent) / 100.0
// Input: fraction of CPU time used.
// Setpoint: idealFraction.