Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gogctuner: fix unstable test in the TestTuner #39101

Merged
merged 8 commits into from
Nov 14, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions util/gctuner/tuner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var testHeap []byte

func TestTuner(t *testing.T) {
EnableGOGCTuner.Store(true)
memLimit := uint64(100 * 1024 * 1024) //100 MB
memLimit := uint64(1000 * 1024 * 1024) //1000 MB
threshold := memLimit / 2
tn := newTuner(threshold)
require.Equal(t, threshold, tn.threshold.Load())
Expand All @@ -44,17 +44,17 @@ func TestTuner(t *testing.T) {
testHeap = make([]byte, threshold/4)
for i := 0; i < 100; i++ {
runtime.GC()
require.GreaterOrEqual(t, tn.getGCPercent(), uint32(100))
require.LessOrEqual(t, tn.getGCPercent(), uint32(500))
require.GreaterOrEqual(t, tn.getGCPercent(), MaxGCPercent/2)
require.LessOrEqual(t, tn.getGCPercent(), MaxGCPercent)
}

// 1/2 threshold
testHeap = make([]byte, threshold/2)
runtime.GC()
for i := 0; i < 100; i++ {
runtime.GC()
require.GreaterOrEqual(t, tn.getGCPercent(), uint32(50))
require.LessOrEqual(t, tn.getGCPercent(), uint32(100))
require.GreaterOrEqual(t, tn.getGCPercent(), MinGCPercent)
require.LessOrEqual(t, tn.getGCPercent(), MaxGCPercent/2)
}

// 3/4 threshold
Expand Down