Are channels and goroutines of any use in CG?

Hi,

I’ve been looking for a lower level alternative to Python and Go seems like a good candidate.

I read somewhere that CG time limits are in CPU time and that parallelism is basically not supported. If this is the case, would it be correct to assume that goroutines and channels are not of any use in CG from a performance point of view?

Note: I understand that just using goroutines and channels is not a sufficient condition for parallelism and that one would also need to tell Go to actually use the other cores. My question is basically: if CG does not support parallelism, should I just forget about channels and goroutines? Has anyone found these tools useful in CG?

Hey,

Just a small precision : Multi-thread and parallelism are possible on CG BUT inefficient. All programs run in a VM which has only one core.

In that sense, goroutines and channels can still be useful (if you want to have some kind of MPMD architecture in your code), but won’t be very efficient. In any case they will never be “required” to solve a problem :slight_smile:

2 Likes

CG actually provide a core with hyperthreading, so it does show up as two cpus and can multitask to a limited extent. I saw a 5-10% increase in performance on my fantastic bits code using goroutines (in my Genetic Algorithm each generation would launch 50 goroutines that each do mutation/evolution/simulation/scoring of a single new solution ).

GOMAXPROCS has defaulted to number of cpu since go 1.5 so extra cores are now used by default.

I quite like go for CG as it gives good performance while still catching a lot more mistakes than c/c++ (also I spend most of the day writing c / c++ so like to use a different language where possible).

3 Likes