develooper Front page | perl.perl5.porters | Postings from March 2008

branch prediction hints (was: faster safe signals?)

Thread Previous | Thread Next
From:
Tim Bunce
Date:
March 21, 2008 18:25
Subject:
branch prediction hints (was: faster safe signals?)
Message ID:
20080321205235.GA1769@timac.local
On Fri, Mar 21, 2008 at 12:21:53PM +0000, Nicholas Clark wrote:
> 
> It made me wonder. Currently the perl 5 runloop looks like this:
> 
> int
> Perl_runops_standard(pTHX)
> {
>     dVAR;
>     while ((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX))) {
> 	PERL_ASYNC_CHECK();
>     }
> 
> # 3 "PERL_ASYNC_CHECK expands to"
> if ((my_perl->Isig_pending)) Perl_despatch_signals(my_perl)
> 
> We do the check after every op. I wondered, if we did the check

I think there's more to gain by adding branch prediction to the code.
It seems the config side is done, so it's ready to use:

perl.h:#  define EXPECT(expr,val) __builtin_expect(expr,val)
perl.h:#  define EXPECT(expr,val)                  (expr)
perl.h:#define LIKELY(cond)                        EXPECT(cond,1)
perl.h:#define UNLIKELY(cond)                      EXPECT(cond,0)

Tim.

p.s. I think they'd look much less noisy in the code if they were in lowercase.

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