Skip to content
This repository has been archived by the owner on Sep 11, 2022. It is now read-only.

Commit

Permalink
Limit spawned goroutines to GOMAXPROCS(0).
Browse files Browse the repository at this point in the history
This change sets the number of spawned goroutines to the GOMAXPROCS
value set by the user.

Using more goroutines than available execution threads is slightly
detrimental to performance (~0.5%), and prevents users of the library
from controlling the number of spawned goroutines.
  • Loading branch information
charlievieth committed Mar 15, 2015
1 parent d8255b0 commit 076a9ce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions resize.go
Expand Up @@ -97,7 +97,7 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i
}

taps, kernel := interp.kernel()
cpus := runtime.NumCPU()
cpus := runtime.GOMAXPROCS(0)
wg := sync.WaitGroup{}

// Generic access to image.Image is slow in tight loops.
Expand Down Expand Up @@ -283,7 +283,7 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i

func resizeNearest(width, height uint, scaleX, scaleY float64, img image.Image, interp InterpolationFunction) image.Image {
taps, _ := interp.kernel()
cpus := runtime.NumCPU()
cpus := runtime.GOMAXPROCS(0)
wg := sync.WaitGroup{}

switch input := img.(type) {
Expand Down

0 comments on commit 076a9ce

Please sign in to comment.