Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Huge perl binary file

by dave_the_m (Parson)
on Jul 13, 2012 at 09:51 UTC ( #981590=note: print w/ replies, xml ) Need Help??


in reply to Huge perl binary file

None of the comments so far have made it clear that the thing being dynamically loaded is the perl library itself; i.e. the 16K thing is just a little wrapper that calls perl library routines to create, execute and destroy a perl interpreter. The vast bulk of the code for the perl interpreter resides in libperl.so, which may or may not be statically linked into the perl executable.

Dave.


Comment on Re: Huge perl binary file
Re^2: Huge perl binary file
by davido (Archbishop) on Jul 13, 2012 at 22:31 UTC

    This is a nice explanation. The perl executable is really just a specific use case of what is documented in perlembed. In this case, Perl is embedded in perl. How it's linked is what is in question; static versus dynamic. If libperl.so is not statically linked, it will be pulled in as soon as it's needed. If it's statically linked, it gets included at startup time.

    I don't know enough about the internals to know the answer to the following question, but in practical terms I hardly see how it matters: The question: Which of the following commands from Perl's API results in a dynamically-linked libperl.so being pulled in: PERL_SYS_INIT3(), perl_alloc(), perl_construct(), perl_parse(), or perl_run()?

    The thing is, I doubt that it matters which one triggers the dynamic loading, because they're probably called in close succession within the perl executable. perlinterp discusses how perlmain.c is really just a concise, high level wrapper around the code that appears in perl.c, and that it looks a lot like the embedding example in perlembed. The little 16k wrapper doesn't maintain its slender memory footprint for very long. Certainly by the time Perl begins parsing code it has already found a need that requires pulling in libperl.so. libperl.so is probably loaded (under a non-static link build) before you have time to sneeze, relegating the distinction between start-up time for static vs dynamic linking to the dustbin of micro-optimization.


    Dave

      I would expect libperl.so to get linked in when the perl executable is first loaded, and before any functions are called: the loading isn't triggered by calling a particular function. Of course, this is OS specific.

      Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-12-27 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls