> 3. Dynamically allocating data to force its layout on a particular > memory boundary will require dereferencing a pointer each time you > need to access that data. You will have better performance if you > add padding to your data structure, so that layout is determined > during compile time.
(a) Sometimes the data structure is dynamically allocated, or at least accessed via a pointer, anyway. (b) Depending on how heavy the cost of going to memory is, the cost of the pointer indirection may be effectively zero, because it gets lost in the stalls waiting for memory anyway. (c) The cost of the pointer indirection, even when not swallowed up in other effects, may be less than the cost of bad cache behaviour from badly-aligned data structures. /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML [email protected] / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
