robins has asked for the wisdom of the Perl Monks concerning the following question:

I've been scouring all the various documentation on how to get code profiling working under mod_perl2. I've setup everything so that Apache::Dprof runs and I get my tmon.out file.

But when I run them through dprofpp there is only one function call reported, and this is APR::Pool. If I look directly at the tmon.out file, there is just one line there, so the problem is not dprofpp, it's the reporting application.

I'm using the stock mod_perl2 installation on Ubuntu 6.06. Is my mod_perl2 missing some bells to report properly, or am I barking up the completely wrong tree?

  • Comment on Apache::DProf works under mod_perl, but only show one method called (APR::Pool)

Replies are listed 'Best First'.
Re: Apache::DProf works under mod_perl, but only show one method called (APR::Pool)
by clinton (Priest) on Jun 23, 2007 at 07:47 UTC
    I've just tried it out on my linux x86_64 system with mod_perl 2.03 and apache 2.2.4 using a preforked MPM, and it works fine. You need to do the following:

    • Install the latest Apache::DProf
    • Make sure your mod_perl is version >=2
    • Make sure that mod_perl has PerlChildInitHandlers enabled - for a stock install, I'm sure this would be the case
    • Create the dir logs/dprof and make it writable by the user apache runs under
    • Add PerlModule Apache::DProf into your httpd.conf file, or make it the first module loaded in your startup.pl file
    • apachectl start should create a number of dirs under logs/dprof named after the process ID of each apache child, with a tmon.out file in each directory - I'm using
    • Run a few requests that involve your mod_perl code
    • Shut down the server - nothing will be written to the tmon.out files until the server shuts down (or the buffer fills up)

    That's the process I followed, and it works. If this isn't working for you, then give us some more details of your apache, mod_perl and how you configured Apache::DProf.

    Things to think about:

    • Are you actually hitting mod_perl code?
    • Are you looking at all the tmon.out files, because if you have 5 children, and make a few requests, they may all go to just one child, and so the profiling will be written to just one of the five tmon.out files.
    • Are you using the preforked MPM or the threaded MPM? I don't know if it will make any difference, but threads and mod_perl can present problems that we don't normally see. It SHOULD work, but I haven't tried it.
    • Are you loading Apache::DProf before any other modules? It doesn't mention it in the docs, and seems to work for me either way, but try it

    Clint

      I was using the worker MPM, and this was the culprit. Changed to prefork MPM, and suddenly my tmon.out files have some content.

      Thanks a bunch for the suggestion!

Re: Apache::DProf works under mod_perl, but only show one method called (APR::Pool)
by perrin (Chancellor) on Jun 23, 2007 at 15:12 UTC
    Sounds like you're loading your code in startup before you load the debugger. Try putting this in httpd.conf before any other perl stuff:
    <Perl> use APR::Pool (); use Apache::DB (); Apache::DB->init(); </Perl>

      This did not help in any way. My files was just as empty.

      As I mentioned to Clint the worker (threaded) MPM was the culprit.

      On a sidenote: Should this be filed as a bug on Apache::DProf, the fact that it doesn't work in a threaded environment?

        Sorry, it didn't occur to me that you might be using threads on a non-Windows platform. You may want to reconsider that. The prefork model has better performance and uses a lot less memory on Linux than the threaded one.
        Should this be filed as a bug on Apache::DProf
        I would say yes. There is nothing in the docs or open bugs for either Apache::DProf or Devel::DProf which indicates that it shouldn't work with threads.

        Clint