perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Vanasco <modperl-l...@2xlp.com>
Subject debugging tip
Date Mon, 14 Aug 2006 20:23:17 GMT

i've been going crazy trying to abstract my shared libraries into  
something where the debug code is manageable and reusable without  
hacking at the library.  my problem was that I made too much use of  
how perl optimizes away debug code if you use constants

	i had tons of
	
	DEBUG && print STDERR 'info'

i tried doing some stuff like i saw in other packages like this
	
	our $Debug=0;

and then flipping it in the code that uses it.

that doesn't allow for perl to optimize stuff away.

entering captain obvious mode, i realized

	use constant DEBUG_CONNECT= $ENV{'P2XLP_DEBUG_CONNECT'}

i've now seen a 70% reduction in memory on my workhorse libraries  
(forms, databse, etc ), which is huge.

going from 800k compiled to 140k is a giant memory saver.

its not as extensible as some of the other debug options, where you  
get to change stuff on live code.

but i realized that for mod_perl stuff- restarting on a shared  
environment with a new env is a hassle worth the performance tradeoff.

just a tip to anyone else out there who didn't realize this.


Mime
View raw message