Welcome to Fractal Forums

Fractal Software => Announcements & News => Topic started by: python.wiz on June 02, 2016, 12:40:07 AM




Title: mandelbrotG5
Post by: python.wiz on June 02, 2016, 12:40:07 AM
Code is here on github: https://github.com/ChrisCalderon/mandelbrotG5

I'd love any feedback. It uses the multiprocessing module in the python standard library to make processes. Each child process writes a row of pixels, and the parent process writes data from the shared array using pypng.

Right now I'm able to render a 30k x 20k image in 3 hours, 10 minutes on my laptop.


Title: Re: mandelbrotG5
Post by: claude on June 02, 2016, 02:40:57 AM
I didn't run it, but code looks simple and clear, the kind of thing I'd look for if I wanted to learn multiprocessing in Python.

I doubt you'll win any speed records using Python though, but you could probably do quite a bit better if you call out to a C function for the inner loop of Mandelbrot iterations.

For speed comparison, my fastest double-precision renderer renders a 20000x20000 image of the whole set with maxiters 1000000 in 6m40s on my quad core desktop (3GHz amd64).  You can get the image here (might want to save without viewing in browser, it decompresses pretty big): https://mathr.co.uk/mandelbrot/2016-06-02_mandelbrot_20000px.png (9.7MB)  (I did try 30000x20000 but it crashed, possibly int overflow leading to bad malloc)

To get it that fast I use biased interior checking, documented here https://mathr.co.uk/blog/2014-11-02_practical_interior_distance_rendering.html

C source code for mine is around https://code.mathr.co.uk/mandelbrot-graphics but the Javascript version might be easier to port to Python if you're curious: https://mathr.co.uk/mandelbrot/web/m-render.js


Title: Re: mandelbrotG5
Post by: python.wiz on June 02, 2016, 10:28:51 PM
Thanks for saying the code looks clear :) . I've changed it a bit, and now it renders a 30k x 20k in 46 minutes! I don't know how much faster I can get it in python. I could try switching to doing work on tiles and use more of numpy's vectorized stuff, but I'm pretty happy with it right now. Idk what other desktop renderers' UIs are like, but I've just updated my CLI too. Now instead of specifying a height and width in pixels, you specify a zoom level.

One thing I can see being a problem with it is the size of the images it creates; the 30k x 20k PNG is ~190MB. Another scaling problem my code has is that the image data is held entirely in RAM throughout the render process, meaning the largest picture I could possibly render is around 210k x 140k (my laptop has 32 GB of RAM.)