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

Delay running Perl execs in Windows

by Raineer (Novice)
on Apr 15, 2014 at 14:19 UTC ( #1082346=perlquestion: print w/ replies, xml ) Need Help??
Raineer has asked for the wisdom of the Perl Monks concerning the following question:

Hello all,

I use Perl to write trace and log parsers for my engineering group. They are a Windows crowd and most are not savvy enough to use native Perl.

I use `pp` to package the scripts into executables which they can run on Windows, and I've had great success doing so.

My question is - Why do freshly-packed execs have such a long delay the first time they are run in Windows on a given machine? I even see this on my own machine - I pack with `pp`, then launching the file gives me a black screen hang for 30-60 seconds and the program proceeds as desired. Subsequent launches have no delay at all.

My colleagues see this same behavior as well. It's a nuisance at worst, but I would really like to eliminate this. I can see the behavior on the simplest of programs, at most my typical programs only import Archive::Tar.

Are there further settings I can use in `pp` to eliminate this delay? I have searched and searched but haven't found a report that matches this behavior, though I can't believe I'm the only one.

I'm using Strawberry 5.16, but I have seen the same behavior on every distro and version I have used. Thank you.

Comment on Delay running Perl execs in Windows
Re: Delay running Perl execs in Windows
by salva (Monsignor) on Apr 15, 2014 at 14:31 UTC
    That's because the programs created by pp are just archives (think .ZIP) with an executable header that unpacks them the first time they are executed into a temporal directory and then invoke the main script from there.

    In my opinion there should be better ways to do that, as for instance, building a .MSI file able to install the script, the modules and all the support files in some directory under c:\Program files (or equivalent) as any other regular application.

    But somebody has to actually build that tool :-(

Re: Delay running Perl execs in Windows
by hominid (Curate) on Apr 15, 2014 at 15:40 UTC

      Since the OP was complaining about the load time, using Cava Packager isn't going to "fix" the problem. I believe that what I described in my response still applies with Cava Packager. The response from "cava-admin" near the end of the thread linked below seems to confirm this.

      "start time of Cava Packager binaries" from Cava Packager Google Group

        Since the OP was complaining about the load time, using Cava Packager isn't going to "fix" the problem.

        Sure it is

        You "install" the cava, which is the unzipping step -- there is no further unzipping to temporary directories that get cleaned up whenver

        After that the overhead is pretty much the same

Re: Delay running Perl execs in Windows
by dasgar (Deacon) on Apr 15, 2014 at 16:04 UTC

    I'm no expert on this, but here's the general gist of what I took away from Reini Urban's presentation on the Perl compiler. (http://houston.pm.org/talks/2011talks/1110Talk/index.html)

    The 'pp' utility is just packaging the Perl interpreter, modules and your code. Running the pp created executable means that it has to unpack the packed files, setup the Perl environment and then run your code. In your case, the initial run does the heavy lifting on the preparation tasks (unpacking files, etc.) and the subsequent runs are able to leverage the preparation work from the first run.

    From Reini's presentation, he's referring to B::C, which I personally have never used. This will actually compile your code (or actually converts Perl into C code and then compile the C code). In this case, the execution time of your Perl code is not any faster (i.e. adding numbers, reading files, etc.), but the start up time can be significantly faster.

    Honestly, most of Reini's presentation went over my head. Hopefully I've accurately described the start up time differences between packaging Perl code into an executable (i.e. using pp) vs. compiling the Perl code into an executable (i.e. B::C).

Re: Delay running Perl execs in Windows
by Anonymous Monk on Apr 15, 2014 at 18:53 UTC

      Thank you to everyone, lots of very helpful information in here. I appreciate it.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1082346]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2014-09-19 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (132 votes), past polls