At 23:25 30/05/2007, you wrote:
>--- [EMAIL PROTECTED] wrote:
>> ----- Original Message ----
>> > MemPage bitfield patch below.
>> >
>> > sizeof(MemPage) on Linux:
>> >
>> > original: 84
>> > patched: 76
>> > ...
>> > Break-even for memory is 904/8 = 113 MemPage structs allocated.
>>
>> I didn't look at the code, so mind me :)
>>
>> If the MemPage are malloced individually (instead of being put in arrays),
>> then they are 16 byte
>> aligned on most platforms, making the allocated block effectively the same
>> size (well, that
>> depends on how many bytes are used by malloc before the user block in
>> memory).
>
>This patch does indeed save memory - on Linux at least.
>Linux has a malloc mimimum resolution of 8 bytes, not 16.
No, for example, under powerpc and linux with altivec enabled in kernel it's 16
bytes (or use www.freevec.org library). I think under other simd capable
processors it's 16 bytes too.
>> Also, my take on bitfields is that they are not thread/multi processor
>> friendly (there is no
>> atomic "set bit"), and also compilers typically don't optimize well with
>> that (so before
>> applying this patch, I would test on other platforms than gcc linux x86).
>
>Setting and reading individual bytes (u8 in sqlite-speak) are not
>threadsafe either. Only reading/setting entire entire words
>are threadsafe on most architectures.
Using a uint32 for store the flags is threadsafe. There are less than 32
true/false values and read/set is simple. I see no difference doing
if (uint8==0){ // read/test bit
uint8=1; // set bit
whatever more
}
and
if (uint32&&MASK){ // read/test bit
uint32&&=MASK; // set bit
whatever
}
in speed, and a compiler should not make worse code on last one. So say
>> Also, my take on bitfields is that they are not thread/multi processor
>> friendly (there is no
>> atomic "set bit"), and also compilers typically don't optimize well with
>> that (so before
>> applying this patch, I would test on other platforms than gcc linux x86).
is not true.
----------------------------------------------------------------------------------
Dios es real, a no ser que esté declarado como entero...
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------