I am running a program which reads multiple gzipped input files and 
performs some processing on each line of the file. 
It creates 8 goroutines (1 per input file which is to be processed. the 
number of such files can be thought to remain 8 at the max).
Each of the go routines send to a buffered channel after finishing 
processing of their respective file.
After creating the go routines, the program waits (using WaitGroup) for all 
go routines to finish and also drain the channel for all the values sent by 
the go routines.

I have an 4 core CPU with 2 threads per core = 8 logical cores.

But I set GOMAXPROCS=4

When I run the program with scheduler trace interval set to 1000ms, I can 
see the following :

SCHED 1001ms: gomaxprocs=4 idleprocs=0 threads=8 spinningthreads=0 
idlethreads=0 runqueue=0 [0 0 0 1]
SCHED 2008ms: gomaxprocs=4 idleprocs=0 threads=8 spinningthreads=0 
idlethreads=1 runqueue=0 [1 0 5 0]
SCHED 3015ms: gomaxprocs=4 idleprocs=0 threads=8 spinningthreads=0 
idlethreads=1 runqueue=1 [0 0 1 0]
SCHED 4022ms: gomaxprocs=4 idleprocs=0 threads=9 spinningthreads=0 
idlethreads=2 runqueue=0 [0 0 0 0]
SCHED 5029ms: gomaxprocs=4 idleprocs=0 threads=9 spinningthreads=0 
idlethreads=2 runqueue=1 [0 0 0 4]


If I create 8 go routines, shouldn't they all be distributed equally among 
the 4 logical cores ?

Why do some runqueues of the logical cores show values of 4 or 5 and some 
have values of 0 ?

I was hoping to see something like which I according to my understanding 
means that all 4 processors have 1 go routine each waiting in the local 
runqueue and at the same time has 1 go routine running on the assigned OS 
Thread :

SCHED 1001ms: gomaxprocs=4 idleprocs=0 threads=8 spinningthreads=0 
idlethreads=0 runqueue=0 [1 1 1 1]

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0c34efb7-18e0-4b16-9e71-fbb4efd57374o%40googlegroups.com.

Reply via email to