Toni:

Toni Cassisi <[EMAIL PROTECTED]> wrote: Keep in mind my main reason for asking 
was due to the VS2005 fussiness,
something that could perhaps be a deficiency in its checking logic.


Thank you for pointing this out.  It does not show up in the gcc compilers and 
therefore overlooked.


It looks like the "-" business first mentioned is to do with the weird
decision by Judy to store the remaining memory as opposed to the used
memory, so provided standard add/subtract are used, then doing a negate with
"-" is correct. 

The problem is the comments around the second use in JudyPrivate.h:
#define JU_MASKLOWEREXC( BITPOS)  ((BITPOS) - 1)
#define JU_MASKLOWERINC( BITPOS)  (JU_MASKLOWEREXC(BITPOS) | (BITPOS))
#define JU_MASKHIGHERINC(BITPOS)  (-(BITPOS))
#define JU_MASKHIGHEREXC(BITPOS)  (JU_MASKHIGHERINC(BITPOS) ^ (BITPOS))

I'm not sure how to prove what the intention was, but they seem to be used
only for walking the JArray in sorted order OR to count the number of items.

Example:    "-x"  is equivalent to "~x + 1", so if the bitarray=0100 (base
2) and:

bitpos=3=0011, then, ~bitpos=1100 but -bitpos=1101
bitpos=2=0010, then, ~bitpos=1101 but -bitpos=1110

So far, ignoring the warning doesn't seem to have caused any problems in my
(limited) testing. 


Your missing the intention of the macros:  Generate a mask from a word
that only has one bit set.  It is used for counting bits above or below a
certain Index(key).  Notice that "EXC" mean exclusive and "INC" means
inclusive.  The code is correct, the syntax is flawed.


* Update on the buffer overrun:

The same thing occurs with the JudyL sources, no surprise really as they are
pretty similar.

However, I setup for Release mode, then ran all the source through the
pre-processor only then post-formatted it automatically with VS and things
are a lot clearer now: for me at any rate.

What is interesting is that I now never have any memory issues flagged up. 

Perhaps the problem is due to an unintended side effect buried somewhere in
the DBGCODE() statements, or whatever else is being excluded by undefining
the DEBUG/_DEBUG et al variable?

I'm working to that theory for now.

Don't waste any more time on this.  It must be the sizeof(Pj1pm_t) and
sizeof(PjLpm_t) is not a mulitiple of a sizeof(Word_t).  I will work on the 
correct fix.




* Final question

If trying to return-and-remove any item from within the set (managed by a
Judy1 structure), is it quicker to search from the first index or the
highest index?

The speed in a modern computer should be the same in the average case.  The 
speed is really a function of what, where and the size of the
array.  Modern machines are all about cache-line misses, so you will find
even measuring the performance frought with prior access problems.


I presume the JudyL and Judy1 are very similar in performance, although
there must be some differences due to the different data layouts.

Judy1 is only a little faster in a modern machine.  It has several basic
advantages over JudyL.  1) Leaves are much smaller because the "Value" is 
missing, 2) Immediate data formats are much larger with the same
amount of memory,  3) The "high density" data is stored as a bitmap and 
thus uses and lot less memory (I.E.  32[64] times less).  "high density" data 
is when the average distance between the Indexes is small (<15).
Where as JudyL is always burdened with a full word of "Value".


Regards,
 
Toni.


Thanks for your interest.

Doug Baskins


 
----
Toni Cassisi
Tovica Ltd
http://www.tovica.com
Tel: +44 (0) 7971 874 054
IM: AOL/Yahoo/MSN: tcassisi
> -----Original Message-----
> From: Alan Silverstein [mailto:[EMAIL PROTECTED]
> Sent: 04 May 2007 16:36
> To: [email protected]; [EMAIL PROTECTED]
> Subject: Re: Issue with Bit mask and Buffer Overruns
> 
> Toni et al, I know Doug was very comfortable with ~ and - operators and
> sometimes used them purposely without special commenting (where I might
> have explained the assumptions).  Beyond that I need to save, study,
> and
> reply at greater length to your email later, unless Doug beats me to
> it.
> 
> Alan


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel



Doug Baskins <[EMAIL PROTECTED]>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel

Reply via email to