You might see a lot of “stat” but it would be really unusual if that was actually impacting your performance. In most cases, the actual time required for perl to compile those modules would vastly outweigh 12 calls to stat. The one exception to this that I’ve read about is if you use a docker container built from a ton of layers. In that case, each call to stat triggers one stat call for each layer of the filesystem, so 12 stat calls could actually be 1200 or something stupid like that. You can fix that problem by “flattening” the docker filesystem.

If you want a program that runs fast, write a daemon that stays running. If this is a web app, there are lots of pre-forking options to choose from. (the program loads once, then forks a copy for each worker, then the workload of incoming requests is divided among the workers) See Starman for example.

If you truly need to start new processes rapid-fire, then the only real way to get performance is to restrict your program to lightweight modules with as few dependencies as possible. For instance, avoid anything that uses Moose or DateTime or several dozen other popular and useful but heavyweight modules. You can of course also reduce the search path as described in other posts here, but I don’t think it’ll make a measurable difference.


In reply to Re: Perl startup and excessive "stat" use on module load by NERDVANA
in thread Perl startup and excessive "stat" use on module load by cherio

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.