Message passing between threads: Java 4 times faster than D

Brad Anderson eco at
Thu Feb 9 09:24:21 PST 2012

On Thu, Feb 9, 2012 at 9:22 AM, dsimcha <dsimcha at> wrote:

> I wonder how much it helps to just optimize the GC a little.  How much
> does the performance gap close when you use DMD 2.058 beta instead of
> 2.057?  This upcoming release has several new garbage collector
> optimizations.  If the GC is the bottleneck, then it's not surprising that
> anything that relies heavily on it is slow because D's GC is still fairly
> naive.
> On Thursday, 9 February 2012 at 15:44:59 UTC, Sean Kelly wrote:
>> So a queue per message type?  How would ordering be preserved? Also, how
>> would this work for interprocess messaging?  An array-based queue is an
>> option however (though it would mean memmoves on receive), as are
>> free-lists for nodes, etc.  I guess the easiest thing there would be a
>> lock-free shared slist for the node free-list, though I couldn't weigh the
>> chance of cache misses from using old memory blocks vs. just expecting the
>> allocator to be fast.
>> On Feb 9, 2012, at 6:10 AM, Gor Gyolchanyan <gor.f.gyolchanyan at>
>> wrote:
>>  Generally, D's message passing is implemented in quite easy-to-use
>>> way, but far from being fast.
>>> I dislike the Variant structure, because it adds a huge overhead. I'd
>>> rather have a templated message passing system with type-safe message
>>> queue, so no Variant is necessary.
>>> In specific cases Messages can be polymorphic objects. This will be
>>> way faster, then Variant.
>>> On Thu, Feb 9, 2012 at 3:12 PM, Alex Dovhal <alex dovhal at>
>>> wrote:
>>>> Sorry, my mistake. It's strange to have different 'n', but you measure
>>>> speed
>>>> as 1000*n/time, so it's doesn't matter if n is 10 times bigger.
>>> --
>>> Bye,
>>> Gor Gyolchanyan.
dmd 2.057:
received 100000000 messages in 192034 msec sum=4999999950000000
speed=520741 msg/sec
received 100000000 messages in 84118 msec sum=4999999950000000
speed=1188806 msg/sec
received 100000000 messages in 88274 msec sum=4999999950000000
speed=1132836 msg/sec

dmd 2.058 beta:
received 100000000 messages in 93539 msec sum=4999999950000000
speed=1069072 msg/sec
received 100000000 messages in 96422 msec sum=4999999950000000
speed=1037107 msg/sec
received 100000000 messages in 203961 msec sum=4999999950000000
speed=490289 msg/sec

Both versions would inexplicably run at approximately half the speed
sometimes. I have no idea what is up with that.  I have no java development
environment to test for comparison.  This machine has 4 cores and is
running Windows.

Brad Anderson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Digitalmars-d mailing list