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

faster safe signals?

From:
Nicholas Clark
Date:
March 21, 2008 05:22
Subject:
faster safe signals?
Message ID:
20080321122153.GA25276@plum.flirble.org
chromatic generated this RT ticket for parrot:

On Tue, Mar 18, 2008 at 05:13:25PM -0700, Chromatic wrote:
> # New Ticket Created by  chromatic 
> # Please include the string:  [perl #51870]
> # in the subject line of all future correspondence about this issue. 
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=51870 >
> 
> 
> Currently, the concurrency and events system only handles pending events at 
> specific points, depending on runcore and opcodes.  (For example, when you 
> use the sleep opcode, when you enter a new predereferenced section, or when 
> you schedule a new event.)
> 
> We need to figure out exactly when, how, and how often to run our event loop 
> more frequently.

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();
    }

    TAINT_NOT;
    return 0;
}

where

# 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

1: At every LOGOP (so every loop iteration)
2: At scope exit
3: At scope entry (or just subroutine entry, given 1 and 2)
4: Before sleep and select
5: Before and after IO operations
6: (maybe also) every time the regexp engine backtracks

would Perl 5 be just as responsive at handling signals as it is currently, but
also faster in the general case?

Nicholas Clark



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About