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

Re: Does perl really need to use sigsetjmp? (18% performance hit)

Thread Previous | Thread Next
From:
nick
Date:
January 21, 2001 13:53
Subject:
Re: Does perl really need to use sigsetjmp? (18% performance hit)
Message ID:
E14KSNZ-0001IV-00@roam1
Dan Sugalski <dan@sidhe.org> writes:
>At 12:11 PM 1/21/01 +0000, Alan Burlison wrote:
>>Note that even if we used C++ it wouldn't help us in this case, because
>>although C++ does exceptions, it knows nothing about threads, mutexes or
>>CVs.  I suspect the perl6 interpreter loop will look something like:
>>
>>         while (! end of script) {
>>                 if (at cancellation point) {
>>                         if (signal detected)
>>                                 call script signal handler;
>>                         if (something died)
>>                                 rollback stack;
>>                 } else {
>>                         do next OP;
>>                 }
>>         }
>
>I'm waffling between checking between every op, or having an op that 
>explicitly checks. (Possibly the end-of-statement cleanup op would do this)

FWIW - current perl5.7.* development sources so the signal stuff every op.
i.e. we should have "safe signals" now.
(Which makes the sigsetjmp vs setjmp even less interesting as C level 
handler does neither.) 

>
>>In other words the C level signal handler will have to do no more than
>>setting a flag, as will the implementation of die().  

You need to explain the die case some more.
Consider:

    if (sv == NULL)
     {
      Perl_die("Something is not valid");
     }
    iv = SvIV(sv);

With the perl5 scheme the die longjmp()s away from the segfault.
So the implementation of "die" has to do more than set a flag.
It has to "noop" the code untill we reach a cancellation point.
It also has to save the "context" (file, line) and/or the "message".
It will end up looking like Tcl core... i.e. just about everything
returns not the value you wanted, but a flag to say whether it died
or not - I guess the flag could be in the "interpreter" data structure,
but you are still going to have to test it.


>>By cancellation
>>point I mean somewhere that is defined as 'safe', i.e. not holding any
>>mutexes or waiting on any CVs etc.

So what do we do if we die with a lock held?

-- 
Nick Ing-Simmons


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