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

.first on an infinite list generated with gather take is excruciatingly slow #3090

Closed
p6rt opened this issue Mar 29, 2013 · 6 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Mar 29, 2013

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

Searchable as RT117403$

@p6rt
Copy link
Author

p6rt commented Mar 29, 2013

From @thundergnat

my @​j := (0 .. *).list;
say @​j.first​: {$^_ > 10};

returns 11 in .01 seconds on my system

my @​l := gather map {take $_ }, 0 .. *;
say @​l.first​: {$^_ > 10};

returns 11 in 63.97 seconds on my system

thundergnat​: r​: my @​harshad := gather for 1 .. * { take $_ if $_ %%
[+] .comb }; say @​harshad.first​: {$^_ > 1000}; # takes 5400 seconds
locally to return an answer
p6eval​: rakudo 25a9d6​: OUTPUT«(timeout)»
pmichaud​: right, so that tells me there's a bug somewhere in the
list code.
pmichaud​: and the way to fix that is by fixing the list code, not
by patching around the bug.
thundergnat​: Should I file a bug report then?
pmichaud​: sure, that works.
thundergnat​: pmichaud​: It only seems to occur in lists created using
gather take. I wonder if it is some weird interaction between GatherIter
and ListIter?
pmichaud​: oh, GatherIter is indeed suboptimal for a lot of stuff.
  there definitely needs to be some improved
communication between GatherIter and MapIter
  I suspect that MapIter tries to go too far
ahead when confronted with an infinite GatherIter
  or, more likely...
  the gather isn't able to signal that it's
infinite, and that's causing MapIter to go too far ahead

@p6rt
Copy link
Author

p6rt commented Mar 12, 2015

From @Mouq

On Fri Mar 29 06​:37​:47 2013, thundergnat@​comcast.net wrote​:

my @​j := (0 .. *).list;
say @​j.first​: {$^_ > 10};

returns 11 in .01 seconds on my system

my @​l := gather map {take $_ }, 0 .. *;
say @​l.first​: {$^_ > 10};

returns 11 in 63.97 seconds on my system

FWIW, on my system with perl6 version "2015.02-275-g3da1bbd built on MoarVM version 2015.02-49-gb5b5435", I get about 8 seconds for​:

  perl6 -e'my @​l := gather map {take $_ }, 0 .. *; say @​l.first​: {$_ > 100000};'

And about 1 second for​:

  perl6 -e'my @​j := (0 .. *).list; say @​j.first​: {$_ > 100000}'

I'm thinking this is less outrageous. This should probably be added to perl6-bench or something to ensure we don't regress. Once we have some kind of test in place, I think this ticket can be resolved.

~Mouq

@p6rt
Copy link
Author

p6rt commented Mar 12, 2015

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

@p6rt
Copy link
Author

p6rt commented Aug 29, 2015

From @coke

On Wed Mar 11 20​:16​:11 2015, Mouq wrote​:

On Fri Mar 29 06​:37​:47 2013, thundergnat@​comcast.net wrote​:

my @​j := (0 .. *).list;
say @​j.first​: {$^_ > 10};

returns 11 in .01 seconds on my system

my @​l := gather map {take $_ }, 0 .. *;
say @​l.first​: {$^_ > 10};

returns 11 in 63.97 seconds on my system

FWIW, on my system with perl6 version "2015.02-275-g3da1bbd built on
MoarVM version 2015.02-49-gb5b5435", I get about 8 seconds for​:

perl6 -e'my @​l := gather map {take $_ }, 0 .. *; say @​l.first​: {$_ >
100000};'

And about 1 second for​:

perl6 -e'my @​j := (0 .. *).list; say @​j.first​: {$_ > 100000}'

I'm thinking this is less outrageous. This should probably be added to
perl6-bench or something to ensure we don't regress. Once we have some
kind of test in place, I think this ticket can be resolved.

~Mouq

on my OSX box on nom​: real 0m4.393s, and real 0m0.532s

on glr, the first is now a syntax error​:
second is slower with​: real 0m1.643s
--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Sep 14, 2015

From @niner

nine@​sphinx​:~/install/rakudo (nom=)> time perl6 -e'my $l := gather map {take $_ }, 0 .. *; say $l.first​: {$_ > 100000};'
100001

real 0m2.170s
user 0m2.141s
sys 0m0.026s
nine@​sphinx​:~/install/rakudo (nom=)> time perl6 -e'my @​j := (0 .. *).list; say @​j.first​: {$_ > 100000}'
100001

real 0m0.757s
user 0m0.736s
sys 0m0.022s

Performance seems ok now post GLR?

@p6rt p6rt closed this as completed Sep 14, 2015
@p6rt
Copy link
Author

p6rt commented Sep 14, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant