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

Autoincrement much slower in sink context #6026

Closed
p6rt opened this issue Jan 21, 2017 · 5 comments
Closed

Autoincrement much slower in sink context #6026

p6rt opened this issue Jan 21, 2017 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 21, 2017

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

Searchable as RT130615$

@p6rt
Copy link
Author

p6rt commented Jan 21, 2017

From alex6k@yahoo.com

m​: my int $i = 0; while $i < 10_000_000 {  $i++ }; say now - INIT now;rakudo-moar 7f245f​: OUTPUT«5.1848902␤»
m​: my (int $i, int $nosink) = 0, 0; while $i < 10_000_000 {  $nosink = $i++ }; say now - INIT now;rakudo-moar 7f245f​: OUTPUT«0.0816566␤»

@p6rt
Copy link
Author

p6rt commented Jan 22, 2017

From @zoffixznet

On Sat, 21 Jan 2017 13​:52​:37 -0800, alex6k@​yahoo.com wrote​:

m​: my int $i = 0; while $i < 10_000_000 {  $i++ }; say now - INIT
now;rakudo-moar 7f245f​: OUTPUT«5.1848902␤»
m​: my (int $i, int $nosink) = 0, 0; while $i < 10_000_000 {  $nosink =
$i++ }; say now - INIT now;rakudo-moar 7f245f​: OUTPUT«0.0816566␤»

More accurately​: it's much faster when not sunk, as it gets optimized. Turn off the optimizer and the difference vanishes​:

zoffix@​VirtualBox​:~$ perl6 -e 'my int $i = 0; while $i < 200_000 { $ = $i++; $ = 42 }; say now - INIT now;'
0.05608007
zoffix@​VirtualBox​:~$ perl6 -e 'my int $i = 0; while $i < 200_000 { $i++; $ = 42 }; say now - INIT now;'
0.1869925
zoffix@​VirtualBox​:~$ perl6 --optimize=off -e 'my int $i = 0; while $i < 200_000 { $ = $i++; $ = 42 }; say now - INIT now;'
0.2641866
zoffix@​VirtualBox​:~$ perl6 --optimize=off -e 'my int $i = 0; while $i < 200_000 { $i++; $ = 42 }; say now - INIT now;'
0.2896187

@p6rt
Copy link
Author

p6rt commented Jan 22, 2017

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

@p6rt
Copy link
Author

p6rt commented Jan 31, 2017

From @jnthn

On Sat, 21 Jan 2017 13​:52​:37 -0800, alex6k@​yahoo.com wrote​:

m​: my int $i = 0; while $i < 10_000_000 {  $i++ }; say now - INIT
now;rakudo-moar 7f245f​: OUTPUT«5.1848902␤»
m​: my (int $i, int $nosink) = 0, 0; while $i < 10_000_000 {  $nosink =
$i++ }; say now - INIT now;rakudo-moar 7f245f​: OUTPUT«0.0816566␤»

The static inlining of the ++ operator was failing to take place in sink context. Fixed that, and now the first example is faster, as you'd expect​:

jnthn@​lviv​:~/dev/rakudo$ ./perl6-m -e 'my int $i = 0; while $i < 10_000_000 { $i++ }; say now - INIT now;'
0.06727072
jnthn@​lviv​:~/dev/rakudo$ ./perl6-m -e 'my (int $i, int $nosink) = 0, 0; while $i < 10_000_000 { $nosink = $i++ }; say now - INIT now;'
0.0737980

/jnthn

@p6rt p6rt closed this as completed Jan 31, 2017
@p6rt
Copy link
Author

p6rt commented Jan 31, 2017

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

@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