[dmd-concurrency] D's Memory Model

Walter Bright walter at digitalmars.com
Tue Feb 9 23:25:12 PST 2010



Robert Jacques wrote:
>
> Yes, there was one important language change which my first post 
> advocated: the separation of local and shared (+immutable & unique) 
> data into logically separate memory pools. I'm sorry that I didn't 
> make it clearer. From a TDPL point of view, this allows 
> implementations to eliminate false sharing (an important fact to 
> highlight) and to use thread-local allocation and/or thread-local 
> collectors. The downside is that it adds language complexity and makes 
> casting from local to shared/immutable/unique implementation defined.
>

There's another way to do this that requires no language changes. Simply 
have each thread have its own thread local pool to allocate from, but 
memory once allocated is treated as global. This allows individual 
allocations to be cast to shared, but the vast bulk will wind up being 
thread local without sharing cache lines, and it will not require locks 
to be taken for most allocations.

A collection cycle, however, will still need to pause all threads and do 
the whole shebang.


More information about the dmd-concurrency mailing list