Skip to content

Commit

Permalink
Set GC to default
Browse files Browse the repository at this point in the history
  • Loading branch information
nakulkar-msft committed Feb 9, 2023
1 parent 6c1d508 commit e434417
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func main() {
}

configureGoMaxProcs()
configureGC()

// Perform os specific initialization
maxFileAndSocketHandles, err := ProcessOSSpecificInitialization()
Expand All @@ -90,16 +89,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 e434417

Please sign in to comment.