Compile Nightly, Run Faster

by Charles Iliya Krempeaux, published on Tue Nov 5th, 2002

Compiled programs have a speed advantage over interpreted programs. Even when the would-be interpreted program is JIT'ed, real compilation still has the advantage.

So why not just have your computer compile all the scripts and VM code on your computer, while it is not doing anything else.

Although I had been a Linux user for a number of years. And had been at home at the shell for even longer (on IRIX and Solaris). I'd never seen the locate command until recently. (I saw someone else using it at a VanLUG meeting.)

The locate command let's you perform extremely fast searches of you file system. It is able to perform these searches at such a fast rate, by what some might call "cheating". In the middle of the night, a special program will run, called updatedb. updatedb goes an indexes your entire file system. This index is what locate uses when it performs searches. It doesn't actually go and search your file system; but instead searches the index that it made the night before.

This same idea could be applied to speeding up scripts and VM (Virtual Machine) code. In the middle of the night, while your computer is not doing anything else, a special program could run and compile all your scripts and VM code into native binaries.

Having said that, there are some details to work out.

The first detail is, where do we put the compiled version of these scripts and VM code. (Surely we don't want to simply replace the original versions.) Well, one way we could do it is by having a special hidden directory created. Maybe have the directory called ".cat". ("CAT" would be an initialization for Compiled Ahead of Time.) And then put the compiled Linux ELF versions of the scripts and VM code into that directory. (This could be done in a similar manner to how thumbnail images are put in the ".thumbnails" directory, according to the Thumbnail Managing Standard.)

Then, whenever we want to execute a program, the operation system (or whatever) would the check to see if there was a ".cat" directory and a compiled version or the script or VM code, to run; and only if there weren't would it go and run the original (non-compiled) version.

Also, we have to consider what happens if we update a program. Well, then the compiled version of the script or VM code is for the old version of the program. Well, we could solve this by making the operating system (or whatever) check the dates on the compiled version and the original. If the compiled version is newer, then run that; else run the original.

(There are likely more details to work out too.)

So what does this mean then. It means that programs written in Perl, Python, shell script, Haskell, etc, or which have been compiled to the Java JVM, .NET/Mono CLR, or other VMs, run much much faster.


Read more about:

Comments

No known comments. (There may be some out there though.)


New Comments

Want to write a comment to this post on your own blog? Then use the HTML code below to link to this article....

Or better yet, use the quote-o-matic below by "selecting" the part of the text (in the article) that you want to quote, and then use the HTML code that will get generated below to link to this article....


Preview:
       

Topics