More aggressive GC.
authorTom Clegg <tom@curii.com>
Wed, 29 Dec 2021 18:40:15 +0000 (13:40 -0500)
committerTom Clegg <tom@curii.com>
Wed, 29 Dec 2021 18:40:15 +0000 (13:40 -0500)
refs #18438

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

cmd.go
slicenumpy.go

diff --git a/cmd.go b/cmd.go
index eeeb6fb740f5d2d334534043e4aff6788ef2ab3d..b10b1caa3fc4a65531de88e6818013a628380494 100644 (file)
--- a/cmd.go
+++ b/cmd.go
@@ -10,6 +10,7 @@ import (
        "io/ioutil"
        "os"
        "os/exec"
+       "runtime/debug"
        "strings"
 
        "git.arvados.org/arvados.git/lib/cmd"
@@ -46,6 +47,12 @@ var (
        })
 )
 
+func init() {
+       if os.Getenv("GOGC") == "" {
+               debug.SetGCPercent(30)
+       }
+}
+
 func Main() {
        if !isatty.IsTerminal(os.Stderr.Fd()) {
                logrus.StandardLogger().Formatter = &logrus.TextFormatter{DisableTimestamp: true}
index 3af4aa04ef51cbc6a0dbefd5fce8c5863d7d3a00..670836a4210c3871cbaa49bf3f18b4d6ee6e516f 100644 (file)
@@ -17,6 +17,7 @@ import (
        "os"
        "regexp"
        "runtime"
+       "runtime/debug"
        "sort"
        "strconv"
        "strings"
@@ -526,6 +527,8 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
                                }
                        }
                        seq = nil
+                       cgs = nil
+                       debug.FreeOSMemory()
                        throttleNumpyMem.Release()
 
                        if *mergeOutput || *hgvsSingle {
@@ -538,6 +541,7 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
                                if err != nil {
                                        return err
                                }
+                               debug.FreeOSMemory()
                        }
                        log.Infof("%s: done (%d/%d)", infile, int(atomic.AddInt64(&done, 1)), len(infiles))
                        return nil