Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-06-02 Thread Nuno Lucas
On 6/2/07, Eduardo Morras <[EMAIL PROTECTED]> wrote: At 17:18 31/05/2007, you wrote: >On 5/31/07, Eduardo Morras <[EMAIL PROTECTED]> wrote: >>At 23:25 30/05/2007, you wrote: >>>Setting and reading individual bytes (u8 in sqlite-speak) are not >>>threadsafe either. Only reading/setting entire enti

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-06-02 Thread Eduardo Morras
At 17:18 31/05/2007, you wrote: >On 5/31/07, Eduardo Morras <[EMAIL PROTECTED]> wrote: >>At 23:25 30/05/2007, you wrote: >>>Setting and reading individual bytes (u8 in sqlite-speak) are not >>>threadsafe either. Only reading/setting entire entire words >>>are threadsafe on most architectures. >> >>

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-31 Thread Ken
One needs to make use of CAS or LL/SC hardware instructions. These can be used to implement lock-free synchronization. Nuno Lucas <[EMAIL PROTECTED]> wrote: On 5/31/07, Eduardo Morras wrote: > At 23:25 30/05/2007, you wrote: > >Setting and reading individual bytes (u8 in sqlite-speak) are no

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-31 Thread Nuno Lucas
On 5/31/07, Eduardo Morras <[EMAIL PROTECTED]> wrote: At 23:25 30/05/2007, you wrote: >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 threa

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Eduardo Morras
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

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Joe Wilson
> > 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). >

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Dennis Cote
Joe Wilson wrote: Generally structs are aligned on 8-byte boundaries, so making isInited a bitfield wouldn't save any additional space in this particular case. You can combine the other bitfields with isInited at the beginning of the structure and save a byte later in the structure. Den

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Joe Wilson
--- Dennis Cote <[EMAIL PROTECTED]> wrote: > Joe Wilson wrote: > > > > If an external interface changed, sure. But these internal structs > > change constantly from (minor) release to release. > > > > The struct in question is used solely by btree.c, so the ordering > > and layout for bit fields

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Joe Wilson
--- [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 :) > >

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread spaminos-sqlite
- Original Message > From: Dennis Cote <[EMAIL PROTECTED]> > To: sqlite-users@sqlite.org > Sent: Wednesday, May 30, 2007 12:09:25 PM > Subject: Re: [sqlite] sqlite internal structs don't make use of C bitfields? > You may want to look at how the isInited fiel

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Dennis Cote
Joe Wilson wrote: If an external interface changed, sure. But these internal structs change constantly from (minor) release to release. The struct in question is used solely by btree.c, so the ordering and layout for bit fields on different compilers or different platforms do not matter.

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread spaminos-sqlite
- 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 b

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Joe Wilson
--- Dennis Cote <[EMAIL PROTECTED]> wrote: > There are also some issues with regard to the ordering and layout > of bitifleds in cross platform applications. I suspect that is the > reason they aren't used. If an external interface changed, sure. But these internal structs change constantly fro

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Joe Wilson
MemPage bitfield patch below. sizeof(MemPage) on Linux: original: 84 patched: 76 Patched "make test" runs without regressions on Linux and Windows. Timings for "make test" (elapsed): original: 1:20.74 patched: 1:20.22 Size of sqlite3.o when compiled from almalogmation with all sql

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Dennis Cote
Joe Wilson wrote: You could save a few bytes in some sqlite internal structs if you'd use C bitfields for boolean flags: For example: struct MemPage { u8 isInit; /* True if previously initialized. MUST BE FIRST! */ u8 idxShift; /* True if Cell indices have changed */ u8

Re: [sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Joe Wilson
struct MemPage2 { u8 nOverflow;/* Number of overflow cell bodies in aCell[] */ u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ u8 hdrOffset;/* 100 for page 1. 0 otherwise */ u8 isInit:1; /* True if previously initialized. MUST BE FIRST! */ Okay, maybe not

[sqlite] sqlite internal structs don't make use of C bitfields?

2007-05-30 Thread Joe Wilson
You could save a few bytes in some sqlite internal structs if you'd use C bitfields for boolean flags: For example: struct MemPage { u8 isInit; /* True if previously initialized. MUST BE FIRST! */ u8 idxShift; /* True if Cell indices have changed */ u8 nOverflow;/*