develooper Front page | perl.perl5.porters | Postings from October 2003

Re: perl's internal usage of dTHX; is a bad idea

Thread Previous | Thread Next
Nick Ing-Simmons
October 24, 2003 03:20
Re: perl's internal usage of dTHX; is a bad idea
Message ID:
Stas Bekman <> writes:
>Frankly I don't understand why internally Perl uses functions which aren't 
>prototyped with (pTHX_ ...), and call dTHX; instead. 

XS module API compatibility.

Most if API _does_ pass aTHX (usually via a macro).
An up-to-date list of those that don't would be welcome, there 
may now be few enough to replicate those and lead XS writers in 
that direction.

>Besides forcing on the 
>application the overhead of calling PERL_SET_CONTEXT() every few millisecs in 
>the env with multiple perl instances, any application always has an overhead 
>of retrieving PERL_GET_CONTEXT. A good example of such a function is: 
>Perl_safesysmalloc, which is called very often. There should be an alternative 
>function which accepts the context as an argument, when it's available (which 
>is true in most cases in perl guts).
>Ideally Perl internals shouldn't rely on the user to call PERL_SET_CONTEXT() 
>and call it by itself only when needed. But I realize that it doesn't always 
>work, e.g. when a redefined malloc is called by other parts of the non-perl 
>I was told that calls to PERL_SET_CONTEXT/PERL_GET_CONTEXT are especially 
>expensive in the multithreaded environment, because of the thread local 
>storage management overhead. I would be interested to hear more about this 
>from the threads experts.
>I wonder whether someone has benchmarked that overhead in the threaded 
>Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
>     mod_perl Guide --->

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About