Message passing between threads: Java 4 times faster than D

Sean Kelly sean at
Thu Feb 9 14:17:00 PST 2012

On Feb 9, 2012, at 11:57 AM, Martin Nowak wrote:

> On Thu, 09 Feb 2012 16:44:46 +0100, Sean Kelly <sean at> 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.
> I didn't yet got around to polish my lock-free SList/DList implementations,
> but mutexes should only become a problem with high contention when you need to block.
> You'd also would need some kind of blocking for lock-free lists.

No blocking should be necessary for the lock-free list.  Just try to steal a node with a CAS.  If the result was null (i.e. if the list ended up being empty), allocate a node via malloc/GC.

> Best first order optimization would be to allocate the list node deterministically.

Neat idea.  I think I can make that change fairly trivially.

More information about the Digitalmars-d mailing list