logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Devel::NYTProf::Apache - Profile mod_perl applications with Devel::NYTProf

Author

AdamKaplan,  "<akaplan  at nytimes.com>" TimBunce, <http://blog.timbunce.org> StevePeters, "<steve at
       fisharerojo.org>"

Caution

       Use of "Devel::NYTProf::Apache" is officially discouraged.

       The "Apache" module is not exercised anywhere in Devel-NYTProf's test suite.  To do so would require an
       Apache/mod_perl environment, which in turn would require a major redirection of developer efforts.  The
       code may be perfectly sound -- so we're not officially deprecating it -- but it was last modified in
       2010.

       If ...

       1.  You are an experienced user of Devel-NYTProf;

       2.  you can set up a development/testing environment with Apache/mod_perl;

       3.  can devise some tests that would demonstrate that Devel::NYTProf::Apache works as intended; and

       4.  would be willing to support it as an independent CPAN distribution, then please let us know!

Description

       This module allows mod_perl applications to be profiled using "Devel::NYTProf".

       If  the  NYTPROF  environment  variable  isn't  set  atthetimeDevel::NYTProf::Apacheisloaded then
       Devel::NYTProf::Apache will issue a warning and default it to:

         file=/tmp/nytprof.$$.out:addpid=1:endatexit=1

       The file actually created by NTProf will also have the process id appended to  it  because  the  "addpid"
       option is enabled by default.

       See  "ENVIRONMENT  VARIABLES"  in  Devel::NYTProf  for  more  details  on  the  settings effected by this
       environment variable.

       Try using "PerlPassEnv" in your httpd.conf if you can set the NYTPROF  environment  variable  externally.
       Note  that  if  you  set  the  NYTPROF environment variable externally then the file name obviously can't
       include the parent process id. For example, to set stmts=0 externally, use:

           NYTPROF=file=/tmp/nytprof.out:out:addpid=1:endatexit=1:stmts=0

       Each profiled mod_perl process will need to have terminated cleanly before you can successfully read  the
       profile data file. The simplest approach is to start the httpd, make some requests (e.g., 100 of the same
       request), then stop it and process the profile data.

       Alternatively you could send a TERM signal to the httpd worker process to terminate that one process. The
       parent httpd process will start up another one for you ready for more profiling.

   Examplehttpd.conf
       It's  usually  a  good idea to use just one child process when profiling, which you can do by setting the
       "MaxClients" to 1 in httpd.conf.

       Set "MaxRequestsPerChild" to 0 to avoid worker processes exiting and  restarting  during  the  profiling,
       which would split the profile data across multiple files.

       Using  an "IfDefine" blocks lets you leave the profile configuration in place and enable it whenever it's
       needed by adding "-D NYTPROF" to the httpd startup command line.

         <IfDefine NYTPROF>
             MaxClients 1
             MaxRequestsPerChild 0
             PerlModule Devel::NYTProf::Apache
         </IfDefine>

       With that configuration you should get two profile files, one for the parent  process  and  one  for  the
       worker.

Limitations

       Profiling mod_perl on Windows is not supported because NYTProf currently doesn't support threads.

Name

       Devel::NYTProf::Apache - Profile mod_perl applications with Devel::NYTProf

See Also

       Devel::NYTProf

Synopsis

         # in your Apache config file with mod_perl installed
         PerlPassEnv NYTPROF
         PerlModule Devel::NYTProf::Apache

       If you're using virtual hosts with "PerlOptions" that include either "+Parent" or "+Clone" then see
       "VIRTUAL HOSTS" below.

Troubleshooting

       Truncated profile: Profiles for large applications  can  take  a  while  to  write  to  the  disk.  Allow
       sufficient  time  after  stopping apache, or check the process has actually exited, before trying to read
       the profile.

       Truncated profile: The mod_perl child_terminate() function terminates the child without  giving  perl  an
       opportunity  to  cleanup. Since "Devel::NYTProf::Apache" doesn't intercept the mod_perl child_terminate()
       function (yet) the profile will be corrupted if it's called. You're most likely to  encounter  this  when
       using Apache::SizeLimit, so you may want to disable it while profiling.

Virtual Hosts

       If  your  httpd  configuration includes virtual hosts with "PerlOptions" that include either "+Parent" or
       "+Clone" then mod_perl2 will create a new perl interpreter to handle  requests  for  that  virtual  host.
       This causes some issues for profiling.

       If  "Devel::NYTProf::Apache"  is loaded in the top-level configuration then activity in any virtual hosts
       that use their own perl interpreter won't be profiled. Normal virtual hosts will be profiled just fine.

       You  can  profile  a  single  virtual  host   that   uses   its   own   perl   interpreter   by   loading
       "Devel::NYTProf::Apache"  insidetheconfigurationforthatvirtualhost.  In  this case donot use
       "PerlModule" directive. You need to use a "Perl" directive instead, like this:

           <VirtualHost *:1234>
               ...
               <Perl> use Devel::NYTProf::Apache; </Perl>
               ...
           </VirtualHost>

See Also