user2150378
user2150378

Reputation: 51

Best way to reduce perl startup time

I have been working on a Perl parser on and off for a few years, though since it has always been in pre-alpha, I have never worried about speeding it up. However, I have started working on ways to optimize it, and was surprised at what I found.

After some algorithmic and regex optimizations, a normal execution takes around 3.5 seconds, of which, about 2.3 is the time it takes for Perl to start up (which I measured with "time perl scriptname.pl" after putting a "die("Done");" in the first line). I understand that Regexp::Grammars isn't the speediest Perl module out there, but it seems that its initialization takes much longer than actually executing the script.

Therefore, I started looking into an easy way of compiling it down to bytecode before running it. It seems B::Bytecode, the only functional way to do this, is no longer maintained or included in the main Perl distribution. Is there any easy way for me to decrease the startup time?

Thanks!

Upvotes: 5

Views: 808

Answers (1)

bart
bart

Reputation: 7767

There are ways to run persistent scripts. Usually they're used in a webserver context, but there's no reason not to use them for other purposes.

One such system is CGI::SpeedyCGI, which may or may not be what I was thinking of. This is currently also known as PersistentPerl.

Upvotes: 0

Related Questions