Oh, my GoD! Goroutines on D
mw
mingwu at gmail.com
Sun Jun 14 22:34:15 UTC 2020
On Monday, 25 May 2020 at 16:41:06 UTC, Jin wrote:
>> FYI: channels are also part of vibe-core since a while:
>>
>> https://github.com/vibe-d/vibe-core/blob/master/source/vibe/core/channel.d
>
> Yes. But it uses mutex. My implementation is wait-free
> (https://en.wikipedia.org/wiki/Non-blocking_algorithm#Wait-freedom). All threads can easy and fast write and read without any locking. So every queue is 1-provider-1-consumer. But Input and Output channels is roundrobin list of queues. You can found some diagrams there: https://github.com/nin-jin/go.d/blob/master/readme.drawio.svg
Just saw this, for 1-provider-1-consumer queue, I did some
experiments with
https://code.dlang.org/packages/lock-free
and the result is here:
https://github.com/mingwugmail/liblfdsd/tree/master/comparison
LDC is ~5x times faster than DMD, I'm not so sure why; and this
package may need more stress testing:
------------------------------------------------------------------------
$ make ldcrun
...
received 1000000000 messages in 9845 msec sum=499999999500000000
speed=101574 msg/msec
$ make dmdrun
...
received 1000000000 messages in 53607 msec sum=499999999500000000
speed=18654 msg/msec
$ make javamp
10000000 messages received in 1151.0 ms, sum=49999995000000
speed: 0.1151 microsec/message, 8688.097306689835 messages/msec
$ make dmp
received 100000000 messages in 27574 msec sum=4999999950000000
speed=3626 msg/msec
------------------------------------------------------------------------
More information about the Digitalmars-d
mailing list