Question about CPU caches and D context pointers

Dicebot public at dicebot.lv
Tue Feb 18 00:11:01 PST 2014


None of your buffers are on stack in both examples. As those are 
dynamic arrays you only get pointer + length as value and data 
itself resides on heap in some unknown location. It can be in 
cache too, of course, if it has been used actively, but it can't 
be verified based on this simple snippet.

To get best cache friendliness one may use dynamic-size structs 
akin to C but, of course, this does not go well with necessity to 
grow the buffer dynamically for given instance.

Also note that your first snippet uses ~= operator which will 
cause new heap allocations invalidating any old cache.


More information about the Digitalmars-d-learn mailing list