diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-04-05 10:09:22 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-04-05 10:21:25 +0200 |
commit | 87b16abd93ff60acd245776d5b0d914fd580c259 (patch) | |
tree | 19dcc2ef755814cf2b19be533df0fe978db46f55 /hugolib | |
parent | 415ca9673d3bd3c06ab94f3d83897c892fce5f27 (diff) |
Add HUGO_NUMWORKERMULTIPLIER
And use that to calculate number of workers, if set, else fall back to number of logical CPUs.
Also tweak the relevant related settings to match the new setup.
Also remove the setting of `runtime.GOMAXPROCS` as this has been the default behaviour since Go 1.5.
Fixes #5814
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/pagebundler.go | 8 | ||||
-rw-r--r-- | hugolib/pagebundler_capture.go | 8 | ||||
-rw-r--r-- | hugolib/site.go | 9 | ||||
-rw-r--r-- | hugolib/site_render.go | 4 |
4 files changed, 9 insertions, 20 deletions
diff --git a/hugolib/pagebundler.go b/hugolib/pagebundler.go index 682221d8c..5149968bc 100644 --- a/hugolib/pagebundler.go +++ b/hugolib/pagebundler.go @@ -18,7 +18,8 @@ import ( "fmt" "math" "path/filepath" - "runtime" + + "github.com/gohugoio/hugo/config" _errors "github.com/pkg/errors" @@ -73,10 +74,7 @@ func (s *siteContentProcessor) processAsset(asset pathLangFile) { } func newSiteContentProcessor(ctx context.Context, partialBuild bool, s *Site) *siteContentProcessor { - numWorkers := 12 - if n := runtime.NumCPU() * 3; n > numWorkers { - numWorkers = n - } + numWorkers := config.GetNumWorkerMultiplier() * 3 numWorkers = int(math.Ceil(float64(numWorkers) / float64(len(s.h.Sites)))) diff --git a/hugolib/pagebundler_capture.go b/hugolib/pagebundler_capture.go index 17a4b865a..7c01a751d 100644 --- a/hugolib/pagebundler_capture.go +++ b/hugolib/pagebundler_capture.go @@ -19,7 +19,8 @@ import ( "os" "path" "path/filepath" - "runtime" + + "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/common/loggers" _errors "github.com/pkg/errors" @@ -70,10 +71,7 @@ func newCapturer( contentChanges *contentChangeMap, filenames ...string) *capturer { - numWorkers := 4 - if n := runtime.NumCPU(); n > numWorkers { - numWorkers = n - } + numWorkers := config.GetNumWorkerMultiplier() // TODO(bep) the "index" vs "_index" check/strings should be moved in one place. isBundleHeader := func(filename string) bool { diff --git a/hugolib/site.go b/hugolib/site.go index 84ee7823c..616b5b37d 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -1881,15 +1881,6 @@ func (s *Site) newPage(kind string, sections ...string) *pageState { return p } -func getGoMaxProcs() int { - if gmp := os.Getenv("GOMAXPROCS"); gmp != "" { - if p, err := strconv.Atoi(gmp); err == nil { - return p - } - } - return 1 -} - func (s *Site) shouldBuild(p page.Page) bool { return shouldBuild(s.BuildFuture, s.BuildExpired, s.BuildDrafts, p.Draft(), p.PublishDate(), p.ExpiryDate()) diff --git a/hugolib/site_render.go b/hugolib/site_render.go index f3df09f09..1d8b14b0a 100644 --- a/hugolib/site_render.go +++ b/hugolib/site_render.go @@ -19,6 +19,8 @@ import ( "strings" "sync" + "github.com/gohugoio/hugo/config" + "github.com/gohugoio/hugo/output" "github.com/pkg/errors" @@ -55,7 +57,7 @@ func (s siteRenderContext) renderSingletonPages() bool { // TODO(bep np doc func (s *Site) renderPages(ctx *siteRenderContext) error { - numWorkers := getGoMaxProcs() * 4 + numWorkers := config.GetNumWorkerMultiplier() results := make(chan error) pages := make(chan *pageState, numWorkers) // buffered for performance |