Message passing between threads: Java 4 times faster than D
Marco.Leise at gmx.de
Thu Feb 9 02:11:20 PST 2012
Am 09.02.2012, 10:06 Uhr, schrieb Nicolae Mihalache <xpromache at gmail.com>:
> I'm a complete newbie in D and trying to compare with Java. I
> implemented a simple test for measuring the throughput in message
> passing between threads. I see that Java can pass about 4mil
> messages/sec while D only achieves 1mil/sec. I thought that D should
> be faster.
> The messages are simply integers (which are converted to Integer in
> The two programs are attached. I tried compiling the D version with
> both dmd and gdc and various optimization flags.
I cannot give you an explanation, just want to say that a message in
std.concurrency is also using a wrapper (a 'Variant') + a type field
(standard, priority, linkDead). So you effectively have no optimization
for int, but the same situation as in Java.
The second thing I notice is that std.concurrency uses a double linked
list implementation, while you use an array in the Java version, which
results in no additional node allocations.
More information about the Digitalmars-d