Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

minimum work size of a goroutine [closed]

Does anyone know approximately what the minimum work size is needed in order for a goroutine to be beneficial (assuming that there are free cores for the work to be offloaded to)?

like image 966
Mark Avatar asked Nov 14 '09 03:11

Mark


2 Answers

I've been plodding through project euler with Go. While I don't have a definite answer for you I found the goroutine-based primality sieve in the Go docs to be an order of magnitude slower than simply checking each number for primality. Setting GOMAXPROCS to a higher value didn't help, either.

like image 129
fbrereto Avatar answered Sep 21 '22 05:09

fbrereto


goroutine is an abstraction that you use if it helps you model your application better. You're doing concurrency oriented programming, so think about the parts of your application that have concurrency within them.

Think about an OO system and imagine asking the same question about whether you should instantiate an object.

Do the thing that makes sense first.

like image 36
Dustin Avatar answered Sep 20 '22 05:09

Dustin