<p dir="ltr"><br>
On 31 Mar 2015 02:19, "Eric Anholt" <<a href="mailto:eric@anholt.net">eric@anholt.net</a>> wrote:<br>
><br>
> Thomas Helland <<a href="mailto:thomashelland90@gmail.com">thomashelland90@gmail.com</a>> writes:<br>
><br>
> > This should give better cache locality, less memory consumption,<br>
> > less code, and should also be faster since we avoid a modulo operation.<br>
> > Also change table size to be power of two.<br>
> > This gives better performance as we can do bitmasking instead of<br>
> > modulo operations for fitting the hash in the address space.<br>
> > By using the algorithm hash = sh + i/2 + i*i/2<br>
> > we are guaranteed that all retries from the quad probing<br>
> > are distinct, and so should be able to completely fill the table.<br>
> > This passes the test added to exercise a worst case collision scenario.<br>
> > Also, start at size = 16 instead of 4.<br>
> > This should reduce some allocation overhead<br>
> > when constantly using tables larger than 3 entries.<br>
> > The amount of space used before rehash is changed to 70%.<br>
> > This should decrease collisions slightly, leading to better performance.<br>
><br>
> I've run a test to confirm that the (i + i * i) / 2 probing does<br>
> actually get us unique values, up to a maximum table size of (1 << 31)<br>
> entries.</p>
<p dir="ltr">Cool!<br>
I just trusted the article blindly, nice to have it confirmed.</p>
<p dir="ltr">><br>
> The amount-filled-before-rehash should probably be a separate commit,<br>
> since it's increasing memory overhead, and each commit have its own<br>
> performance data justifying it (actually, it looks like that's missing<br>
> From this commit message). Similarly for start size = 16 instead of 4.<br>
> I wouldn't mind set/hash changes being in the same commits, though.</p>
<p dir="ltr">I agree, sounds like a good plan.<br>
The performance data is indeed missing from the message.<br>
I rebased it in, but f'ed up and used the old commit id when sending out.<br>
Maybe I should include the 15'ish top performance hogs for each commit?<br>
Or stick them in the cover letter?<br>
Might be nice to get a full understanding of the effect things have.<br>
At least for upping the starting size this affects the whole top 10 list.<br>
So percentage of total will get skewed for everything else.<br>
I'll get a new version out by the weekend probably.</p>