Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Perl startup and excessive "stat" use on module load

by NERDVANA (Deacon)
on Jan 04, 2021 at 00:39 UTC ( [id://11126252]=note: print w/replies, xml ) Need Help??


in reply to Perl startup and excessive "stat" use on module load

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.

  • Comment on Re: Perl startup and excessive "stat" use on module load

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11126252]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 23:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found