This is a simple Mandelbrot fractal generator that uses Scala actors. I wrote this to learn more about how actors work.
To compile and run MandelActors, you need:
After installing the JDK and Maven and adding their bin
directories to your PATH
, you can compile it with: mvn compile
If you have compiled MandelActors successfully, run it with run.bat
(Windows) or run.sh
(Mac OS X and Linux).
Note: Especially when you use the renderers that use actors, and the number of samples is large (with a large image size and multiple samples per pixel), the program needs a lot of memory. You can set the maximum amount of memory to use by changing the value of the -Xmx
parameter in the JAVA_OPTS
environment variable in run.bat
or run.sh
.
To configure MandelActors, edit the file mandelactors.properties
. You can set the size of the output image, change settings for the sampler and reconstruction filter and parameters for the Mandelbrot algorithm. You can also select the renderer to use. Currently, there are five renderers:
This renderer uses a single thread to do the rendering. This is useful to compare how fast the actor renderers perform compared to doing everything in a single thread.
This renderer uses Scala 2.9 parallel collections.
This uses event-based actors: actors that use react
to process messages. For each batch of samples, a new actor is created. This can potentially create a large number of actors, but event-based actors are very lightweight, so this is not a problem.
This uses thread-based actors: actors that use receive
to process messages. Thread-based actors block the thread they are running on while waiting to receive a message, so that each actor needs its own thread. Therefore, they are much more heavyweight than event-based actors and you can't create a large number of them.
The ThreadActors renderer creates a fixed number of actors and sends them batches of samples by round-robin scheduling. When the rendering is done, the actors are sent a stop message.
Configuration settings:
renderer.actorCount
The number of actors to create (default: twice the number of CPU cores available to the JVM).
This renderer does not use actors, but threads. It starts up a number of threads which pick up batches of samples from a work queue. The way this renderer works is a lot like the ThreadActors renderer.
Configuration settings:
renderer.threadCount
The number of threads to create (default: twice the number of CPU cores available to the JVM).