[plt-dev] some Racket proposals & implementation

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Sun Apr 4 09:34:39 EDT 2010

On Sat, Apr 3, 2010 at 9:48 PM, Eli Barzilay <eli at barzilay.org> wrote:
> * Same for the memory & runtime costs.  (In particular, I don't know
>  what batch compiler you were talking about...)

I've vaguely mentioned it to a few people, but I might as well say a bit more.

A student, Blake Johnson, is working on a demodularizing
bytecode-based batch compiler. Basically, you give it a modular zo and
it computes the phase-0 dependencies and gets their bytecode, then
creates one big zo with all the dependencies as a single module.

There are a few advantages. Whereas in

(module a scheme/base (require scheme/list) empty)

'empty' is a reference to a's top-level binding for the import 'empty'
from 'scheme/list' which is a reference to 'scheme/list's export for
'empty' which is a reference to 'scheme/list's top-level binding for
'empty'

After "demodularizing" the bytecode, 'empty' in the new a is a
reference to the top-level binding for 'empty'. Module imports are
"free".

Since we assume the program is closed [1], we can do traditional
whole-program optimization. In this email I was referencing that
dead-code elimination [2] amounts to removing the code for modules
that you just import without using. It's really amazing to look at
what that does.

For example, a simple Web server application brings in about 50 MBs of
bytecode, but after dead code elimination, it is only about 5 MBs.

It's definitely not ready for use yet, but it's promising.

Jay

[1] Closed = doesn't use eval, expand, dynamic-require, etc or observe
the existence of modules, like with module->namespace.

[2] There are lots of ways to make this less useful though. For
example, if a module contains top-level initialization code then it
will be seen as a "use" of the bindings in the module, even if the
ultimate "user" code doesn't use them. scheme/class is a good example
of this because the initialization of object% is done imperatively at
the top-level, rather than hidden inside of the object% define.

-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the dev mailing list.