Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Module::Compile + B::Bytecode = Faster loading ?

by cosimo (Hermit)
on Dec 18, 2006 at 20:39 UTC ( [id://590551]=perlquestion: print w/replies, xml ) Need Help??

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

I saw B::Bytecode and tried it out a bit.
Then I saw Module::Compile and tried it out a bit.

Now I'd like to mix and match them and compile a module (*.pm) to bytecode and save the result as *.pmc

The point would be saving parsing and bytecode compiling for each program execution, given that I load hundreds of modules every time.
I suppose I am the first one coming up with this Cool Idea™, uh? ;-)
From what I read, perl already loads *.pmc files, but:

  1. is there a ready-made solution to this problem?
  2. is it sane to do that?
  3. is B::Bytecode going to be abandoned?

Replies are listed 'Best First'.
Re: Module::Compile + B::Bytecode = Faster loading ?
by Joost (Canon) on Dec 18, 2006 at 21:00 UTC
    • is there a ready-made solution to this problem?

      Not really no. If possible, the best solution is to keep the program running all the time. (See for example, mod_perl)

    • is it sane to do that?

      It's not going to be much faster (and quite possibly slower) than just compiling the modules at run-time. If you don't use all the modules all the time, you might get better results by using require and/or Autoloader to load code when you need it instead of all at once.

    • is B::Bytecode going to be abandoned?

      As far as I know, yes.

Re: Module::Compile + B::Bytecode = Faster loading ?
by merlyn (Sage) on Dec 18, 2006 at 20:55 UTC
    You should already be able to say:
    perl -MO=Bytecode,-H,-oFoo/Bar.pmc Foo/Bar.pm
    to compile Foo/Bar.pm to pmc.

    You can use that to test out whether your theories will work.

      Thanks merlyn,

      I don't know why, but looking at the docs, I tried with -O2 rather than -H and that failed miserably...

      Now, I only have to bytecode-compile a hundred modules, hope that the process works for all of them, and see if that saves time or not... :-)

      I'll try to automate the whole thing for the most used modules.

        It probably doesn't. Loading code with B::Bytecode is reported to be slower than loading code from source.

        ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: Module::Compile + B::Bytecode = Faster loading ?
by diotalevi (Canon) on Dec 18, 2006 at 21:34 UTC

    See also pperl.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://590551]
Approved by chargrill
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-26 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found