ソースを参照

Merge pull request #154 from vmarkovtsev/master

Tighten the heap size and force RSS cleanup
Vadim Markovtsev 6 年 前
コミット
67be01cb9d
1 ファイル変更8 行追加0 行削除
  1. 8 0
      internal/core/pipeline.go

+ 8 - 0
internal/core/pipeline.go

@@ -8,6 +8,7 @@ import (
 	"log"
 	"os"
 	"path/filepath"
+	"runtime/debug"
 	"sort"
 	"strings"
 	"time"
@@ -644,6 +645,10 @@ func (pipeline *Pipeline) Initialize(facts map[string]interface{}) error {
 			return errors.Wrapf(err, "%s failed to initialize", item.Name())
 		}
 	}
+	if pipeline.HibernationDistance > 0 {
+		// if we want hibernation, then we want to minimize RSS
+		debug.SetGCPercent(20) // the default is 100
+	}
 	return nil
 }
 
@@ -676,6 +681,9 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 		if pipeline.DryRun {
 			continue
 		}
+		if index > 0 && index%100 == 0 && pipeline.HibernationDistance > 0 {
+			debug.FreeOSMemory()
+		}
 		firstItem := step.Items[0]
 		switch step.Action {
 		case runActionCommit: