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

Re: [PATCH] Callbacks to core, with benchmarks

Thread Previous | Thread Next
From:
Paul Johnson
Date:
August 22, 2001 08:55
Subject:
Re: [PATCH] Callbacks to core, with benchmarks
Message ID:
20010822175540.R12169@pjcj.net
On Wed, Aug 22, 2001 at 09:28:59AM -0500, David M. Lloyd wrote:
> I have benchmarked the effects of callbacks on performance, by timing
> execution of this expression:
> 
> for $x (1..10000000) {}
> 
> with and without a callback enabled.
> 
> All tests used Perl 5.7.2 11722 on RedHat Linux 7.0, on a PIII-800 MHz and
> were run 5 times, with the average times going into the results here.
> 
> (1) Perl without callback patch:
> 
> real: 3.9774 seconds
> user: 3.8360 seconds
> sys:  0.0160 seconds
> 
> (2) Perl with callback patch, but no callbacks enabled:
> 
> real: 4.0304 seconds
> user: 3.9940 seconds
> sys:  0.0100 seconds
> 
> (3) Perl with callback patch, and one callback enabled
>   NOTE: callback is: void cb(pTHX_ void * data) {})
>   NOTE: includes one module load + 4 XS function calls
> 
> real: 5.8074 seconds
> user: 5.7700 seconds
> sys:  0.0120 seconds

So that's about 45% overhead for calling an empty function per op.  If I
add a guarded empty function call to a pluggable runops I see about 6%
overhead.  Inlining the function (ie just the guard) gives about 1%
overhead.  These are all very rough figures, but you get the idea.

Unless this callback overhead can be reduced, I would probably stay with
a pluggable runops, at least by default, for Devel::Cover, which would
be a shame.

Of course, the benchmark is not particularly representative, but the
figures are probably close enough to show a bit of a problem.

Is there any way the speed can be improved when there is a callback?

-- 
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

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