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

.race makes code run 5 times slower #5084

Closed
p6rt opened this issue Jan 25, 2016 · 6 comments
Closed

.race makes code run 5 times slower #5084

p6rt opened this issue Jan 25, 2016 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 25, 2016

Migrated from rt.perl.org#127364 (status was 'rejected')

Searchable as RT127364$

@p6rt
Copy link
Author

p6rt commented Jan 25, 2016

From @zoffixznet

I was playing around and noticed that using .race makes this code actually run 5 times SLOWER. This a 2-core machine, so my expectations were the code would run 0%-100% FASTER than .race-less version.

The produced results are consistent. Here's the normal version​:

$ perl6 -e '.base​: 16 for ^100000; say now - INIT now'
2.33417984

And here's the .race version​:
$ perl6 -e '.base​: 16 for ^100000 .race; say now - INIT now'
10.3816176

@p6rt
Copy link
Author

p6rt commented Jan 25, 2016

From @zoffixznet

See also a possibly-related RT#​127365 with .hyper method, where slowness also appears, but only sporadically​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127365

@p6rt
Copy link
Author

p6rt commented Jan 26, 2016

From @moritz

Hi,

On Mon Jan 25 09​:10​:18 2016, cpan@​zoffix.com wrote​:

I was playing around and noticed that using .race makes this code
actually run 5 times SLOWER. This a 2-core machine, so my expectations
were the code would run 0%-100% FASTER than .race-less version.

Since parallelization carries its own overhead, I'm not sure this expectation is justified. IMHO it's only justified if you do heavy lifting in each iteration (either CPU or IO), and so you can expect the overhead to small in comparison.

The produced results are consistent. Here's the normal version​:

$ perl6 -e '.base​: 16 for ^100000; say now - INIT now'
2.33417984

And here's the .race version​:
$ perl6 -e '.base​: 16 for ^100000 .race; say now - INIT now'
10.3816176

.base​: 16 certain doesn't qualify as computational heavy.

Ig might be interesting to see where .hyper spends its time, but I disagree that it being slower than the serial version is bug.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jan 26, 2016

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

@p6rt
Copy link
Author

p6rt commented Jan 26, 2016

From @zoffixznet

On Tue Jan 26 00​:11​:01 2016, moritz wrote​:

Since parallelization carries its own overhead, I'm not sure this
expectation is justified. IMHO it's only justified if you do heavy
lifting in each iteration (either CPU or IO), and so you can expect
the overhead to small in comparison.

I should've remembered to test with :batch in my OP, but even if I split the operation into 4 batches, it comes out 2.2 times SLOWER than non-paraller version. Surely 250,000 calls to .base would classify as heavy lifting. This is on a 4-core box​:

zoffix@​ZofMain​:~$ perl6 -e '.base​: 16 for ^1_000_000; say now - INIT now'
6.1851868
zoffix@​ZofMain​:~$ perl6 -e '.base​: 16 for ^1_000_000 .race​: :250000batch; say now - INIT now'
13.6450290
zoffix@​ZofMain​:~$ perl6 -e '.base​: 16 for ^1_000_000 .race​: :250000batch :4degree; say now - INIT now'
13.7348898
zoffix@​ZofMain​:~$ perl6 -v
This is Rakudo version 2015.12-23-ga7ea8e6 built on MoarVM version 2015.12
implementing Perl 6.c.

@p6rt
Copy link
Author

p6rt commented Apr 26, 2017

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

@p6rt p6rt closed this as completed Apr 26, 2017
@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