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