There is indeed a method cache issue.

Whenever you call a method, Perl has to figure out what that method is. While the search rules are clear, the search can be slow. So what Perl does is assumes that when you call a method once, you are likely to call it again, and so it stores in an internal hash the information about where the method is so that next time the lookup will be fast.

Unfortunately if you change any information which could change the lookup results, Perl has to throw away this cache and start over because it can no longer trust the answers. Normally this isn't much of a problem because people tend to use everything, define all of their functions, and then start calling methods (which builds the cache). So once you start running your code, your cache never gets thrown away again.

Unfortunately dynamic changing of functions at runtime (which is what autoloading them does) means that in the middle of running your code you are forced to throw away your cache. Do this repeatedly and you spend a lot of startup time building up bits of this cache only to throw it away again and start over.

If your process runs for a long time, or if you can arrange to preload everything that you are going to use up front, this is not an issue.


In reply to Re (tilly) 2: Require Load Times by tilly
in thread Require Load Times by Anonymous Monk

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.