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

I am looking for a way to profile a (fairly complex) Perl program and its child processes. This particular program starts up, launches a number of child process for different tasks and then does basic process automation to restart child processes that die unexpectedly.

I have been using Devel::DProf with some good results, however, it does not seem to carry across a fork -- which would coincide with other articles I've read regarding Perl's debugger and forking processes.

What are some recommendations for profiling a program that forks child processes?

  • Comment on Profiling a Perl program and its children

Replies are listed 'Best First'.
Re: Profiling a Perl program and its children
by wazzuteke (Hermit) on Apr 10, 2006 at 15:41 UTC
    If you're running a straight Perl application (not embedded within Apache/mod_perl), the only other thing I can think of is Devel::SmallProf. Although it is much more granular than Devel::DProf, if you claim it's not jumping processes than I would imagine the same fault would be in Devel::SmallProf. Although you may run into the same issue, it's (should be) a one-line change and worth checking out.

    This being said, if you are working within Apache/mod_perl, I have had great success with Devel::DProf and Apache::SmallProf. Also, if you are running Linux or any other pre-fork worker, I can all but guarentee the profiler will attach to each post-forked child in order to profile them individually.

    Other than that I think you may be out of luck... next to modifying DProf on your own :)

    ---hA||ta----
    print$_ for(map{chr($_)}split(/\s+/,join(/\B?:\w+[^\s+]/,<DATA>))); __DATA__ 67 111 100 101 32 80 101 114 108
Re: Profiling a Perl program and its children
by salva (Canon) on Apr 11, 2006 at 09:03 UTC
    AFAIK, my Devel::FastProf is the only Perl profiler that has support for forking scripts, but unfortunately, I have discovered it has a bug that causes it to malfunction on fast processors (basically, the units used to measure time internally are too big).

    I am going to try to solve the bug today.

    update: I have uploaded a new version of Devel::FastProf to CPAN with the bug corrected.