http://qs1969.pair.com?node_id=11129023

chrestomanci has asked for the wisdom of the Perl Monks concerning the following question:

I am working on an legacy perl application that frequently invokes other perl scripts. The application runs as a server, and in response to each remote connection it does a fork and the child invokes another worker script via a system call. Most but not all of these scripts are perl.

There are about 500 perl scripts that could be run, and most are trivial. The volume of incoming connections is high, and the application has performance issues, which I suspect are in part caused by the overhead of invoking a fresh perl interpreter for each of these trivial scripts.

I searched online and found the do builtin in perl and this article about it.

Would it make sense to modify my application so that worker perl scripts are invoked via do() instead of system calls?

I am running perl 5.10 via Carton (The legacy app is not compatible with more recent perl versions due to use of Storable)

Would there be any issue with non-trivial perl scripts?

Do I need to wrapper the call to do() in an eval block or does that happen automatically?

Bear in mind that the caller of each worker script is a forked child from the main server process, so if the worker script goes wrong in some way such as leaking memory, the main server process is in the parent so should not be affected.

There are no security concerns here. All the code is trusted, and was written by company employees, so I only have to worry about mistakes, not malice.