ref: 13972d6c833f7837e8a04b1931e25e6fcc2e10c8
parent: 91968f3b1fad64a5cae53e18113e50ea50e14bbd
author: Bjørn Erik Pedersen <[email protected]>
date: Tue Feb 21 13:56:56 EST 2017
hugolib: Cleanup the Goroutine count calculation
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -484,8 +484,9 @@
func (s *Site) preparePagesForRender(cfg *BuildCfg) {
pageChan := make(chan *Page)
wg := &sync.WaitGroup{}
+ numWorkers := getGoMaxProcs() * 4
- for i := 0; i < getGoMaxProcs()*4; i++ {
+ for i := 0; i < numWorkers; i++ {
wg.Add(1)
go func(pages <-chan *Page, wg *sync.WaitGroup) {
defer wg.Done()
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -1150,11 +1150,10 @@
files := s.Source.Files()
results := make(chan HandledResult)
filechan := make(chan *source.File)
- procs := getGoMaxProcs()
wg := &sync.WaitGroup{}
-
- wg.Add(procs * 4)
- for i := 0; i < procs*4; i++ {
+ numWorkers := getGoMaxProcs() * 4
+ wg.Add(numWorkers)
+ for i := 0; i < numWorkers; i++ {
go sourceReader(s, filechan, results, wg)
}
@@ -1178,11 +1177,11 @@
results := make(chan HandledResult)
pageChan := make(chan *Page)
fileConvChan := make(chan *source.File)
- procs := getGoMaxProcs()
+ numWorkers := getGoMaxProcs() * 4
wg := &sync.WaitGroup{}
- wg.Add(2 * procs * 4)
- for i := 0; i < procs*4; i++ {
+ for i := 0; i < numWorkers; i++ {
+ wg.Add(2)
go fileConverter(s, fileConvChan, results, wg)
go pageConverter(pageChan, results, wg)
}
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -33,11 +33,11 @@
go errorCollator(results, errs)
- procs := getGoMaxProcs()
+ numWorkers := getGoMaxProcs() * 4
wg := &sync.WaitGroup{}
- for i := 0; i < procs*4; i++ {
+ for i := 0; i < numWorkers; i++ {
wg.Add(1)
go pageRenderer(s, pages, results, wg)
}