Subj : Performance impact of disaligned structures To : comp.programming From : Gioele Barabucci Date : Tue Oct 04 2005 02:48 pm How much "worse" is this structure struct { uint64 length; uint32 id; uint64 *next; /* this is 32 bits aligned */ uint64 data[256]; /* this starts on the 32 bits boundary */ } compared to this other struct { uint64 length; uint32 id; uint32 padding; uint64 *next; /* now this is 64 bits aligned */ uint64 data[256]; /* and this starts on the 64 bits boundary */ } on 32 bits and 64 bits architectures? The '*next' pointer is going to be used seldom; what worries me is the data field. The content of data[256] is going to be used as input for heavy CPU computations, it should be loaded as fast as possible into the MMX/Altivec registers. How (and how much) will the different layout affect run time speed? My targets are x86 and ppc32 on the 32 bits side and x86_64 and POWER (ppc64) on the 64 bits side. -- Gioele Barabucci .