> Or is there some benefit in having less threads and switching between
> goroutines in one thread?
>
> On Aug 1, 7:42 pm, John Nogatch <jnoga...@gmail.com> wrote:
>> While learning go, I implemented Conway's game of life. A goroutine is
>> started for each cell of an array that is 126 columns by 37 rows =
>> 4662 goroutines, plus the main thread which performs the display.
>>
>> The following shows GOMAXPROCS, mean time per generation (sec), and
>> standard deviation of time per generation (sec), when run on a 1 CPU
>> Intel Pentium III:
[..]
>> Performance improved when GOMAXPROCS was increased to 10, on a 1 CPU
>> laptop.
>>
>> Very large values of GOMAXPROCS degraded performance only slightly.
>>
>> Using the "H" option to "top" showed only 7 active threads, for
>> "GOMAXPROCS=100".
Best regards/Mit freundlichen Grüßen
--
Muharem Hrnjadovic <muh...@lbox.cc>
Public key id : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F 5602 219F 6B60 B2BB FCFC
> I can imagine why there could be a performance benefit for running
> only one goroutine at a time (no locking), but I never really
> understood why there should be a real life benefit caused by limiting
> the number of goroutines depending on the number of processors. And I
> think I read somewhere that thats planned for the future. Isn't the
> operating system scheduler good enough to handle that task?
The scheduler should be good enough. But in a 1:1 model, each
goroutine needs a kernel stack, which takes up 8K. This means that
they are not really that lightweight, no matter what you do on the
userspace side.
[..]
> Performance improved when GOMAXPROCS was increased to 10, on a 1 CPU
> laptop.
>
> Very large values of GOMAXPROCS degraded performance only slightly.
I made some similar observations running parallel Go code on a multicore
machine though: http://tinyurl.com/3w4nrby -- The sweet spot in my case
was GOMAXPROCS=8