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

Re: Compile option to disable taint mode: speedup

Thread Previous | Thread Next
From:
Tim Bunce
Date:
October 10, 2012 05:56
Subject:
Re: Compile option to disable taint mode: speedup
Message ID:
20121010125617.GE1009@timac.local
On Wed, Oct 10, 2012 at 09:09:21AM +0200, Steffen Mueller wrote:
>
> [...] around 10-20% faster [...]

That seems surprising to me, given the change. Even for a micro-benchmark.

> Of those things, this is left:
> - Code review.
> - Test some CPAN against a SILENT_NO_TAINT_SUPPORT perl.
> - Configure support.
> - Review the remaining taint test failures of the core modules. Some
> fail for a reason because they check -T specifically, some should
> just be skipped if not ${^TAINT} since they test taint compatibility.

+ Gain a deeper understanding of where the costs/savings actually are.

Accessing an interpreter structure element should be very cheap.
Given the size of the struct perhaps there's some L1 cache thrashing.
In which case perhaps clustering together hot elements may help
reduce the cost of taint checking, and perhaps much else besides.

Also, while browsing around I noted that SvTAINTED(sv) is defined as
(SvMAGICAL(sv) && sv_tainted(sv)) and I wonder if that should include
a test for TAINTING_get before (or perhaps after) SvMAGICAL.

Perhaps there are unexpected costs elsewhere. Basically I'm saying that
digging deeper here may yield lessons that could be applied elsewhere.


+ Experiment with more static branch prediction.

I recall some previous experiments with using branch prediction hint
macros.  I think they weren't applied extensively enough to prove a
difference either way.  There are only 11 in the current code, most in
utf8.c, and none in headers.

Wrapping TAINT_get, TAINTING_get and SvTAINTED with UNLIKELY(...) may help:
#   define TAINT_get        UNLIKELY(PL_tainted)
at least for compilers that support __builtin_expect, i.e. GCC.
http://linuxkernelpanic.blogspot.ie/2010/06/using-static-branch-prediction-with-gcc.html


Tim.

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