[racket] thread size and creation time
here the little program
#lang racket/base
(current-thread-initial-stack-size 1)
(define num-threads 10000)
(collect-garbage)
(collect-garbage)
(collect-garbage)
(define before (current-memory-use))
(displayln before)
(for ([i num-threads])
(thread (lambda ()
(sleep 100))))
(collect-garbage)
(collect-garbage)
(collect-garbage)
(define after (current-memory-use))
(displayln after)
(displayln (exact->inexact (/ (- after before) num-threads)))
(sleep 100)
On 11.05.2013, at 12:17, Berthold Bäuml <berthold.baeuml at dlr.de> 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
>
>
--
-----------------------------------------------------------------------
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