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 ;-).

Thanks

Ted


In reply to Troubles with getting NYTProf to work properly in a CGI program by ted.byers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.