Also, to plug a possible hole: what is the parallelism[0] of your solution?

It might be that the coded solution is built such that only one goroutine
can run at any time. Thus, the critical path (the span) through the program
can only ever utilize a single core out of the 4 possible. You also need
enough work to actually fill a single core up and saturate it. If you have
lots of communication to other systems, and you spend most of your time
waiting for some proxy-task to complete, it would make sense that your
program never gets above the utilization of a single CPU core.

One common problem is if you have lots of channels which are unbuffered.
Hence, a sender has to wait for a receiver to be ready. If you are unlucky,
this could essentially tie your program up in a way such that only a single
processor core can run at the same time. Adding some buffers will help, but
make sure that your system can handle the inherent asynchronicity when
doing so.



[0] https://en.wikipedia.org/wiki/Analysis_of_parallel_algorithms

On Mon, Feb 27, 2017 at 7:59 PM Guillermo Estrada <phroze...@gmail.com>
wrote:

> Are you sure your virtual machine has 4 cores assigned? You might have 4
> cores, but when you create the VM you can assign any number of cores to it
> (1 being default IIRC).
>
>
> On Monday, February 27, 2017 at 12:39:31 PM UTC-6, Mark wrote:
>
> I just tried this on an old Windows 7-32bit machine which reports
> GOMAXPROCS of 2 but only one is ever used.
>
> On Monday, February 27, 2017 at 5:32:17 PM UTC, Mark wrote:
>
> I have a Go app that only uses 1 thread when GOMAXPROCS is 4 on Windows
> 7-64bit inside VirtualBox even though I can have up to 20 goroutines. Is
> this a known problem? And is there a solution that can force Go to use all
> 4 CPUs? (The underlying hardware is a 64-bit i7.)
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to