[racket] thread size and creation time

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat May 11 11:27:32 EDT 2013

Racket threads are indeed heavier than in Gambit or Erlang, while being
much lighter than threads in Java or pthreads.

The difference between Racket and Gambit is mostly in the
representation of continuations. The Racket implementation of
continuations is tangled up with the C stack in a way that creates
trouble and inefficiency.

Tangling with the C stack is related Racket's origins, where we wanted
to allow callback paths through C and have those paths captured in
continuations and swapped among threads. That approach was a good way
of getting started quickly, but not a great choice in the long run. We
are moving the implementation in a direction that will let us fix the
problem, but it's a very long process.

At Sat, 11 May 2013 12:17:28 +0200, Berthold Bäuml wrote:
> Hi,
> what is the reason that threads in Racket are so much bigger than in Gambit 
> Scheme and take so much longer to create them? Is there possibly a way to come 
> closer to Gambit performance or have threads in Gambit less functionality? In 
> my little Racket test program below I get about 10kB per thread on my MacBook 
> and creation takes about 100us per thread (Gambit claims to fit "millions of 
> active threads in ~1GB and a creation time of 0.5us).
> Marc Freely states in a talk from 2010 about Gambit 
> http://www.iro.umontreal.ca/~gambit/Gambit-inside-out.pdf
> Green threads
> Preemptive scheduler with priorities
> Very lightweight and scalable
> Thread = descriptor (324 bytes) + continuation 
> Thread creation/synchronization ~ 0.5 μs 
> O(log N) enqueue/dequeue operations 
> Supports millions of active threads (in ~ 1GB)
> Best,
> Berthold
> -- 
> -----------------------------------------------------------------------
> Berthold Bäuml -- Head of Autonomous Learning Robots Lab
> DLR, Robotics and Mechatronics Center (RMC)
> Münchner Str. 20, D-82234 Wessling
> Phone +49 8153 282489
> http://www.robotic.de/Berthold.Baeuml
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.