[racket] generator performance

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Sep 18 20:41:47 EDT 2012

At Tue, 18 Sep 2012 19:20:29 +0200, Sam Tobin-Hochstadt wrote:
> continuations are *not* used to
> implement `thread` and associated facilities in Racket

Although Racket threads are not implemented with continuations in the
sense of `continuation?', both threads and continuations use the same
internal machinery for capturing context. As it happens, the run-time
system knows some invariants for thread contexts so that it can swap
them a little faster.

Along those lines, it occurs to me that the implementation of
`generator' might speed up by using `prompt' and `call/cc' instead of
`shift' and `reset'. When I make that change, it cuts about 1/3 of the
time from Greg and Patrick's examples. That's not a big improvement,
but it helps explain the difference between threads and generators.

Using `call/cc' for generators is effectively a hint to the run-time
system that the continuation doesn't need to compose. That hint is
useful only because of the way that continuations are implemented

Posted on the users mailing list.