[dmd-concurrency] D's Memory Model

Walter Bright walter at digitalmars.com
Wed Feb 10 10:30:21 PST 2010



Robert Jacques wrote:
>
> Yes. The reason I said that casting from local to shared was 
> implementation defined was I knew the operation could be valid or 
> invalid based on the type of GC used. However, your comment sounds 
> like the standard C/C++ approach to thread-local allocation, which I 
> discussed in the original post. In short, this model has been shown to 
> be insufficient in C/C++ with regard to false sharing and has created 
> several hacks to remove false sharing for identifiable hot-spots. Your 
> comment also doesn't address the key challenge to D's GC, which is: 
> where does the garbage returned to?

The garbage is returned to the global memory pool, not the local one. 
When the local ones run out, they go and get more from the global pool.

> (which I also discussed) Anyways, in order to prevent false sharing, 
> small immutable objects need their own memory pool and shared objects 
> need to be created in a different manner than local objects. To me 
> this creates a logical separation of their memory pools and at a 
> minimum requires the GC implementation to perform allocation using 
> specific flags for each type qualifier.
>

False sharing isn't just a problem with shared objects, it happens with 
local objects. Using separate local pools to allocate from will minimize 
this problem.


More information about the dmd-concurrency mailing list