D vs Go in real life

Atila Neves atila.neves at gmail.com
Tue Nov 5 05:05:20 PST 2013


So my buddy Jeff at work is a massive Go fan and goes on about it 
all the time. He even got me to try it once but I mostly hated 
it. To each his own. However, he laid down the gauntlet last 
Thursday saying his MQTT broker implementation in Go couldn't be 
beaten in performance. For those not in the know, MQTT is a 
publish/subscribe network protocol. And Go is all about parallel 
network programming, so what could beat it, right?

Always up for a challenge, I went ahead and implemented enough of 
an MQTT broker to handle the functionality required by the 
benchmark program he wrote to test his own code. In D of course, 
with the network code coming from vibe.d.

The result? 11% - 34% faster than the Go implementation depending 
on the workload (34%, 30%, 11%, 30%). The low end of that was 
with a higher number of connected clients, and that could always 
be me not using vibe.d well (I'd never used it before last 
Friday).

I also measured Mosquitto, an open-source C implementation. It 
mostly beat my D one, and went from 1% slower to 17% faster than 
the D/vibe.d combo depending on workload, with that 17% being an 
outlier (-1%, 5%, 17%, 3%, 3%).

I actually have error bars for all those values but thought it'd 
be too much to post them here. D FTW!

Atila

P.S. Not all was roses. Although getting to write D again was 
awesome (and I beat him), I ran into multiple problems:

- Trying to use dub to compile the project in release or profile 
mode flat out didn't work. I had to take the verbose output of 
dub, use it to compile vibe.d in debug mode into an object file 
and compile my own code separately and link it in. I believe this 
was a dmd regression. Speaking of which, why does dub recompile 
the world instead of tracking dependencies (I tried the rdmd 
option once but that didn't work, I can't remember why)?

- I ran into a dmd bug when I tried to use TaskPool.map with a 
delegate so I had to give up trying that possible optimisation.

- I ran into another dmd bug (it crashed) at one point if -inline 
was used.

- dub build with LDC and GDC failed miserably. I think it was 
because of vibe.d.


More information about the Digitalmars-d mailing list