flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Code alignment optimization |
Author |
|
revolution 05 Feb 2020, 05:37
There isn't any fixed rule.
Sometimes, in some code, you can measure a speed improvement when you align procedure entries and loop entries to some binary power multiple. But it is not guaranteed to be true. Sometimes it harms the performance. Blindly aligning every entry point is almost certainly not going to benefit you for any non-trivial program. You will have to selectively target certain parts and have functioning performance measurement code running to see the effects. Also, it is an iterative process. Changing one part of the code can affect other parts. And worse, every system/CPU/mobo variant will show different results. Unfortunately you can't use one optimisation on one system and have it have the same effect on all other systems. Each system needs its own testing procedure to see what works for it. |
|||
05 Feb 2020, 05:37 |
|
Hrstka 05 Feb 2020, 12:53
I would say that code alignment can bring some benefit only in situation when the code is executed many times. So it's not necessary to align the start of a function, but it's more meaningful to align the start of a loop instead. Anyway, the OS doesn't manage any alignment, it just loads the code stored in the executable file. The alignment must be performed by the compiler.
|
|||
05 Feb 2020, 12:53 |
|
revolution 05 Feb 2020, 15:46
Also note that the kind of improvement you might see is probably of the order of a few percent at most.
If this kind of improvement is significant to you then I recommend setting up a robust measuring system to make sure you aren't mislead by transient effects and external events causing jitter. |
|||
05 Feb 2020, 15:46 |
|
donn 05 Feb 2020, 16:58
https://developer.amd.com/wp-content/resources/56305_SOG_3.00_PUB.pdf
Quote: 2.9 Instruction Fetch and Decode Is this 'pick window' just an internal cache in the processor, or is this related to the code instruction data that you can generate in an .asm/.inc file? Obviously this 'recommendation' is related to AMD and one family of processors, but there are alignment 'tips' sprinkled throughout this doc. Some are pretty crazy: Quote: "Only the first pick slot (of 4) can pick instructions greater than eight bytes in length. Avoid having more than one instruction in a sequence of four that is greater than eight bytes in length." |
|||
05 Feb 2020, 16:58 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.