I’ve dragged the Mandelbrot script from day 17 of the Advent calendar kicking and screaming to the current version of Rakudo. The big hurdle turned out to be an under-spec’d and poorly implemented corner of Range. If you specified the size on the command line, then the width / height was a string. And, well:
> say (^"501").eager.perl (0, 1, 2, 3, 4, 5)
Once I converted width / height to a numeric type, the script worked fine.
Martin Berends wrote a beautiful little Perl 5 script to monitor run time and memory usage on a Linux box, enabling me to do a profile of how Rakudo behaves when you bump up the size of the Mandelbrot set we calculate. There is both good and bad news on this front.
The good news: we would expect that doubling the length of an edge would quadruple the time taken. Because each line of the set is output as we go, we would expect doubling the edge length would memory double the memory required. In both cases, that is exactly what we see, which means there are no unexpected N^2 or worse issues.
The bad news: The code is very slow, and worse, it uses insane amounts of memory. Generating a 1001×1001 Mandelbrot set — an operation that should only use the memory required to store 1001 Complex numbers in an array and 1001 ints in another array — takes 6.4 GB of memory. Obviously that’s not what we’re seeing, as a quick test script I just wrote shows that you can create both those arrays in under 25MB of memory. So something else is eating up memory at a ferocious rate.