Re: [Vala] Further speculations on couroutines, generators and threads : Emulating Go's goroutines and channels in Vala
- From: Luca Bruno <lethalman88 gmail com>
- To: Jim Peters <jim uazu net>
- Cc: Serge Hulne <serge hulne gmail com>, vala-list <vala-list gnome org>
- Subject: Re: [Vala] Further speculations on couroutines, generators and threads : Emulating Go's goroutines and channels in Vala
- Date: Tue, 12 Jul 2011 19:23:40 +0200
On Tue, Jul 12, 2011 at 12:04:13PM -0500, Jim Peters wrote:
Luca Bruno wrote:
Threads are very heavy compared to an optimised implementation of
'goroutines' or whatever. Certainly you can emulate them but it's not
going to be an efficient way of implementing algorithms unless someone
puts in the work to make it efficient under the hood.
If convenience matters more than efficiency, then no problem.
Do you have any benchmark? I wouldn't say that loudly in general.
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,
http://www.debian.org - The Universal Operating System
] [Thread Prev