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

slow array slicing #5234

Open
p6rt opened this issue Apr 12, 2016 · 6 comments
Open

slow array slicing #5234

p6rt opened this issue Apr 12, 2016 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 12, 2016

Migrated from rt.perl.org#127881 (status was 'open')

Searchable as RT127881$

@p6rt
Copy link
Author

p6rt commented Apr 12, 2016

From @MasterDuke17

'@​array[0, 3, 7]' is much slower than '(@​array[0], @​array[3], @​array[7])'

time perl6 -e 'my @​a = ^500;my @​f;my $s = @​a.elems;loop (my $i1 = 0; $i1 <
$s-1; $i1++) { loop (my $i2 = $i1+1; $i2 < $s; $i2++) { @​f.push(@​a[$i1,
$i2]) } };'

real 0m14.974s
user 0m14.947s
sys 0m0.017s

time perl6 -e 'my @​a = ^500;my @​f;my $s = @​a.elems;loop (my $i1 = 0; $i1 <
$s-1; $i1++) { loop (my $i2 = $i1+1; $i2 < $s; $i2++) { @​f.push((@​a[$i1],
@​a[$i2])) } };'

real 0m0.897s
user 0m0.877s
sys 0m0.017s

With Rakudo version 2016.03 built on MoarVM version 2016.03

Dan

@p6rt
Copy link
Author

p6rt commented Apr 13, 2016

From @lizmat

On 12 Apr 2016, at 04​:40, Daniel Green (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Daniel Green
# Please include the string​: [perl #​127881]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127881 >

'@​array[0, 3, 7]' is much slower than '(@​array[0], @​array[3], @​array[7])'

time perl6 -e 'my @​a = ^500;my @​f;my $s = @​a.elems;loop (my $i1 = 0; $i1 <
$s-1; $i1++) { loop (my $i2 = $i1+1; $i2 < $s; $i2++) { @​f.push(@​a[$i1,
$i2]) } };'

real 0m14.974s
user 0m14.947s
sys 0m0.017s

time perl6 -e 'my @​a = ^500;my @​f;my $s = @​a.elems;loop (my $i1 = 0; $i1 <
$s-1; $i1++) { loop (my $i2 = $i1+1; $i2 < $s; $i2++) { @​f.push((@​a[$i1],
@​a[$i2])) } };'

real 0m0.897s
user 0m0.877s
sys 0m0.017s

With Rakudo version 2016.03 built on MoarVM version 2016.03

This is a known issue. Anytime you use lists, the optimization paths are not that well developed yet. To give you another example​:

$ 6 'for ^100000 { my ($a,$b) = 42,666 }'
real 0m1.628s
user 0m1.582s
sys 0m0.041s

$ 6 'for ^100000 { my $a = 42; my $b = 666 }'
real 0m0.180s
user 0m0.152s
sys 0m0.026s

$ 6 'for ^100000 { my $a; my $b }'
real 0m0.170s
user 0m0.144s
sys 0m0.025s

$ 6 'say (1628 - 170) / (180 - 170)’
145.8

Liz

@p6rt
Copy link
Author

p6rt commented Apr 13, 2016

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

@p6rt
Copy link
Author

p6rt commented Apr 13, 2016

From @MasterDuke17

Where in Rakudo is the slowdown? I'm by no means a compiler developer, but
I enjoy tinkering.

Dan

On Wed, Apr 13, 2016 at 8​:04 AM, Elizabeth Mattijsen via RT <
perl6-bugs-followup@​perl.org> wrote​:

On 12 Apr 2016, at 04​:40, Daniel Green (via RT) <
perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Daniel Green
# Please include the string​: [perl #​127881]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127881 >

'@​array[0, 3, 7]' is much slower than '(@​array[0], @​array[3], @​array[7])'

time perl6 -e 'my @​a = ^500;my @​f;my $s = @​a.elems;loop (my $i1 = 0; $i1
<
$s-1; $i1++) { loop (my $i2 = $i1+1; $i2 < $s; $i2++) { @​f.push(@​a[$i1,
$i2]) } };'

real 0m14.974s
user 0m14.947s
sys 0m0.017s

time perl6 -e 'my @​a = ^500;my @​f;my $s = @​a.elems;loop (my $i1 = 0; $i1
<
$s-1; $i1++) { loop (my $i2 = $i1+1; $i2 < $s; $i2++) { @​f.push((@​a[$i1],
@​a[$i2])) } };'

real 0m0.897s
user 0m0.877s
sys 0m0.017s

With Rakudo version 2016.03 built on MoarVM version 2016.03

This is a known issue. Anytime you use lists, the optimization paths are
not that well developed yet. To give you another example​:

$ 6 'for ^100000 { my ($a,$b) = 42,666 }'
real 0m1.628s
user 0m1.582s
sys 0m0.041s

$ 6 'for ^100000 { my $a = 42; my $b = 666 }'
real 0m0.180s
user 0m0.152s
sys 0m0.026s

$ 6 'for ^100000 { my $a; my $b }'
real 0m0.170s
user 0m0.144s
sys 0m0.025s

$ 6 'say (1628 - 170) / (180 - 170)’
145.8

Liz

@p6rt
Copy link
Author

p6rt commented Jul 10, 2016

From @zoffixznet

Still present in 2016.06-154-g55c359e built on MoarVM version 2016.06-9-g8fc21d5

zoffix@​VirtualBox​:~$ 6 'for ^100000 { my ($a,$b) = 42,666 }'

real 0m1.052s
user 0m1.012s
sys 0m0.024s
zoffix@​VirtualBox​:~$ 6 'for ^100000 { my $a = 42; my $b = 666 }'

real 0m0.181s
user 0m0.164s
sys 0m0.012s
zoffix@​VirtualBox​:~$ 6 'for ^100000 { my $a; my $b }'

real 0m0.236s
user 0m0.216s
sys 0m0.020s

@p6rt
Copy link
Author

p6rt commented Dec 16, 2017

From @AlexDaniel

FWIW this issue was noticed today​: https://irclog.perlgeek.de/perl6/2017-12-16#i_15587006

On 2016-04-11 20​:40​:43, ddgreen@​gmail.com wrote​:

'@​array[0, 3, 7]' is much slower than '(@​array[0], @​array[3], @​array[7])'

time perl6 -e 'my @​a = ^500;my @​f;my $s = @​a.elems;loop (my $i1 = 0; $i1 <
$s-1; $i1++) { loop (my $i2 = $i1+1; $i2 < $s; $i2++) { @​f.push(@​a[$i1,
$i2]) } };'

real 0m14.974s
user 0m14.947s
sys 0m0.017s

time perl6 -e 'my @​a = ^500;my @​f;my $s = @​a.elems;loop (my $i1 = 0; $i1 <
$s-1; $i1++) { loop (my $i2 = $i1+1; $i2 < $s; $i2++) { @​f.push((@​a[$i1],
@​a[$i2])) } };'

real 0m0.897s
user 0m0.877s
sys 0m0.017s

With Rakudo version 2016.03 built on MoarVM version 2016.03

Dan

@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