develooper Front page | perl.perl5.porters | Postings from May 2010

Re: [PATCH] shift; optimization

Thread Previous | Thread Next
From:
Reini Urban
Date:
May 4, 2010 13:58
Subject:
Re: [PATCH] shift; optimization
Message ID:
AANLkTimdQpVJbyeg_kexKxjBiFSnEBi-8x59zYuZ-C38@mail.gmail.com
2010/5/3 Jan Dubois <jand@activestate.com>:
> On Mon, 03 May 2010, Reini Urban wrote:
>> 2010/5/3 Ruslan Zakirov <ruz@bestpractical.com>:
>> > While testing a simple benchmark script I noticed that threaded
>> > version is 25% faster. I suspect that the code may be is not thread
>> > safe, however don't know anything about perl threads.
>>
>> This is because threaded passes the my_perl struct on the stack, PL_op
>> is just 4(%esi).
>
> Note that fox XS code this is only true if you
>
> #define PERL_NO_GET_CONTEXT
>
> Otherwise my_perl will actually be redefined to *Perl_get_context(),
> which will fetch the actual my_perl from thread-local storage, which
> will be really slow.
>
>> Accessing stack locals is much faster than accessing a global.
>
> So please make sure you define PERL_NO_GET_CONTEXT in your modules
> if you are an XS author.  It is not on by default for backwards
> compatibility reasons only.

FYI:
That's why I started working on
  http://github.com/rurban/perl/tree/local-op
to get this advantage for non-threaded and
#undef PERL_NO_GET_CONTEXT also.
-- 
Reini Urban
http://phpwiki.org/           http://murbreak.at/

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