[gambit-list] Help With Memory

Alex Shinn alexshinn at gmail.com
Fri Sep 26 10:41:56 EDT 2008


Hi,

Marc Feeley <feeley at iro.umontreal.ca> writes:

> The point I am trying to make is that in a Scheme to C compiler
> continuations can be implemented in other ways than Cheney on the MTA
> to get a system with good performance for call/cc.  Whether one system
> is a few percent faster than the other on these benchmarks is quite
> possibly due to other factors unrelated to the implementation of
> continuations.

Indeed, those benchmarks are both highly influenced by the
speed of generic arithmetic, which Chicken is slow at.  If
you set the options for both implementations to use unsafe,
fixnum-only arithmetic, the computation amounts to
practically nothing, and all you're comparing is the speed
of call/cc.  In this case I find Chicken is roughly 1.4x
faster for ctak, and 2x faster for fibc.

Chicken is a simple compiler with relatively few
optimizations.  The fact that it can nonetheless outperform
Gambit (which is otherwise faster in general) on these
benchmarks suggests that Cheney on the MTA gives you very
fast continuations.

> Another point I want to make is that Cheney on the MTA give you "free"
> call/cc only after paying a premium on other things, namely stack-like
> behaving function calls and tail-calls.

Sure, to be clear I'm not claiming that Cheney on the MTA is
a superior architecture, just that it has fast
continuations.  Specifically, in answer to the original
question, you can't get notably faster code with manual CPS
than with call/cc in Chicken.  But as you say, it comes with
trade-offs, and I wouldn't be so rude as to recommend people
use Chicken on the Gambit list :)

I do think that with a good optimizing compiler, a lot of
the differences in strategies can be optimized away though.
For example Chicken already contracts self tail-calls so
that simple loops use goto - they're not "stack-like" - and
many more optimizations can help close the gap.

-- 
Alex



More information about the Gambit-list mailing list