Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rakudo consumes excessive resources for a simple loop #1027

Closed
p6rt opened this issue May 30, 2009 · 11 comments
Closed

Rakudo consumes excessive resources for a simple loop #1027

p6rt opened this issue May 30, 2009 · 11 comments

Comments

@p6rt
Copy link

p6rt commented May 30, 2009

Migrated from rt.perl.org#66152 (status was 'resolved')

Searchable as RT66152$

@p6rt
Copy link
Author

p6rt commented May 30, 2009

From adam@ali.as

As requested by chromatic

http://use.perl.org/~korpenkraxar/journal/39051

@p6rt
Copy link
Author

p6rt commented Jun 13, 2009

From @moritz

On Sat May 30 10​:58​:04 2009, adam@​ali.as wrote​:

As requested by chromatic

http://use.perl.org/~korpenkraxar/journal/39051

Since this is a bug report, it should also be closable.
So please formulate it as a condition that can be objectively tested and
that's achievable.

(That said, I very much appreciate your effort)

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jun 13, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jun 16, 2009

From adam@ali.as

I'm not sure what testable condition you'd want to use, but as a
starting point I'd suggest that you execute the loop and then confirm
that the total memory consumed by the process is lower than some
anticipated threshold.

You could pick something like 1 meg as a starting point perhaps?

Adam K

On Sat, Jun 13, 2009 at 10​:20 PM, Moritz Lenz via
RT<perl6-bugs-followup@​perl.org> wrote​:

On Sat May 30 10​:58​:04 2009, adam@​ali.as wrote​:

As requested by chromatic

http://use.perl.org/~korpenkraxar/journal/39051

Since this is a bug report, it should also be closable.
So please formulate it as a condition that can be objectively tested and
that's achievable.

(That said, I very much appreciate your effort)

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Aug 20, 2010

From @bbkr

[14​:39] <bbkr> http://rt.perl.org/rt3/Ticket/Display.html?id=66152 -
this ticket still has no "closable point" defined. and I'm not sure if
we should test against used memory amount after all, since this will be
platform-dependent and there is no threshold which is considered correct.
[14​:40] <moritz_> bbkr​: just because it's not testable right now doesn't
mean there's no point to the ticket

@p6rt
Copy link
Author

p6rt commented May 28, 2012

From @coke

On Sat May 30 10​:58​:04 2009, adam@​ali.as wrote​:

As requested by chromatic

http://use.perl.org/~korpenkraxar/journal/39051

This url is now a 404. Anyone have the original text?

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented May 28, 2012

From @Siddhant

On Mon, May 28, 2012 at 8​:29 AM, Will Coleda via RT
<perl6-bugs-followup@​perl.org> wrote​:

On Sat May 30 10​:58​:04 2009, adam@​ali.as wrote​:

As requested by chromatic

http://use.perl.org/~korpenkraxar/journal/39051

This url is now a 404. Anyone have the original text

Here is the archived text​:
http://web.archive.org/web/20100113111447/http://use.perl.org/~korpenkraxar/journal/39051
from The Wayback Machine. I couldn't find any comment by 'chromatic'
there but well, I did not look hard enough.

- Siddhant

@p6rt
Copy link
Author

p6rt commented May 28, 2012

From @coke

So, the original p5 code was​:

#!/usr/bin/perl -w
my $i = 0;
my @​numbers;
until ( $i == 100000 ) {
  $numbers[$i] = $i;
  $i++;
}

p6 code was​:

use v6;
my Int $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.

1 similar comment
@p6rt
Copy link
Author

p6rt commented May 28, 2012

From @coke

So, the original p5 code was​:

#!/usr/bin/perl -w
my $i = 0;
my @​numbers;
until ( $i == 100000 ) {
  $numbers[$i] = $i;
  $i++;
}

p6 code was​:

use v6;
my Int $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.

@p6rt
Copy link
Author

p6rt commented May 28, 2012

From @pmichaud

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

@p6rt
Copy link
Author

p6rt commented May 28, 2012

@pmichaud - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed May 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant