develooper Front page | perl.perl5.porters | Postings from October 2012

sub signatures - performance

Thread Next
From:
Peter Martini
Date:
October 19, 2012 19:59
Subject:
sub signatures - performance
Message ID:
CAFyW6MRzFia4wSouebRMuXX3ihvrfkayAbf7aRQ7y1HnrNrhiQ@mail.gmail.com
Okay, so I think my sub signatures work is ready for testing. Still plenty
to talk about, but at least its real code now, not just theory. All my
tests - at t/comp/namedproto.t - pass (except for one that Doy added, and
I'm not quite sure what it's testing?)

If anyone wants to help, just trying to run it and complaining to me when
something breaks is very helpful :-)

The code is at https://github.com/PeterMartini/perl, and the branch is
peter/signatures.

I'm going to send a second email with a more detailed status/design report;
right now, I'll just list some performance numbers.

Unmodified blead, as of a couple of days ago (-Dusedevel -DDEBUGGING
-Dusethreads -des):

dumbbench -p 0.005 -- ./perl -e 'sub foo{} foo() for 1 .. 1_000_000'
cmd: Ran 21 iterations (1 outliers).
cmd: Rounded run time per iteration: 4.0581e-01 +/- 8.9e-04 (0.2%)

With my patches, rebased onto that blead (-Dusedevel -DDEBUGGING
-Dusethreads -des):

dumbbench -p 0.005 -- ./perl -e 'sub foo{} foo() for 1 .. 1_000_000'
cmd: Ran 23 iterations (3 outliers).
cmd: Rounded run time per iteration: 4.0092e-01 +/- 2.4e-04 (0.1%)

So, no real difference if you're not using the feature.

Now, same baseline unmodified blead:

*Two lexical variables, with nothing passed:*
dumbbench -p 0.005 -- ./perl -e 'sub foo{my ($foo,$bar) = @_;} foo() for 1
.. 1_000_000'
cmd: Ran 20 iterations (0 outliers).
cmd: Rounded run time per iteration: 7.824e-01 +/- 1.7e-03 (0.2%)

*Two lexical variables, and actual copies:*
dumbbench -p 0.005 -- ./perl -e 'sub foo{my ($foo,$bar) = @_;}
foo("blah","blah") for 1 .. 1_000_000'
cmd: Ran 20 iterations (0 outliers).
cmd: Rounded run time per iteration: 9.591e-01 +/- 3.1e-03 (0.3%)

The numbers are similar with the patched version.

However, taking advantage of the new syntax:

*Two lexical variables, with nothing passed:*
dumbbench -p 0.005 -- ./perl -Ilib -Mfeature=experimental::sub_signature -e
'sub foo($foo,$bar){} foo() for 1 .. 1_000_000'
cmd: Ran 22 iterations (2 outliers).
cmd: Rounded run time per iteration: 4.2474e-01 +/- 9.2e-04 (0.2%)

*Two lexical variables, and actual copies:*
dumbbench -p 0.005 -- ./perl -Ilib -Mfeature=experimental::sub_signature -e
'sub foo($foo,$bar){} foo("blah","blah") for 1 ..  1_000_000'
cmd: Ran 23 iterations (3 outliers).
cmd: Rounded run time per iteration: 7.5809e-01 +/- 9.4e-04 (0.1%)

******

So, the signatures definitely look like a significant performance gain, if
you consider the cost of the assignment, and it is no performance loss if
you don't use the feature.

Of course, that's all for the code as I have it now, additional bug fixes
will certainly hurt those numbers :-)


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About