January 2011 Archives

mod_perl2 & Devel::NYTProf

This week I’ve been trying to switch us over to using mod_perl2. I wanted to cache database handles as much as possible so one of the first things that I did was edit my startup.pl and add:

use Apache::DBI;

Most stuff just works. When I find something that is only slightly broken, I fix it. When I find something that is horribly broken, I just create a Location in httpd.conf to tell Apache to run that as plain CGI and I’ll update them later.

The entire application suite feels faster. I suspect much of the speed up is due to caching database handles but I’d like to profile it. I have no problems profiling CGI with Devel::NYTProf. When I configure httpd.conf to use Devel::NYTProf::Apache like this I get issues.

PerlSetEnv NYTPROF trace=2:file=/tmp/mm-nytprof.out:addpid=1:start=begin:use_db_sub=1
PerlModule Devel::NYTProf::Apache

I guess I’ll have to file a bug report. Here is just one of the many issues showing up in the error log:

Marking 'Apache2::RequestRec::args' as xsub
Marking 'CGI::Cookie::CORE:subst' as sop
Marking 'CGI::Cookie::CORE:substcont' as sop
NYTProf is confused about CV 0x2ac1ed3023e0 called as /opt/perl/lib/site_perl/5.12.3/x86_64-linux-thread-multi/ModPerl/RegistryCooker.pm at /opt/perl/lib/site_perl/5.12.3/x86_64-linux-thread-multi/ModPerl/RegistryCooker.pm line 225 (please report as a bug)
SV = PVCV(0x2ac1ed2b49d0) at 0x2ac1ed3023e0
  REFCNT = 2
  FLAGS = (POK,pPOK,CONST)
  PROTOTYPE = ""
  COMP_STASH = 0x2ac1ed240ad0   "ModPerl::RegistryCooker"
  XSUB = 0x2ac1d2d845b0
  XSUBANY = 0x2ac1ed2d0da8 (CONST SV)
    SV = IV(0x2ac1ed2d0da0) at 0x2ac1ed2d0da8
      REFCNT = 2
      FLAGS = (PADMY,IOK,READONLY,pIOK)
      IV = 0
  GVGV::GV = 0x2ac1ed2d2910     ""
  FILE = "/opt/perl/lib/site_perl/5.12.3/x86_64-linux-thread-multi/ModPerl/RegistryCooker.pm"
  DEPTH = 0
  FLAGS = 0xc00
  OUTSIDE_SEQ = 0
  PADLIST = 0x0
  OUTSIDE = 0x0 (null)
unknown entersub xsub assumed to be anon called_cv '/opt/perl/lib/site_perl/5.12.3/x86_64-linux-thread-multi/ModPerl/RegistryCooker.pm'

Is there a way to tell Devel::NYTProf not to profile ModPerl::RegistryCooker?

TAP

A recent push at work has been to use TAP everywhere that we need to test something. It's great for a variety of reasons.

  • We are finally trying to test as much as possible.
  • All of the myriad pieces of software, written in a variety of languages, can use the same text-based interface.
  • Anyone in the group can look at the output and understand it.
  • The test results can be read by a single process that parses and displays the results in a uniform fashion.

It's very refreshing …

About Mr. Muskrat

user-pic I'm married with 2 girls. By day, I work as a Senior Design Engineer (full time Perl programmer) for EFJohnson Technologies, a Land Mobile Radio company, in the Dallas/Fort Worth area. By night, I play various games as the mood strikes me. (Lately it's CPAN smoke testing.)