1
0
mirror of https://github.com/golang/go synced 2024-11-12 05:50:21 -07:00

add a paragraph about GOMAXPROCS

R=rsc
CC=golang-dev
https://golang.org/cl/154153
This commit is contained in:
Rob Pike 2009-11-15 13:09:43 -08:00
parent 39f64bed52
commit dc3b4932d8

View File

@ -2233,6 +2233,22 @@ func (v Vector) DoAll(u Vector) {
</pre>
<p>
The current implementation of <code>gc</code> (<code>6g</code>, etc.)
will not parallelize this code by default.
It dedicates only a single core to user-level processing. An
arbitrary number of goroutines can be blocked in system calls, but
by default only one can be executing user-level code at any time.
It should be smarter and one day it will be smarter, but until it
is if you want CPU parallelism you must tell the run-time
how many goroutines you want executing code simultaneously. There
are two related ways to do this. Either run your job with environment
variable <code>GOMAXPROCS</code> set to the number of cores to use
(default 1); or import the <code>runtime</code> package and call
<code>runtime.GOMAXPROCS(NCPU)</code>.
Again, this requirement is expected to be retired as the scheduling and run-time improve.
</p>
<h3 id="leaky_buffer">A leaky buffer</h3>
<p>