On Mon, May 28, 2012 at 08:39:15AM -0700, Will Coleda via RT wrote: > So, the original p5 code was: > > #!/usr/bin/perl -w > my $i = 0; > my @numbers; > until ( $i == 100000 ) { > $numbers[$i] = $i; > $i++; > } > > [...] > > OP gave the following one-shot benchmark numbers: > > Perl5: ~0.07s to complete, uses 26KB RAM at completion. > Rakudo Perl6: ~1m14s to complete, uses 1.4GB RAM at completion.
I find the RAM usage cited for the P5 case to be very suspect -- I don't know that an array of 100K integers can be held in 26KB of RAM. I'll need more details about what is actually being measured here before addressing "memory consumption used compared with p5" as bug. On my system running perl 5.14.2, the P5 version above completes in 0.03 sec: pmichaud@kiwi:~/p6/rakudo$ cat x.p5 #!/usr/bin/perl -w my $i = 0; my @numbers; until ( $i == 100000 ) { $numbers[$i] = $i; $i++; } pmichaud@kiwi:~/p6/rakudo$ time perl x.p5 real 0m0.033s user 0m0.028s sys 0m0.004s > p6 code was: > > use v6; > my Int $i = 0; > my @numbers; > until ( $i == 100000 ) { > @numbers[$i] = $i; > $i++; > } As of 2012.05-94-g197e0bd, Rakudo now executes the above on my system in about 5 seconds (versus 74 seconds in OP): pmichaud@kiwi:~/p6/rakudo$ cat x.p6 use v6; my Int $i = 0; my @numbers; until ($i == 100000 ) { @numbers[$i] = $i; $i++; } pmichaud@kiwi:~/p6/rakudo$ time ./perl6 x.p6 real 0m5.031s user 0m4.808s sys 0m0.204s Adding the "Int" constraint to $i is slightly unfair to the p6 test, since it has to do more work (type checking) than the p5 version did. However, removing the "Int" on my system didn't significantly improve the speed, although it might on other systems. Changing "Int" to "int" to use native ints for $i exposes a bug with postfix:<++> (to be filed as a different ticket). Working around that bug gives a loop that executes in 4 seconds: pmichaud@kiwi:~/p6/rakudo$ cat z.p6 use v6; my int $i = 0; my @numbers; until ($i == 100000 ) { @numbers[$i] = $i; $i = $i + 1; } pmichaud@kiwi:~/p6/rakudo$ time ./perl6 z.p6 real 0m4.000s user 0m3.788s sys 0m0.188s Based on the above, I'm declaring this ticket "resolved". I recognize that some people will still want the 100+ x speed difference between p5 and p6 to be considered a "bug", but to me that starts to smack of an apples-to-oranges comparison unless startup time needed for equivalent language features is included in the p5 case. Also, this test is a little artificial; the canonical way to initialize @numbers in p6 would be: pmichaud@kiwi:~/p6/rakudo$ cat w.p6 use v6; my @numbers = 0..9999; pmichaud@kiwi:~/p6/rakudo$ time ./perl6 w.p6 real 0m0.475s user 0m0.364s sys 0m0.104s Resolving ticket. Pm