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

Compile option to disable taint mode: speedup

Thread Next
Steffen Mueller
October 9, 2012 09:29
Compile option to disable taint mode: speedup
Message ID:
Dear all,

After reading Reini's blog post, I spent a commute on adding a compile 
flag (-DNO_TAINT_SUPPORT) that replaces virtually all taint-related 
operations with no-ops. It's in a branch on camel at smueller/no_taint 
and can't go to blead quite as-is.

The upshot is that a the basic script that I had used for profiling 
function call overhead now runs somewhere around 10-20% faster. Just 
compiling normally, I saw on the order of 18%. With Nicholas' set of 
"let's try to avoid alignment issues"[1] flags, I still see 12%. It's a 
micro-benchmark, so don't assign too much meaning. Either way, it's 
*known* to shed instructions.

I would NOT want this to be the default behaviour, but having this an 
option could be a boon to people like my employer, who run Perl on 
thousands of machines and capacity is as important as latency. (Thus the 
eternal "you spend more time waiting for IO" doesn't apply.)

I would love some review of the changes to the effect of what you think 
needs doing in order to get this into blead. Just to reiterate: This 
would be an opt-in perl.o-compile-time option to disable taint support 
in the perl binary.

This is what I think needs doing still:
- PL_taint_warn would likely deserve the same treatment as
   PL_taint and PL_tainted.
- Obviously, tests fail. We have tests for -t/-T
   So we'd need a way from Perl to check for whether or not we have
   taint support and skipping the tests.
- Right now, I added a Perl warn() on startup when -t/-T are detected
   but the perl was not compiled support it. It might be argued that it
   should be silently ignored! Needs some thinking. You could argue
   that perl should just throw an exception on -T/-t without support for
   it. For the tests, it would be kind of convenient to be able to just
   silently ignore -t/-T and then skip running the tests.
- Code quality concerns of my patch - it just needs review.
- Configure support required. Merijn, Andy, could you help me with this?
- Needs thinking: How does this tie in with CPAN XS modules that use
   PL_taint and friends? It's easy to backport the new macros via PPPort,
   but that doesn't magically change all code out there. Might be
   harmless, though, because whenever you're running under
   NO_TAINT_SUPPORT, any check of PL_taint/etc is going to come up false.
   Thus, the only CPAN code that SHOULD be adversely affected is code
   that changes taint state.

Any more sophisticated commetns than Reini's "10% don't matter"?

Best regards,

[1] -g -O2 -falign-loops=8 -falign-jumps=8 -falign-functions=64 
-falign-labels=8 -mpreferred-stack-boundary=8 -minline-all-stringops

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