Skip Menu |
Report information
Id: 127881
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: ddgreen [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] slow array slicing
To: rakudobug [...] perl.org
From: Daniel Green <ddgreen [...] gmail.com>
Date: Mon, 11 Apr 2016 23:40:29 -0400
Download (untitled) / with headers
text/plain 575b
'@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
Subject: Re: [perl #127881] [BUG] slow array slicing
To: "Daniel Green (via RT)" <perl6-bugs-followup [...] perl.org>
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Date: Wed, 13 Apr 2016 13:03:58 +0100
Download (untitled) / with headers
text/plain 1.3k
Show quoted text
> 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.perl.org/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
Subject: Re: [perl #127881] [BUG] slow array slicing
From: Daniel Green <ddgreen [...] gmail.com>
To: perl6-bugs-followup [...] perl.org
Date: Wed, 13 Apr 2016 08:24:36 -0400
Download (untitled) / with headers
text/plain 1.6k
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:
Show quoted text
> 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.perl.org/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


Download (untitled) / with headers
text/plain 525b
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
Subject: home.desktop
Download home.desktop
application/x-desktop 800b

Message body not shown because it is not plain text.

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:
Show quoted text
> '@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




This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org