mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: rename gcpercent, readgogc, and heapminimum to match Go style
Generated with: rf 'mv gcpercent gcPercent' rf 'mv readgogc readGOGC' rf 'mv heapminimum heapMinimum' After this, comments referencing these symbols were updated via a simple sed command. For #44167. Change-Id: I6bb01597c2130686c01f967d0f106b06860ad2db Reviewed-on: https://go-review.googlesource.com/c/go/+/306597 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
f5f7647107
commit
693859542e
2 changed files with 31 additions and 31 deletions
|
|
@ -161,13 +161,13 @@ func gcinit() {
|
||||||
memstats.triggerRatio = 7 / 8.0
|
memstats.triggerRatio = 7 / 8.0
|
||||||
|
|
||||||
// Fake a heap_marked value so it looks like a trigger at
|
// Fake a heap_marked value so it looks like a trigger at
|
||||||
// heapminimum is the appropriate growth from heap_marked.
|
// heapMinimum is the appropriate growth from heap_marked.
|
||||||
// This will go into computing the initial GC goal.
|
// This will go into computing the initial GC goal.
|
||||||
memstats.heap_marked = uint64(float64(heapminimum) / (1 + memstats.triggerRatio))
|
memstats.heap_marked = uint64(float64(heapMinimum) / (1 + memstats.triggerRatio))
|
||||||
|
|
||||||
// Set gcpercent from the environment. This will also compute
|
// Set gcPercent from the environment. This will also compute
|
||||||
// and set the GC trigger and goal.
|
// and set the GC trigger and goal.
|
||||||
_ = setGCPercent(readgogc())
|
_ = setGCPercent(readGOGC())
|
||||||
|
|
||||||
work.startSema = 1
|
work.startSema = 1
|
||||||
work.markDoneSema = 1
|
work.markDoneSema = 1
|
||||||
|
|
@ -557,7 +557,7 @@ func (t gcTrigger) test() bool {
|
||||||
// own write.
|
// own write.
|
||||||
return memstats.heap_live >= memstats.gc_trigger
|
return memstats.heap_live >= memstats.gc_trigger
|
||||||
case gcTriggerTime:
|
case gcTriggerTime:
|
||||||
if gcpercent < 0 {
|
if gcPercent < 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
lastgc := int64(atomic.Load64(&memstats.last_gc_nanotime))
|
lastgc := int64(atomic.Load64(&memstats.last_gc_nanotime))
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,12 @@ const (
|
||||||
// assist by pre-paying for this many bytes of future allocations.
|
// assist by pre-paying for this many bytes of future allocations.
|
||||||
gcOverAssistWork = 64 << 10
|
gcOverAssistWork = 64 << 10
|
||||||
|
|
||||||
// defaultHeapMinimum is the value of heapminimum for GOGC==100.
|
// defaultHeapMinimum is the value of heapMinimum for GOGC==100.
|
||||||
defaultHeapMinimum = 4 << 20
|
defaultHeapMinimum = 4 << 20
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// heapminimum is the minimum heap size at which to trigger GC.
|
// heapMinimum is the minimum heap size at which to trigger GC.
|
||||||
// For small heaps, this overrides the usual GOGC*live set rule.
|
// For small heaps, this overrides the usual GOGC*live set rule.
|
||||||
//
|
//
|
||||||
// When there is a very small live set but a lot of allocation, simply
|
// When there is a very small live set but a lot of allocation, simply
|
||||||
|
|
@ -59,13 +59,13 @@ var (
|
||||||
// per-GC overhead while keeping the heap reasonably small.
|
// per-GC overhead while keeping the heap reasonably small.
|
||||||
//
|
//
|
||||||
// During initialization this is set to 4MB*GOGC/100. In the case of
|
// During initialization this is set to 4MB*GOGC/100. In the case of
|
||||||
// GOGC==0, this will set heapminimum to 0, resulting in constant
|
// GOGC==0, this will set heapMinimum to 0, resulting in constant
|
||||||
// collection even when the heap size is small, which is useful for
|
// collection even when the heap size is small, which is useful for
|
||||||
// debugging.
|
// debugging.
|
||||||
heapminimum uint64 = defaultHeapMinimum
|
heapMinimum uint64 = defaultHeapMinimum
|
||||||
|
|
||||||
// Initialized from $GOGC. GOGC=off means no GC.
|
// Initialized from $GOGC. GOGC=off means no GC.
|
||||||
gcpercent int32
|
gcPercent int32
|
||||||
)
|
)
|
||||||
|
|
||||||
// gcController implements the GC pacing controller that determines
|
// gcController implements the GC pacing controller that determines
|
||||||
|
|
@ -266,11 +266,11 @@ func (c *gcControllerState) startCycle() {
|
||||||
// is when assists are enabled and the necessary statistics are
|
// is when assists are enabled and the necessary statistics are
|
||||||
// available).
|
// available).
|
||||||
func (c *gcControllerState) revise() {
|
func (c *gcControllerState) revise() {
|
||||||
gcpercent := gcpercent
|
gcPercent := gcPercent
|
||||||
if gcpercent < 0 {
|
if gcPercent < 0 {
|
||||||
// If GC is disabled but we're running a forced GC,
|
// If GC is disabled but we're running a forced GC,
|
||||||
// act like GOGC is huge for the below calculations.
|
// act like GOGC is huge for the below calculations.
|
||||||
gcpercent = 100000
|
gcPercent = 100000
|
||||||
}
|
}
|
||||||
live := atomic.Load64(&memstats.heap_live)
|
live := atomic.Load64(&memstats.heap_live)
|
||||||
scan := atomic.Load64(&memstats.heap_scan)
|
scan := atomic.Load64(&memstats.heap_scan)
|
||||||
|
|
@ -289,7 +289,7 @@ func (c *gcControllerState) revise() {
|
||||||
//
|
//
|
||||||
// (This is a float calculation to avoid overflowing on
|
// (This is a float calculation to avoid overflowing on
|
||||||
// 100*heap_scan.)
|
// 100*heap_scan.)
|
||||||
scanWorkExpected := int64(float64(scan) * 100 / float64(100+gcpercent))
|
scanWorkExpected := int64(float64(scan) * 100 / float64(100+gcPercent))
|
||||||
|
|
||||||
if int64(live) > heapGoal || work > scanWorkExpected {
|
if int64(live) > heapGoal || work > scanWorkExpected {
|
||||||
// We're past the soft goal, or we've already done more scan
|
// We're past the soft goal, or we've already done more scan
|
||||||
|
|
@ -542,7 +542,7 @@ func (c *gcControllerState) findRunnableGCWorker(_p_ *p) *g {
|
||||||
// This can be called any time. If GC is the in the middle of a
|
// This can be called any time. If GC is the in the middle of a
|
||||||
// concurrent phase, it will adjust the pacing of that phase.
|
// concurrent phase, it will adjust the pacing of that phase.
|
||||||
//
|
//
|
||||||
// This depends on gcpercent, memstats.heap_marked, and
|
// This depends on gcPercent, memstats.heap_marked, and
|
||||||
// memstats.heap_live. These must be up to date.
|
// memstats.heap_live. These must be up to date.
|
||||||
//
|
//
|
||||||
// mheap_.lock must be held or the world must be stopped.
|
// mheap_.lock must be held or the world must be stopped.
|
||||||
|
|
@ -553,13 +553,13 @@ func gcSetTriggerRatio(triggerRatio float64) {
|
||||||
// has grown by GOGC/100 over the heap marked by the last
|
// has grown by GOGC/100 over the heap marked by the last
|
||||||
// cycle.
|
// cycle.
|
||||||
goal := ^uint64(0)
|
goal := ^uint64(0)
|
||||||
if gcpercent >= 0 {
|
if gcPercent >= 0 {
|
||||||
goal = memstats.heap_marked + memstats.heap_marked*uint64(gcpercent)/100
|
goal = memstats.heap_marked + memstats.heap_marked*uint64(gcPercent)/100
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the trigger ratio, capped to reasonable bounds.
|
// Set the trigger ratio, capped to reasonable bounds.
|
||||||
if gcpercent >= 0 {
|
if gcPercent >= 0 {
|
||||||
scalingFactor := float64(gcpercent) / 100
|
scalingFactor := float64(gcPercent) / 100
|
||||||
// Ensure there's always a little margin so that the
|
// Ensure there's always a little margin so that the
|
||||||
// mutator assist ratio isn't infinity.
|
// mutator assist ratio isn't infinity.
|
||||||
maxTriggerRatio := 0.95 * scalingFactor
|
maxTriggerRatio := 0.95 * scalingFactor
|
||||||
|
|
@ -584,9 +584,9 @@ func gcSetTriggerRatio(triggerRatio float64) {
|
||||||
triggerRatio = minTriggerRatio
|
triggerRatio = minTriggerRatio
|
||||||
}
|
}
|
||||||
} else if triggerRatio < 0 {
|
} else if triggerRatio < 0 {
|
||||||
// gcpercent < 0, so just make sure we're not getting a negative
|
// gcPercent < 0, so just make sure we're not getting a negative
|
||||||
// triggerRatio. This case isn't expected to happen in practice,
|
// triggerRatio. This case isn't expected to happen in practice,
|
||||||
// and doesn't really matter because if gcpercent < 0 then we won't
|
// and doesn't really matter because if gcPercent < 0 then we won't
|
||||||
// ever consume triggerRatio further on in this function, but let's
|
// ever consume triggerRatio further on in this function, but let's
|
||||||
// just be defensive here; the triggerRatio being negative is almost
|
// just be defensive here; the triggerRatio being negative is almost
|
||||||
// certainly undesirable.
|
// certainly undesirable.
|
||||||
|
|
@ -599,10 +599,10 @@ func gcSetTriggerRatio(triggerRatio float64) {
|
||||||
// We trigger the next GC cycle when the allocated heap has
|
// We trigger the next GC cycle when the allocated heap has
|
||||||
// grown by the trigger ratio over the marked heap size.
|
// grown by the trigger ratio over the marked heap size.
|
||||||
trigger := ^uint64(0)
|
trigger := ^uint64(0)
|
||||||
if gcpercent >= 0 {
|
if gcPercent >= 0 {
|
||||||
trigger = uint64(float64(memstats.heap_marked) * (1 + triggerRatio))
|
trigger = uint64(float64(memstats.heap_marked) * (1 + triggerRatio))
|
||||||
// Don't trigger below the minimum heap size.
|
// Don't trigger below the minimum heap size.
|
||||||
minTrigger := heapminimum
|
minTrigger := heapMinimum
|
||||||
if !isSweepDone() {
|
if !isSweepDone() {
|
||||||
// Concurrent sweep happens in the heap growth
|
// Concurrent sweep happens in the heap growth
|
||||||
// from heap_live to gc_trigger, so ensure
|
// from heap_live to gc_trigger, so ensure
|
||||||
|
|
@ -682,9 +682,9 @@ func gcSetTriggerRatio(triggerRatio float64) {
|
||||||
// ratio (GOGC/100) based on heap_marked from the previous GC and
|
// ratio (GOGC/100) based on heap_marked from the previous GC and
|
||||||
// next_gc for the current GC.
|
// next_gc for the current GC.
|
||||||
//
|
//
|
||||||
// This may differ from gcpercent/100 because of various upper and
|
// This may differ from gcPercent/100 because of various upper and
|
||||||
// lower bounds on gcpercent. For example, if the heap is smaller than
|
// lower bounds on gcPercent. For example, if the heap is smaller than
|
||||||
// heapminimum, this can be higher than gcpercent/100.
|
// heapMinimum, this can be higher than gcPercent/100.
|
||||||
//
|
//
|
||||||
// mheap_.lock must be held or the world must be stopped.
|
// mheap_.lock must be held or the world must be stopped.
|
||||||
func gcEffectiveGrowthRatio() float64 {
|
func gcEffectiveGrowthRatio() float64 {
|
||||||
|
|
@ -703,13 +703,13 @@ func setGCPercent(in int32) (out int32) {
|
||||||
// Run on the system stack since we grab the heap lock.
|
// Run on the system stack since we grab the heap lock.
|
||||||
systemstack(func() {
|
systemstack(func() {
|
||||||
lock(&mheap_.lock)
|
lock(&mheap_.lock)
|
||||||
out = gcpercent
|
out = gcPercent
|
||||||
if in < 0 {
|
if in < 0 {
|
||||||
in = -1
|
in = -1
|
||||||
}
|
}
|
||||||
gcpercent = in
|
gcPercent = in
|
||||||
heapminimum = defaultHeapMinimum * uint64(gcpercent) / 100
|
heapMinimum = defaultHeapMinimum * uint64(gcPercent) / 100
|
||||||
// Update pacing in response to gcpercent change.
|
// Update pacing in response to gcPercent change.
|
||||||
gcSetTriggerRatio(memstats.triggerRatio)
|
gcSetTriggerRatio(memstats.triggerRatio)
|
||||||
unlock(&mheap_.lock)
|
unlock(&mheap_.lock)
|
||||||
})
|
})
|
||||||
|
|
@ -723,7 +723,7 @@ func setGCPercent(in int32) (out int32) {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func readgogc() int32 {
|
func readGOGC() int32 {
|
||||||
p := gogetenv("GOGC")
|
p := gogetenv("GOGC")
|
||||||
if p == "off" {
|
if p == "off" {
|
||||||
return -1
|
return -1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue