Hello Jay,


Monday, March 27, 2006, 12:25:36 PM, you wrote:

JS> On 3/27/06, Alexei Alexandrov <[EMAIL PROTECTED]> wrote:
>> >
>> > Isn't this eliminated with the proper compile settings for data packing?
>> > There should be a compile option for sometihng like 'align data on N
>> > byte boundaries'
>> >
>>
>> Even if that is possible, I don't want to say to compiler "Please
>> align everything on 16 bytes" because this will lead to huge memory
>> footprint overhead - every element - even 1 byte-long will take 16
>> bytes in memory. This is not an option.

JS> The compiler I used was smarter than that in the 1980's...

I agree. Typically it's just structure alignments so, for instance if
you had a char followed by a short in the struct, it would get padded
out to 16 bytes but, it wouldn't pad unless it had too. 15 chars
for instance would have a 1 byte pad. Structs HAVE to be aligned in
order to prevent unaligned access unless you're working with something
byte centric like a net protocol which requires you to work with no or
smaller alignments. The native alignment for my windows apps is 8
bytes. When I tried Visual Studio 2005, the default alignment was 16
bytes (which caused me some real problems till I figured it out).

Unless the on disk format is carried over into memory, there's no
reason not to use a structure alignment which prevents unaligned
access.

I'm a little surprised your compiler hadn't already padded the struct
out to proper alignment when you built SQLite.







-- 
Best regards,
 Teg                            mailto:[EMAIL PROTECTED]

Reply via email to