[Freeciv-Dev] Re: (PR#3781) Micro size of structs optimizations
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, Mar 24, 2003 at 09:18:57AM -0800, Rafa³ Bursig wrote:
>
> Hi
>
> As I know "bool" type is unisgnet char
This is set by your compiler and not be the standard.
> then we can sort all this type ( and others ) variable than gcc can
> pack it in one 32 bit field. This problem touch all types < int
> (32bits) and by sorting we can reduce size of some game
> structs. This is rather micro optimizations but can be done without
> cost.
There are two issues here:
- size reduction to get better cache behavior:
* by removing gaps (gcc has -Wpadded to catch these)
* by reducing the used size of the fields
- better cache behavior by better arrangement of the fields
All of the above are not necessary all win solutions. For example it
may be better to let the compiler add 3 bytes as padding after each
bool but get a faster access this way (unalign access is slow on i386
and impossible on other archs).
Since all this is depends very much on your compiler and the
CPU/cache/memory you have I think we shouldn't try to change
this. Unless you show numbers for various compilers and archs.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"If at first you don't succeed... well so much for skydiving."
|
|