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

severe performance problem with ranges and pick #5829

Closed
p6rt opened this issue Nov 27, 2016 · 4 comments
Closed

severe performance problem with ranges and pick #5829

p6rt opened this issue Nov 27, 2016 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 27, 2016

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

Searchable as RT130190$

@p6rt
Copy link
Author

p6rt commented Nov 27, 2016

From laurent.rosenfeld@googlemail.com

Hi,

This is a simplified example of the problem I encountered​:

my $start = now; my $c = (1..1e5).pick; say now - $start;
9.97741524
my $start = now; my $c = (1..100_000).pick; say now - $start;
0

10 seconds to pick a random number between 1 and 1e5 seems to be a disaster.

From the discussion on the #perl6 IRC channel, there are some errors with
my test​: using (1e0..1e5).pick is already much faster, but still way slower
than (1..100_000).pick​:

my $start = now; my $c = (1e0..1e5).pick; say now - $start;
0.4222894

It was also suggested to me that I should use integers (i.e. not the 1e5
Num notation), but my real case had hundreds of digits so that using for
example the 1e200 notation seemed better than typing all 200 digits.

I found a work around​:

my $up = 1e5.Int;
100000
my $start = now; my $c = (1..$up).pick; say now - $start;
0.00100080

So I have a solution to my problem, but it was suggested on the #perl6 IRC
channel that I should still submit a performance bug report.

Cheers,
Laurent.

@p6rt
Copy link
Author

p6rt commented Dec 10, 2016

From @zoffixznet

On Sun, 27 Nov 2016 10​:11​:51 -0800, laurent.rosenfeld@​googlemail.com wrote​:

Hi,

This is a simplified example of the problem I encountered​:

my $start = now; my $c = (1..1e5).pick; say now - $start;
9.97741524
my $start = now; my $c = (1..100_000).pick; say now - $start;
0

10 seconds to pick a random number between 1 and 1e5 seems to be a disaster.

From the discussion on the #perl6 IRC channel, there are some errors with
my test​: using (1e0..1e5).pick is already much faster, but still way slower
than (1..100_000).pick​:

my $start = now; my $c = (1e0..1e5).pick; say now - $start;
0.4222894

It was also suggested to me that I should use integers (i.e. not the 1e5
Num notation), but my real case had hundreds of digits so that using for
example the 1e200 notation seemed better than typing all 200 digits.

I found a work around​:

my $up = 1e5.Int;
100000
my $start = now; my $c = (1..$up).pick; say now - $start;
0.00100080

So I have a solution to my problem, but it was suggested on the #perl6 IRC
channel that I should still submit a performance bug report.

Cheers,
Laurent.

Thank you for the report. The cause of a massive slowdown was located and fixed and now the performance of infix​:<..> on Nums is closer to "normal" levels.

Fixed in rakudo/rakudo@a8ba26bbe
Test for another bug located during this fix and squashed with the same commit​: Raku/roast@e6b125eef1

@p6rt
Copy link
Author

p6rt commented Dec 10, 2016

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

@p6rt
Copy link
Author

p6rt commented Dec 10, 2016

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

@p6rt p6rt closed this as completed Dec 10, 2016
@p6rt p6rt added the perf label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant