Thread local and memory allocation

bearophile bearophileHUGS at lycos.com
Mon Oct 3 14:16:05 PDT 2011


Sean Kelly:

> I'd favor per-thread heaps but am open to suggestions and/or help.

(I am ignorant still about such issues, so I usually keep myself quiet about them. Please forgive me if I am saying stupid things.)
The memory today is organized like a tree, the larger memories are slower, and the far the memory is, the more costly it is to move data across, and to keep coherence across two pieces of data that are supposed to be the "same" data.
If I have a CPU with 4 cores, each core has hyper-threading, and each pair of cores has its L2 cache, then I think it is better for your code to use 2 heaps (one heap for each L2 cache). If future CPUs will have even more cores, with totally independent local memory, then this memory has to correspond to a different heap.

Bye,
bearophile


More information about the Digitalmars-d mailing list