goroutines vs vibe.d tasks

Atila Neves via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 30 10:37:36 PDT 2015


On Tuesday, 30 June 2015 at 16:43:58 UTC, anonymous wrote:
> On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote:
>> Just creating a bunch (10k) of sleeping (for 100 msecs) 
>> goroutines/tasks.
>>
>> Compilers
>> go:     go version go1.4.2 linux/amd64
>> vibe.d: DMD64 D Compiler v2.067.1 linux/amd64, vibe.d 0.7.23
>>
>> Code
>> go:     http://pastebin.com/2zBnGBpt
>> vibe.d: http://pastebin.com/JkpwSe47
>>
>> go version build with     "go build test.go"
>> vibe.d version built with "dub build --build=release test.d"
>>
>> Results on my machine:
>>
>> go:     168.736462ms (overhead ~ 68ms)
>> vibe.d: 1944ms       (overhead ~ 1844ms)
>>
>> Why creating of vibe.d tasks is so slow (more then 10 times)???
>
> I think this might be a problem with vibe.d's `sleep`. Putting 
> a `writeln("...");` there is a lot faster than `sleep`ing even 
> the tiniest amount of time.

Sleep will almost certainly pause and block the fiber. Vibe.d 
only switches between them when there's IO to be done or 
something else from the event loop. A better way of comparing 
would be to actually do something: use channels to ping-pong back 
between the goroutines and use vibe.d's concurrency to send 
messages betweeen fibers. Whatever you do, don't sleep.

Atila



More information about the Digitalmars-d-learn mailing list