From ba8e5828b84b7884145fa83ad77bd3d2e924bd26 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey Date: Fri, 17 Nov 2023 19:59:03 -0800 Subject: [PATCH] 4min pause before gc --- src/corso.go | 3 ++- src/internal/operations/backup.go | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corso.go b/src/corso.go index 347e78066..a80f4561b 100644 --- a/src/corso.go +++ b/src/corso.go @@ -38,7 +38,8 @@ func main() { // if mem > 3GB and we havent captured a profile this min, capture it // or if its been 2 mins since last profile, capture it t := time.Now().Truncate(time.Minute) - if (m.HeapAlloc > uint64(3*1024*1024*1024) && perMinuteMap[t] == 0) || time.Since(timeSinceRefresh) > 2*time.Minute { + //if (m.HeapAlloc > uint64(3*1024*1024*1024) && perMinuteMap[t] == 0) || time.Since(timeSinceRefresh) > 2*time.Minute { + if time.Since(timeSinceRefresh) > 2*time.Minute { filename := "mem." + strconv.Itoa(profileCounter) + ".pprof" f, _ := os.Create(filename) diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index 908680d62..0422d4347 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -463,6 +463,10 @@ func (op *BackupOperation) do( return nil, clues.Wrap(err, "producing backup data collections") } + // Sleep for 4 mins to let the memory usage settle down so that we have a better + // picture. Also allows pprof to run twice during this time. + time.Sleep(4 * time.Minute) + sum := 0 numItems := 0 mapSum := 0 @@ -488,10 +492,6 @@ func (op *BackupOperation) do( // print total sum logger.Ctx(ctx).Debugf("itemSum %d, map sum %d, total items %d, mem used per item %f mem per item in map %f \n", sum, mapSum, numItems, float64(sum)/float64(numItems), float64(mapSum)/float64(numItems)) - - // Sleep for 4 mins to let the memory usage settle down so that we have a better - // picture. Also allows pprof to run twice during this time. - time.Sleep(3 * time.Minute) } return nil, clues.New("failed")