Hey again.. I keep hearing this issue of 'allignment' in discussions..

I also know i have asked this question in the past, but somehow it doesnt still well in my head how it affects the actually CPU and the pipe-lines while fetching info etc. etc.

All i truely get at this point is if your can figure out the needed allignment the cpu will run faster while executing your code. And the allignment is based on a common factor found in the data lengths on the stack and data segments????? ** moving into grey areas here... **

At this point in my coding practices im sure i can understand this, but i need someone to lay out the pieces and give a modest explaination as to what to look for and think about if i wanted to 'allign' my code for speed optomization... (some basic examples to see a good alignment from a bad allignment would be an awesome starting point for me.. )

Thanx in advanced for the your patience on this (as i know it may be a bit more typing than you might want to on this reply.. its appreciated..)

My intersts is to start optomizing my Object set before i release them for general use, so any help in this area would most likely be an asset in the long run...

Thanx again...
Posted on 2001-08-12 21:40:53 by NaN
Some people say alignment doesn't really matter, other people says
it matters a lot. For DWORD sized data, I guess you just have to
keep it DWORD aligned. Pretty easy with locals, since they should
always be automatically aligned (unless you do dangerous stuff
like pushing non-dword data... which is a no-no under win32 anyways).

For globals, it can be easy to forget the ALIGN directive, but... it's
not that important with your standard variables anyway. But it might
give tiny speed improvements if you align your important data...
at least it did on my trusty old pentium/mmx/200 :). The special
profiling registers rocked, btw, but they are a bit hard to use under
windows. And even if you can get them working, the results will be
rather misleading because of all the task switching going on.

However, a thing that could very well mean a lot, is that cache line
size of your processor... usually 32 bytes iirc. Whenever there's a
cache miss, a whole line is transferred, so if you have big structures
or arrays that are used intensively, it might be smart to align them
on a 32byte boundary.

But this is mostly guesswork from my side, it's been (too) long since
I did intensive alignment testing...
Posted on 2001-08-13 00:48:24 by f0dder