[Melbourne-pm] An old one but an important one

leif.eriksen at hpa.com.au leif.eriksen at hpa.com.au
Sun Jan 20 14:43:04 PST 2008


I wonder  if there's a way to hook into $& and family, to see stack
traces where they are used ? Being global, can you tie them to something
useful ?

L 

> -----Original Message-----
> From: melbourne-pm-bounces+leif.eriksen=hpa.com.au at pm.org 
> [mailto:melbourne-pm-bounces+leif.eriksen=hpa.com.au at pm.org] 
> On Behalf Of Scott Penrose
> Sent: Saturday, 19 January 2008 10:51 AM
> To: Melbourne Perlmongers
> Subject: [Melbourne-pm] An old one but an important one
> 
> Hey Dudes,
> 
> I was fixing a performance problem with our portal. It was taking 2 or
> 3 minutes to render an HTML form. I narrowed it down to the 
> fact that this particular form had a 500K XML file to parse, 
> and it did it 10 times. If the duplicate parsing and size 
> wasn't bad enough, it was the hidden problem.
> 
> Making command line code that did EXACTLY the same thing (so I
> thought) it ran in sub 1 second. So what was going on.
> 
> After a full day of debugging I narrowed it down to one 
> module Filter::Simple, only it wasn't, it was Text::Balanced
> 
> And after even more work I found the real problem - "$&" 
> after a regular expression.
> 
> Yep - it is a known killer of regular expression performance, 
> but here is the actual differences:
> 
> (env53) vmwmi1:~/simple# time perl test_direct.pl
> 	Fake loop start - size 488604
> 	Fake loop end - for 21581
> 	real	0m26.586s
> 	user	0m9.305s
> 	sys	0m17.269s
> 
> (env53) vmwmi1:~/simple# time perl test_direct.pl
> 	Fake loop start - size 488604
> 	Fake loop end - for 21581
> 	real	0m0.131s
> 	user	0m0.112s
> 	sys	0m0.012s
> 
> Yep, even including compile time, and reading the file from 
> disk - the time goes from 0.012s to 26.58 second - that is 
> 2000 times slower !
> 
> So... take heed !
> 
> 	Don't use $&, $` or $'
> 
> But more importantly - check the modules you use on CPAN.
> 
> Scooter
> P.S. I have removed all uses in our code, and still it has a 
> problem, so I suspect there is yet another CPAN module using one.
> 
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm
> 
**********************************************************************
IMPORTANT
The contents of this e-mail and its attachments are confidential and intended
solely for the use of the individual or entity to whom they are addressed.  If
you received this e-mail in error, please notify the HPA Postmaster, postmaster at hpa.com.au,
then delete  the e-mail.
This footnote also confirms that this e-mail message has been swept for the
presence of computer viruses by Ironport. Before opening or using any
attachments, check them for viruses and defects.
Our liability is limited to resupplying any affected attachments.
HPA collects personal information to provide and market our services. For more
information about use, disclosure and access see our Privacy Policy at
www.hpa.com.au
**********************************************************************



More information about the Melbourne-pm mailing list