develooper Front page | perl.perl5.porters | Postings from January 2001

Re: 2% speedup with Duff's device

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
January 23, 2001 08:10
Subject:
Re: 2% speedup with Duff's device
Message ID:
20010123161013.B72556@plum.flirble.org
On Tue, Jan 23, 2001 at 01:02:42PM +0000, Nick Ing-Simmons wrote:
> Nicholas Clark <nick@ccl4.org> writes:
> >If one uses Duff's device in PERL_HASH, the regression tests go about 2%
> >faster.

> >Without:
> >
> >All tests successful.
> >u=1.33  s=0.46  cu=62.27  cs=10.54  scripts=273  tests=21120
> >
> >real    2m16.388s
> >user    1m3.610s
> >sys     0m11.000s
> >
> >With:
> >
> >All tests successful.
> >u=1.4  s=0.32  cu=59.86  cs=10.71  scripts=273  tests=21120
> >
> >real    2m11.748s
> >user    1m1.260s
> >sys     0m11.030s
> >
> >
> >perl gets about .25% bigger:
> >
> >-rwxrwxr-x    1 nick     1001       785667 Jan 20 15:36 bleadperl/perl
> >-rwxrwxr-x    1 nick     1001       787683 Jan 23 11:51 bleadperl-duff/perl

> Would be interesting to see what inline costs in speed/size. 
> Can you experiment with putting the "snazzy" hash in a _real_ function 
> (in pp_hot.c or perhaps hv.c) and making PERL_HASH call that?

The 1 at a time loop in a function Perl_hash at the end of pp_hot.c:

All tests successful.
u=1.54  s=0.37  cu=63.85  cs=10.94  scripts=273  tests=21120

real    2m13.488s
user    1m5.390s
sys     0m11.310s

The 8 fold Duff's device in that function:

All tests successful.
u=1.33  s=0.4  cu=62.43  cs=10.69  scripts=273  tests=21120

real    2m8.974s
user    1m3.760s
sys     0m11.090s

I delete the previous binary before I thought to measure the size, but the
8 fold is:

-rwxrwxr-x    1 nick     1001       785501 Jan 23 15:50 perl


Hmm. Calling an optimised hash function is about as fast as in-lining a
simple one.

Nicholas Clark

Thread Previous | 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