[plt-scheme] From hash-table to generator

From: Eli Barzilay (eli at barzilay.org)
Date: Fri May 11 23:28:06 EDT 2007

On May 11, Jens Axel Søgaard wrote:
> In my sample application I get:
>    Above version:    cpu time: 23594 real time: 25469 gc time: 3389
>    Call/cc version:  cpu time: 18125 real time: 18344 gc time: 11515
>    List version:     cpu time: 1843 real time: 1843 gc time: 578
> The conclusion must therefore be, that you need to
> implement hash-table->generator as a primitive, if you want
> to avoid Unnecessary allocation.

These numbers show that context switches are expensive -- and the ones
involved with threads are a little more expensive than those with
continuation.  Allocating a list removes such switching, but it leads
to allocation (which is not a big deal, but my guess is that you're
worried about really big tables).

So how about a hybrid approach: use either the continuation or the
thread+channel code, but pass along blocks of N values from the table.
This way you're protected from really big tables, and with something
like N=1000 the context switching would be reduced to a minimum, and
the run time would be very close to what you'd get from a primitive

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

Posted on the users mailing list.