diff --git a/internal/gui/sessions.go b/internal/gui/sessions.go index da337e4b4..242521b19 100644 --- a/internal/gui/sessions.go +++ b/internal/gui/sessions.go @@ -969,13 +969,16 @@ func retightenGC() { afterNextGC(retightenGC) } -// steadyGCStart has the heap grow by half of what it holds before a +// steadyGCStart has the heap grow by a quarter of what it holds before a // collection, or by steadyGCRoom when that is more, not Go's default of // all of it, for the life of the process; a GOGC the user set is kept. // A window resting on ~60 MB live polls /api/state, /api/drift and // /api/providers, ~10 MB thrown away a round, so at the default its -// footprint peaked at 138 MB; under half, 107-108 MB, for ~9% more CPU in -// the polls. Reads under a tight GC still set their tenth while they run. +// footprint peaked at 138 MB and under half at 107-108 MB. On a real +// account's history (~100 MB live) a quarter took the resting footprint +// from 171 to 146 MB and its peak from 200 to 166 MB, with 60 busy poll +// rounds at 5.14s of CPU against 5.12s. Reads under a tight GC still set +// their tenth while they run. func steadyGCStart() { if os.Getenv("GOGC") != "" { return @@ -992,13 +995,13 @@ func steadyGCStart() { } } -// steadyGCPercent is the half steadyGCStart lets the heap grow by. -const steadyGCPercent = 50 +// steadyGCPercent is the quarter steadyGCStart lets the heap grow by. +const steadyGCPercent = 25 -// steadyGCRoom is the least it grows by: half of a small heap is a few -// MB, and a heap under 64 MB grows by 32 MB, never by more than Go's +// steadyGCRoom is the least it grows by: a quarter of a small heap is a +// few MB, and a heap under 64 MB grows by 16 MB, never by more than Go's // default. -const steadyGCRoom = 32 << 20 +const steadyGCRoom = 16 << 20 // steadyPercent is the GOGC steadyGCStart sets on a live heap of live // bytes (0 before the first collection: steadyGCPercent). diff --git a/internal/gui/warm_gc_test.go b/internal/gui/warm_gc_test.go index 082d58362..aa2b13c34 100644 --- a/internal/gui/warm_gc_test.go +++ b/internal/gui/warm_gc_test.go @@ -144,19 +144,20 @@ func TestTightGCRetunesAfterACollection(t *testing.T) { } } -// TestSteadyPercent: between reads the heap grows by half of what it -// holds, by 32 MB when that is more, and never by more than Go's default. +// TestSteadyPercent: between reads the heap grows by a quarter of what it +// holds, by 16 MB when that is more, and never by more than Go's default. func TestSteadyPercent(t *testing.T) { for _, c := range []struct { live int64 want int }{ - {0, 50}, - {60 << 20, 53}, - {64 << 20, 50}, + {0, 25}, + {60 << 20, 26}, + {64 << 20, 25}, + {8 << 20, 100}, {16 << 20, 100}, - {32 << 20, 100}, - {500 << 20, 50}, + {32 << 20, 50}, + {500 << 20, 25}, } { if got := steadyPercent(c.live); got != c.want { t.Errorf("steadyPercent(%d MB) = %d, want %d", c.live>>20, got, c.want)