From: Rob Pike Date: Thu, 26 Jan 2012 22:44:38 +0000 (-0800) Subject: FAQ: more words about why GOMAXPROCS>1 might not speed you up X-Git-Tag: weekly.2012-01-27~6 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=01afb79c5960c746238c21b1eadc222af85d7c19;p=gostls13.git FAQ: more words about why GOMAXPROCS>1 might not speed you up R=golang-dev, adg, gri CC=golang-dev https://golang.org/cl/5572067 --- diff --git a/doc/go_faq.html b/doc/go_faq.html index 33e5cde41a..93e1ea4ee5 100644 --- a/doc/go_faq.html +++ b/doc/go_faq.html @@ -1020,10 +1020,23 @@ slower?

It depends on the nature of your program. -Programs that contain several goroutines that spend a lot of time -communicating on channels will experience performance degradation when using -multiple OS threads. This is because of the significant context-switching -penalty involved in sending data between threads. +Problems that are intrinsically sequential cannot be sped up by adding +more goroutines. +Concurrency only becomes parallelism when the problem is +intrinsically parallel. +

+ +

+In practical terms, programs that spend more time +communicating on channels than doing computation +will experience performance degradation when using +multiple OS threads. +This is because sending data between threads involves switching +contexts, which has significant cost. +For instance, the prime sieve example +from the Go specification has no significant parallelism although it launches many +goroutines; increasing GOMAXPROCS is more likely to slow it down than +to speed it up.