Re: Bloated Struct Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually, I was under the impression that the sizeof(my_type_t) should
be 24 to guarantee 8-byte alignment of the 8-byte types?  In other
words, I would have expected 24 bytes instead of 20.  Can anyone
explain why it's only 20?  Indeed on my 64 bit machine it is 24 bytes,
but is that an artifact of being on x86-64?

Thanks,
  Brian

On Fri, Jun 5, 2009 at 12:42 AM, me22<me22.ca@xxxxxxxxx> wrote:
> 2009/6/4 . . <pkejjy@xxxxxxxxx>:
>> If so, that would be a bad performance decision in this
>> multicore world, where memory footprint size matters much more than
>> alignment, generally speaking.
>>
>
> But sharing of cache lines between unrelated things can be even worse.
>
> And as you said, the point is to make the 64-bit ints properly aligned
> when arrays of the type are used.  There are numerous architectures
> which cannot read mis-aligned types, and those that can are usually
> fairly slow at it -- especially when then end up straddling cache
> lines, as an array of 17-byte structs certainly would, at some point.
>
> There is, iirc, an __attribute__ that'll let you pack it, if you
> insist.  Do you have profiler feedback that says it actually matters?
>


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux