Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Troubles with getting NYTProf to work properly in a CGI program

by ted.byers (Monk)
on Feb 21, 2013 at 22:16 UTC ( #1020012=perlquestion: print w/replies, xml ) Need Help??
ted.byers has asked for the wisdom of the Perl Monks concerning the following question:

To begin with, I have 'almost' learned how to get NYTProf used in a CGI program. I added the following to Apache's httpd.conf (this is the latest, 64 bit Apache on Windows, version Apache 2.4.3, or at least I believe it is the latest - I haven't checked in the past few months).

SetEnv PERL5OPT -d:NYTProf SetEnv NYTPROF=file=C:/Projects/CGI.tests/nytprof.out

Note, I tried the file name both with and without a trailing colon.

I do not know if the file name specified needs to be within Apache's directory tree, or if it can go into any convenient directory. The directory chosen is the one in which my client script resides, which passes a few hundred HTTP requests to the server to exercise the CGI script.

I believe NYTProf is trying to run, as I see certain messages in the error log related to it, but it produces no output files. Here are the messages (without the time stamps) I get related to NYTProf:

AH01215: Unknown NYTProf option: '' Warning: 193 subroutine calls had negative time! See TROUBLESHOOTING i +n the documentation. (Clock -1)

Now, checking the documentation, I see reference to a number of options for NYTProf, but I do not see any mention anywhere as to how to specify them for NYTProf within the context of a CGI process. For example, I see reference to specifying a format for NYTProf, using nytprofhtml, or, for the negative timing, I see, in the docs, "Try profiling with the slowops=N option set to 0 to disable the profiling of opcodes. Since opcodes often execute in a few microseconds they are a common cause of this warning." But, where do I specify that option?

Of course, the whole purpose of this exercise is to improve the performance of my CGI scripts. Now, when I look at industry data, the ten best, largest, providers of a similar service average a round trip: client to CGI on the server abd back (to complete a transaction) of 15 to 20 seconds, and my script presently falls in that range. However, the fastest of that ten routinely gets the round trip completed in 6 seconds. Obviously, therefore, I ought to be able to improve the performance of my CGI scripts further, by at least a factor of 2 (I already improved it's performance by 30%, and we obtained another improvement of 10% by throwing a more capable server at it; but in my view these gains are not good enough). I know I can, and should be able to, do better, as I am an old hand at optimizing my number crunching FORTRAN and C++ code.

My first problem to solve is, thus, how to actually get useful results out of NYTProf as without it, it would be easy to waste a lot of time making already fast functions twice as fast, but saving only microseconds, while missing the key bottlenecks. Thus, any advice on how to address this would be appreciated (as would, of course, advice on how optimizing Perl might be different from optimizing C++ or FORTRAN ;-).



Replies are listed 'Best First'.
Re: Troubles with getting NYTProf to work properly in a CGI program
by Anonymous Monk on Feb 22, 2013 at 00:24 UTC

      Thanks. That works fine with a script executed from a commandline, or within an environment like Emacs. However, even there, no variation I have tried lets me use "slowops=0". The documentation for Devel::NYTProf says to use slowops if some of the functions have negative timings, but I can not tell from the documentation where such an assignment is supposed to be set. From the behaviour I see, that seems to be a way to use NYTProf within a CGI script as an alternative to setting the configuration parameters I'd used in httpd.conf.

      Thus, the problem remains as to how to use slowops, and some of the other items I see in the documentation for NYTProf.



Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2016-09-26 18:18 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (488 votes). Check out past polls.