Bartosz Milewski Missing post

Andrei Alexandrescu SeeWebsiteForEmail at
Sat May 30 06:36:19 PDT 2009

Michel Fortin wrote:
> On 2009-05-28 12:52:06 -0400, Andrei Alexandrescu 
> <SeeWebsiteForEmail at> said:
>> What happens is that memory is less shared as cache hierarchies go 
>> deeper. It was a great model when there were a couple of processors 
>> hitting on the same memory because it was close to reality. Cache 
>> hierarchies reveal the hard reality that memory is shared to a 
>> decreasing extent and that each processor would rather deal with its 
>> own memory. Incidentally, message-passing-style protocols are 
>> prevalent in such architectures even at low level. It follows that 
>> message passing is not only an attractive model for programming at 
>> large, but also a model that's closer to machine than memory sharing.
> While message-passing might be useful for some applications, I have a 
> hard time seeing how it could work for others. Try split processing of a 
> 4 Gb array over 4 processors, or implement multi-threaded access to an 
> in-memory database. Message passing by copying all the data might happen 
> at the very low-level, but shared memory is more the right abstraction 
> for these cases.

Depends on what you want to do to those arrays. If concurrent writing is 
limited (e.g. quicksort) then there's no need to copy. Then many times 
you want to move (hand over) data from one thread to another. Here 
something like unique would help because you can safely pass pointers 
without worrying about subsequent contention.

> There's a reason why various operating systems support shared memory 
> between different processes: sometime it's easier to deal with shared 
> memory than messaging, even with all the data races you have to deal with.

Of course sometimes shared memory is a more natural fit. My argument is 
that that's the rare case.

> Shared memory becoming more and more implemented as message passing at 
> the very low level might indicate that some uses of shared memory will 
> migrate to message passing at the application level and get some 
> performance gains, but I don't think message passing will ever 
> completely replace shared memory for dealing with large data sets. It's 
> more likely that shared memory will become a scarse resource for some 
> systems while it'll continue to grow for others.
> That said, I'm no expert in this domain. But I believe D should have 
> good support both shared memory and message passing.
> I also take note that having a good shared memory model could prove very 
> useful when writting on-disk databases or file systems, not just 
> RAM-based data structures. You could have objects representing disk 
> sectors or file segments, and the language's type system would help you 
> handle the locking part of the equation.

I think shared files with interlocking can support such cases with ease.


More information about the Digitalmars-d mailing list