Skip to content

Commit

Permalink
Set GC to default (#2063)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakulkar-msft committed Feb 14, 2023
1 parent 3cc9d16 commit 84b9cb4
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"os"
"path"
"runtime"
"runtime/debug"
"time"

"github.com/Azure/azure-pipeline-go/pipeline"
Expand Down Expand Up @@ -78,7 +77,6 @@ func main() {
}

configureGoMaxProcs()
configureGC()

// Perform os specific initialization
maxFileAndSocketHandles, err := ProcessOSSpecificInitialization()
Expand All @@ -90,16 +88,6 @@ func main() {
glcm.Exit(nil, common.EExitCode.Success())
}

// Golang's default behaviour is to GC when new objects = (100% of) total of objects surviving previous GC.
// But our "survivors" add up to many GB, so its hard for users to be confident that we don't have
// a memory leak (since with that default setting new GCs are very rare in our case). So configure them to be more frequent.
func configureGC() {
go func() {
time.Sleep(20 * time.Second) // wait a little, so that our initial pool of buffers can get allocated without heaps of (unnecessary) GC activity
debug.SetGCPercent(20) // activate more aggressive/frequent GC than the default
}()
}

// Ensure we always have more than 1 OS thread running goroutines, since there are issues with having just 1.
// (E.g. version check doesn't happen at login time, if have only one go proc. Not sure why that happens if have only one
// proc. Is presumably due to the high CPU usage we see on login if only 1 CPU, even tho can't see any busy-wait in that code)
Expand Down

0 comments on commit 84b9cb4

Please sign in to comment.