On Tue, Sep 12, 2006 at 08:19:34PM +0300, Sagiv Barhoom wrote:
> Any ideas how to improve performance ?
The startup of a Perl program is slow because the program needs to be
compiled. The more code, the slower the load. Shutdown isn't always
slow, though: could it be that you have handles to resources open that
need to be closed? If the delay is acute then maybe network handles are
involved, but even just having a lot of objects that need to be
destroyed can take time.
One approach to treat your problem is not to spawn off external programs
at all. This is what mod_perl technology famously does for CGI. This
may not be suitable for you, since you say your code is generated; but
depending on your problem, you may find it profitable to use closures
and other functional techniques. Avoid string eval as much as possible,
as this invokes the compiler at runtime.
Of course, there are issues with doing this. Your current model assumes
separate process spaces for each spawned process, and even if your tasks
could be made to work together in one process, it could involve redesign
and turn out new bugs because things need to learn to play together or
because some per-process limit you were far away from is now reached.
Probably the first thing you need to do is figure out where, exactly, is
the time being spent during startup and shutdown. Is the module that you
mentioned a particular one? Maybe it does stuff in BEGIN that is slow?
When you exit, is there a point in the code you can stick the Win32
equivalent of POSIX::_exit() and observe the speedup, then consider what
you had chopped off.
--
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/