|Keep It Simple, Stupid|
Troubles with getting NYTProf to work properly in a CGI programby ted.byers (Beadle)
|on Feb 21, 2013 at 22:16 UTC||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).
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:
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 ;-).