[plt-scheme] getting better speed with JIT

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Sun Dec 2 15:25:49 EST 2007

Prabhakar Ragde skrev:
> Will Clinger recently posted in comp.lang.scheme on the speed of various 
> Scheme implementations, and mentioned in passing that one has to 
> (require mzscheme) to get the JIT to work. I was not aware of this. I 
> cannot find this incantation anywhere in Help Desk, except in the mzc 
> manual. Should I have known this, and if so, what did I miss? It sped up 
> one of my benchmarks, a double loop looking for perfect numbers, by a 
> factor of 2.5. Thanks. --PR

The standard Scheme semantics require that you can do
the unmentionable:

   (set! + *)

Thus in a module-less program like

   (define (foo a b) (+ a b))

the + is in practise bound to a box containing
the primitive plus operator. This implies that
the compiler can't inline the call (+ a b).

However, since it is illegal to mutate a module-required
variable, the compiler can safely inline the + in:

   (require mzscheme)
   (define (foo a b) (+ a b))

There are no problems with module based programs.

Jens Axel Søgaard

Posted on the users mailing list.