[plt-scheme] A Comment on MzScheme Performance vis-a-vis Web Applications

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Jun 11 00:27:12 EDT 2006

On Jun 10, Brent Fulgham wrote:
> 
> MzScheme's performance on the newer tests is still pretty bad, but I
> suspect a little review by Eli and Matthew will substantially help
> in these areas.

This is something that is often neglected...  Take this simple code:

  (define (fib n)
    (if (<= n 1)
      n
      (+ (fib (- n 1)) (fib (- n 2)))))

It looks innocent -- but every free variable reference is costly,
since it can change at any second through a `set!' or re`define'.  In
this case, this means that every reference to `<=', `+', `-' and `fib'
must be done indirectly, in case the binding changes.  If you put that
same code in a module, the environment can rely on the fact that `+'
is always MzScheme's addition etc, and that `fib' is always a
recursive call.  You can imagine how much that can help -- and that's
more true now than ever, since inline does happen, and bytecode is
turned to machine code.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.