Re: [Vala] Further speculations on couroutines, generators and threads : Emulating Go's goroutines and channels in Vala



Luca Bruno wrote:
No, I don't have a benchmark, but a Thread is actually a kernel
process on Linux, whereas a goroutine could be just an allocated
mini-stack of 100 bytes (assuming enough static analysis to figure out
required stack depth) and some housekeeping structures.  Switching
between threads means waiting for the Linux kernel to schedule it.
Switching to/from a go/coroutine could be a longjmp (having read some
of the Pth implementation stuff).

To me it seems that they would not be comparable in efficiency.

Threads are allocated on multiple cores nowadays and you can use lock-free
data structures when possible. Still you didn't provide any benchmark,
only thoughts.

We are both putting forward "only thoughts".

To prove my point I will have to implement simple coroutines in Vala
using low-level C stuff, i.e. setcontext/makecontext/etc.  I guess a
Coroutine class could be useful for something someday.  Give me a
moment ...

Jim

-- 
 Jim Peters                  (_)/=\~/_(_)                 jim uazu net
                          (_)  /=\  ~/_  (_)
 UazĂș                  (_)    /=\    ~/_    (_)                http://
 in Peru            (_) ____ /=\ ____ ~/_ ____ (_)            uazu.net



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]