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

branch prediction hints (was: faster safe signals?)

Thread Previous | Thread Next
Tim Bunce
March 21, 2008 18:25
branch prediction hints (was: faster safe signals?)
Message ID:
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))) {
>     }
> # 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)


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

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About