Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

How to use Devel::NYTProf on Apache

by feumw (Novice)
on Mar 06, 2020 at 09:18 UTC ( #11113904=perlquestion: print w/replies, xml ) Need Help??

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

I installed Devel::NYTProf. I added
PerlSetEnv NYTPROF file=/tmp/nytprof.out <Perl> use Devel::NYTProf::Apache; </Perl>
into my vhost config and it seems to be loaded fine. I don't find a file at /tmp/nytprof.out instead i have a folder with subfolder and finally some nytprof.out files. My problem is: when I stop the apache everything is gone.

How do I now get an output file I can use with nytprofhtml to get the html view of my results?

Replies are listed 'Best First'.
Re: How to use Devel::NYTProf on Apache
by 1nickt (Abbot) on Mar 06, 2020 at 15:38 UTC

    Hi, I am not a profiling expert and ceased to be an Apache expert about 15 years ago, but I'm not sure your approach will work, depending on where in your stack you are calling it.

    From the doc on threaded/multiprocess programs:

    Devel::NYTProf is not currently thread safe or multiplicity safe. If you'd be interested in helping to fix that then please get in touch with us. Meanwhile, profiling is disabled when a thread is created, and NYTProf tries to ignore any activity from perl interpreters other than the first one that loaded it.

    ... but on the other hand, the doc for `endatexit` says:

    Sets the PERL_EXIT_DESTRUCT_END flag in the PL_exit_flags of the perl interpreter. This makes perl run END blocks in perl_destruct() instead of perl_run() which may help in cases, like Apache, where perl is embedded but perl_run() isn't called.

    I don't know why your output files are disappearing, but note that the default output location for the files is the current directory.

    Hope this helps!

    The way forward always starts with a minimal test.
      I once had a Teamviewer Session with someone who explained me how this works. Unfortunately bad habits lead me to not documenting it. I haven't placed any Flags/Markers in my Scripts to start/stop profiling. I want to profile a CMS and the last time we did this by starting the Webserver, doing a single click and stopping webserver after. With stopping the profiling ends aswell. I don't want to dive to deep. The last time I got a hint that 80% loading time was SQL so I could took a more detailed look on it. I have to see what I can do. Anyway, thank you, I will probably take a look on the docs again if I can't find an easy quick way to rudimentory profile the problems.
Re: How to use Devel::NYTProf on Apache
by bliako (Prior) on Mar 06, 2020 at 23:52 UTC
      I thought about changing the output directory aswell on Friday, and so did I. Now I have the files on a different spot and they won't dissappear when I stop the webserver. Now I have to see how/what can I do with them. Unfortunately nytprofhtml still doesn't work with those files:
      Reading nytprof.out Failed to open input 'nytprof.out': No such file or directory at /usr/ +local/lib64/perl5/Devel/NYTProf/ line 87.

        What is the actual invocation you are using? If the files look like nytprof.out.123 then you need to use the -f flag, e.g. nytprofhtml -f nytprof.out.123 . More details are at nytprofhtml.

        It is probably also worth looking at the Apache specific docs in Devel::NYTProf::Apache as it seems not to have been mentioned thus far. (I have never used it, though).

        There is also nytprofmerge if you have multiple output files and want to combine the results.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11113904]
Front-paged by haukex
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2020-10-29 22:39 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (274 votes). Check out past polls.