[plt-scheme] About extensions, inlining, fixnums and performance

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Mar 25 09:05:22 EDT 2008

At Tue, 25 Mar 2008 13:55:32 +0100, "Fabien Delorme" wrote:
> My fixn operations are faster, as expected. Well, there's a way to
> speed things up, I just have to use :
> 
> (require mzscheme)
> (time (do ((i 0 (+ i 1))) ((= i 100000000)) (+ i 2)))
> cpu time: 660 real time: 658 gc time: 0
> 
> Wow. If I understood, requiring mzscheme informs the compiler +, - et
> al. won't be redefined, so he can inline them. But what I don't get is
> : why doesn't it work with *my* fixn operations ?

The JIT recognizes and handles operators like `+' by generating inline
machine code for fixnums (and, in 3.99, flonums).

For your functions, all the JIT sees is a C function pointer, and it is
not able to extract the machine code from the function pointer and
integrate the code into its own stream of machine code.

Currently, the only way to get the JIT to inline other operations is to
change the JIT directly.

Matthew



Posted on the users mailing list.