[% setvar title Cache byte-compiled programs and modules %]

This file is part of the Perl 6 Archive

Note: these documents may be out of date. Do not use as reference!

To see what is currently happening visit http://www.perl6.org/


Cache byte-compiled programs and modules


  Maintainer: Simon Cozens <simon@brecon.co.uk>
  Date: 25 Sep 2000
  Mailing List: perl6-internals@perl.org
  Number: 301
  Version: 1
  Status: Developing


Python does it. Java does it. It's time we did it.


When Perl runs a program, it's compiled to bytecode and then the bytecode is executed. Now, what you could easily do is stop after compiling and dump out the bytecode to save you compiling it next time the program is run. In Perl 5, this is slow, because it's quicker to recompile than to read in the bytecode. In Perl 6 it'll be quick, and I'll have some suggestions as to how to speed it up soon.

So, we check for the existence of a .plc file before running a program; if the .plc file is newer than the program, we use that instead. If there isn't a .plc file or it's older than the program, recompile and dump the bytecode to a .plc file. Naturally, this gives us the best speedup for modules which change very, very infrequently, rather than programs which can change a lot during development. Maybe you only want to do this for modules, then.


Perl 5.6 has the elements of support for .plc files, but it doesn't tell anyone about this: have a look at pp_require in pp_ctl.c. (Hmm, it's not in 5.7.0, but I could have sworn I've seen it in there in the past.)

I also threw out a module called ByteCache onto p5p a few months ago, which implemented the thing as a coderef on @INC. Implementing it in pp_require is a cleaner way of doing it, however.