The order of operations when it comes to speed optimization:

  1. Actually notice that there might be a performance issue.
  2. Profile to find where the issue is focused.
  3. Research the options with respect to algorithms that might improve upon the performance of the hotspots discovered in profiling.
  4. Benchmark the various algorithmic options.
  5. Implement the better algorithm.
  6. Test the implementation to ensure you haven't regressed in some way.
  7. If there's still an issue, repeat step 2.

If there's no better algorithm, then it's time to trim cycles (paraphrasing Tom Duff).

You mentioned CGI, and you are correct that many have discovered (probably through profiling) that the startup cost of CGI is high, particularly for short-running scripts (which CGI usually entails). This is one area where the profiling's been done again and again, there is a better algorithm, and the better algorithm is known. The better algorithm for that scenario is to eliminate the repeated start-ups. This can be done with something like mod-perl, or more modernly, through a persistent application framework that sits on top of a back-end like mod-perl, FastCGI, or some other persistent daemon. The modern frameworks such as Dancer, Catalyst, and Mojolicious attempt to do this (and much more).

To summarize, if you have determined that startup time is your foe, the effectiveness of the micro-optimization of trimming cycles from startup pales in comparison to the algorithmic optimization of moving the startup cost out of the individual request cycle by creating a persistent process.


Dave


In reply to Re: suggested module/tools to automatically "tighten" my perl by davido
in thread suggested module/tools to automatically "tighten" my perl by abcperl5

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.