

What does MoarVM do with your Perl 6 code? - lelf
http://perl6advent.wordpress.com/2014/12/11/day-11-so-what-does-moarvm-do-with-your-perl-6-code/

======
sciurus
For more on MoarVM see [http://moarvm.org](http://moarvm.org)

According to [http://perl6advent.wordpress.com/2014/12/01/the-state-of-
per...](http://perl6advent.wordpress.com/2014/12/01/the-state-of-
perl-6-in-2014/) "In 2014, MoarVM has become the de facto standard backend for
the Rakudo Perl 6 compiler. Parrot and JVM are still supported as backends,
but MoarVM provides much lower memory usage, faster startup time, and is
significantly faster than parrot at runtime. Rakudo on MoarVM also has
concurrency support, including reactive programming."

------
petercooper
_The simple program: my $i = 0; while ++$i <= 100000000 { } .. got a factor of
2.5 improvement with what we had several months ago_

If the topic is optimization improvements, is the improvement in question one
that assigns the eventual value directly to $i? :-) (Or if that's literally
the whole program, optimizes it away to nothing.)

~~~
chrisseaton
It's quite hard to remove that loop.

First of all, keep in mind that the loop isn't empty - it includes the
iteration condition.

Then think you've got a loop of 100000000 iterations. Are you suggesting we
should unroll that so that it can be constant folded using conventional
techniques? That's going to be prohibitively expensive in terms of space and
time.

If we can't unroll we could peel it an iteration at a time, but we'll need
some kind of analysis that will detect that the body of the loop can be
constant folded, while at the still time having the control flow nodes in
there. That might well be possible, but I'm not personally aware of how to do
it - are you?

~~~
petercooper
As I'm academically naive to the topic (though I have a long term interest) I
was being 50% tongue in cheek and 50% "well, why not?" so take my comments in
my capacity as an enthusiastic but ignorant buffoon basking in the presence of
a certified genius.

With that said, I wrote the C equivalent of that Perl code, compiled -O0,
disassemble, and it's what you'd expect.. add, mov, cmp, jg. At O3, the entire
program is replaced by the no op: xor eax, eax.

I am surely comparing apples and oranges here and missing your point about the
control flow nodes, but gcc is making such an optimization on a naive
implementation so it seems conceptually possible in a more dynamic environment
if the same limitations can be calculated to be present on such an example,
maybe?

~~~
viraptor
In a fairly dynamic language, it may be more problematic than in C. I mean in
C you know _i_ is an _int_ and will not change. Maybe even know it's not used
later on, so changing _i_ at all is useless.

I honestly don't know how much magic you can inject into Perl6, but there have
to be languages dynamic enough that allow you to override integer increments
and make _$i=10; ++$i_ return an array of oranges. Possibly even from another
thread while you're iterating.

~~~
petercooper
If only I knew how to poke around in V8 some more, I'd be interested to see
what V8 would do on a JavaScript equivalent. JavaScript is reasonably dynamic
and its performance has skyrocketed in recent years mostly due to jumps in JIT
approaches and optimization. Of course, V8 has some of the smartest people in
the field working on it and the backing of Google.. :)

------
Diederich
The MoarVM folks are moving very quickly and achieving amazing results. Many
kudos to them.

------
DonHopkins
Wasn't MoarVM actually an April Fools Day joke, or do I have it confused with
something else?

~~~
chadzawistowski
You might be thinking of ParrotVM. Guido van Rossum and Larry Wall had an
April Fool's joke in which they announced they would combine Python and Perl
into a single new language, "Parrot". In spirit with the joke, ParrotVM
strives to be a good target many dynamic languages in general (such as Perl
and Python) rather than any specific language.

~~~
sciurus
I was curious what happened to Parrot; it seems dead at this point.

[https://www.openhub.net/p/parrot/commits/summary](https://www.openhub.net/p/parrot/commits/summary)

~~~
chromatic
_[W]hat happened to Parrot_

Almost all of its developers quit around the same time:

[http://www.modernperlbooks.com/mt/2013/02/goodnight-
parrot.h...](http://www.modernperlbooks.com/mt/2013/02/goodnight-parrot.html)

~~~
DonHopkins
Somebody finally explained to them that Parrot was actually a joke, and nobody
was actually serious about Perl 6 either.

