flat assembler
Message board for the users of flat assembler.

Index > Windows > A more elegant way of aligning procedures

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 20 Dec 2012, 06:27
revolution, it is about MAINTAINING optimal speed, rather than losing speed. There is a big big and HUGE difference here. The speed that you think you gain is speed that you had to begin with but ruined it by bad layout in your program.

It is about maintaining optimal speed, not gaining speed.

That is also why people very rarily experience that it gives them speed gains, because the time it shows speed gains will always be proportionally to when you made a bad mistake. Any time it gives you speed gain will also be the time you made a bad mistake.

Because, let's face it, we only want the processor to pick up our instructions at the fastest way possible, and we do that by aligning, so that our processor can work at peak potential.

If a function is less than 64 bytes it most likely already works at peak potential, as soon as it becomes larger, it may need alignment to maintain peak potential.

And if you happen to gain a little speed, some people may go "Wow, it actually gained some speed". No it didn't, you just reclaimed the optimal speed that you already had to begin with.

1. Bad layout, speed drops -5
2. Alignment applied, speed gain +5

Total speed gain : 0
Post 20 Dec 2012, 06:27
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1619
Location: Toronto, Canada
AsmGuru62 20 Dec 2012, 15:40
@nmake: all the points you mentioned are for speed.
What do you think is faster: polluted cache or non-polluted cache?
Basically, these terms are equivalent to "speed".
Alignment = Prefetching = more speed (everyone knows that, these are synonyms).
Post 20 Dec 2012, 15:40
View user's profile Send private message Send e-mail Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 192
nmake 20 Dec 2012, 16:37
Yes you get speed, but only the kind of speed you have in the beginning of your program. If you code a small program, the speed you get is the same speed you get when aligning. If your program grow in size, you add alignment to maintain the same speed across the whole program, so that the speed stays at 1.0 from the beginning, 1.0 in the middle and finally 1.0 in the end. If you can maintain 1.0 all the way you have successfully maintained optimal speed. But your question in the beginning of this thread why fasm is so fast without aligning is the very same reason, it is because alignment doesn't gain speed, it only maintains optimal speed (1.0 here, 1.0 there and 1.0 in the end)
Post 20 Dec 2012, 16:37
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1619
Location: Toronto, Canada
AsmGuru62 20 Dec 2012, 18:17
Yes, my point was that we all align our code, yet we very well can do without it.
And be as fast as FASM.
Post 20 Dec 2012, 18:17
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.