Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Devel::NYTProf on program that fork/execs

First I export PERL5OPT=-d:NYTProf from the command line so that my debugging option will be inherited by child processes. Then I launch my Perl program contactd. It forks to become a daemon process, and then fork/execs nine instances of another Perl program, table_manager. (The exec looks something like exec /path/to/perl /path/to/table_manager.) At this point I can see 10 or 11 new files called nytprof.out.nnnn; one for each process that has been forked up til now, as expected.

Clients connect to contactd which fork/execs slave, which in turn connects to the nine table managers and accepts requests from the client and passes them to the nine table managers.

After running a typical client connection, I shut down all the server processes. I run nytprofmerge to merge the various nytprof.out.nnnn files into nytprof-merged.out, and then run nytprofhtml -f nytprof-merged.out --open.

When the HTML report opens, I see no mention of anything but contactd. The top subroutines are mostly BEGIN blocks, import, AUTOLOAD ... early execution stuff.

This leads me to think that NYTPROF is going across a fork (based on the multiple nytprof.out files) but for some reason is not continuing to profile the exec'ed Perl programs.

I'm running perl 5.16.1 and the latest Devel::NYTProf, in MacOSX 10.8.2.

Any suggestions as to what I've not done?

like image 734
Chap Avatar asked Oct 21 '22 16:10

Chap


1 Answers

You could set fork depth variable to -1:

http://search.cpan.org/~timb/Devel-NYTProf-4.25/lib/Devel/NYTProf.pm#forkdepth=N

forkdepth=N

When a perl process that is being profiled executes a fork() the child process is also profiled. The forkdepth option can be used to control this. If forkdepth is zero then profiling will be disabled in the child process.

If forkdepth is greater than zero then profiling will be enabled in the child process and the forkdepth value in that process is decremented by one.

If forkdepth is -1 (the default) then there's no limit on the number of generations of children that are profiled.

Regards,

like image 143
user1126070 Avatar answered Nov 15 '22 01:11

user1126070