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

Re: [PATCH] C Callbacks, try #3

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
August 25, 2001 08:13
Subject:
Re: [PATCH] C Callbacks, try #3
Message ID:
20010825151338.664.2@bactrian.ni-s.u-net.com
David M . Lloyd <dmlloyd@tds.net> writes:
>OK, here's my third attempt.
>Unpatched current perl (5.7.2 pl 11734):
>
>Real: 31.1656
>User: 31.1600
>Sys:   0.0040
>
>Patched current perl (5.7.2 pl 11734) no callbacks:
>
>Real: 33.3060
>User: 33.2880
>Sys:   0.0120
>
>Patched current perl (5.7.2 pl 11734) one empty callback:
>
>Real: 42.4894
>User: 41.9460
>Sys:   0.0180
>
>So just applying the patch causes a slowdown of about 7%, 

We need to explain that.

>and having one
>empty callback slows it down by 35%... big bummer.
>
>As far as the 7%, I suspect that the 'if' condition in my current
>PERL_ASYNC_CHECK() is not as optimizable as the old one, so it ends up
>being more instructions or something.
>
>By moving the body of the comparison in PERL_ASYNC_CHECK() into a
>function, the 7% disappears but the 35% increases significantly.
>
>I don't see how I can optimize the empty callback cost any further.  It's
>the function call itself that is slowing things down, as far as I can
>figure out.
>
>So, this is the question: Is 35% to large a price to pay for the ability
>for more than one function to overload runops?

7% is a heck of a lot to pay for a feature I am not using!
But I am surprised it changes that much.

Are PL_sig_pending vs PL_event_pending different classes of 
variable ?

> #ifndef PERL_MICRO
>-#   ifndef PERL_OLD_SIGNALS
>-#		ifndef PERL_ASYNC_CHECK
>-#			define PERL_ASYNC_CHECK() if (PL_sig_pending) despatch_signals()
>-#		endif
>-#   endif
>+#  ifndef PERL_OLD_SIGNALS
>+#    ifndef PERL_ASYNC_CHECK
>+#      define PERL_ASYNC_CHECK() \
>+    if (PL_event_pending) { \
>+	if (PL_sig_pending) despatch_signals(); \
>+	for (PL_callback_cur = PL_callbacks; PL_callback_cur < PL_callbacks_end; PL_callback_cur ++) \
>+    	    (*PL_callback_cur)(aTHX); \
>+    }
>+#    endif
>+#  endif
> #endif
>
>
>-PERLVAR(Isavebegin,     bool)	/* save BEGINs for compiler	*/
>+PERLVAR(Isavebegin,     bool)	    	/* save BEGINs for compiler	*/
>+PERLVAR(Icallbacks_end, CALLBACK_t*)	/* first unused callback */
>+PERLVAR(Ievent_pending, int)	    	/* event-pending flag */
>+PERLVAR(Icallbacks, 	CALLBACK_t*)	/* The callbacks themselves */
>+PERLVAR(Icallbacks_size,IV) 	    	/* Size of callbacks array */
>+PERLVAR(Icallback_cur,	CALLBACK_t*)	/* Current callback being run */
>
> /* New variables must be added to the very end for binary compatibility.
>  * XSUB.h provides wrapper functions via perlapi.h that make this
-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/


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