hugolib: Cleanup the Goroutine count calculation
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 21 Feb 2017 17:56:56 +0000 (18:56 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 21 Feb 2017 17:56:56 +0000 (18:56 +0100)
hugolib/hugo_sites.go
hugolib/site.go
hugolib/site_render.go

index 624cb2b9f2d115addfd8e2a3a93475602303cf5e..dbaec164483d73b56a42e5aede5ded24f788a5d8 100644 (file)
@@ -484,8 +484,9 @@ func (h *HugoSites) setupTranslations() {
 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()
index 415a1c5975e55183e1b5f0ce09aee386b272f194..e2aa7449fb4fbd5fca6c35b73f63bd5e8f638515 100644 (file)
@@ -1150,11 +1150,10 @@ func (s *Site) readPagesFromSource() chan error {
        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 @@ func (s *Site) convertSource() chan error {
        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)
        }
index c6774339462d5ea6fb51692a1aca033ea7018eb5..5709aa83a9cb30107ae0d76c825d978caf744ea5 100644 (file)
@@ -33,11 +33,11 @@ func (s *Site) renderPages() error {
 
        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)
        }