Parallel computation of Mandelbrot set

Last weekend I attended FOSDEM, an amazing conference in Brussels.

As part of it I attended a great talk about how to use concurrency in Ada to compute the Mandelbrot set and paint it on screen.

I decided that it would be a cool idea to do the same using Go, after all concurrency is part of the DNA of Go.

The resulting program generates some pretty cool images like the one below.

The code is available on

The cool part about this is exercise is that the difference between the sequential and parallel solution is just five lines!

Basically I start a new goroutine per pixel, which means that for a 4096x4096 pixels image I start more than 16 million goroutines. Now this sounds like a bad idea, and it probably is, but the result is actually pretty amazing.

Passing from this code:
To this code:

allowed me to run 3 times faster on my MacBookPro i5.

But if you are concerned about the number of goroutines you should start you can limit them by using this simple approach.