Re: Good hash for pointers

Liste des GroupesRevenir à cl c 
Sujet : Re: Good hash for pointers
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.c
Date : 03. Jun 2024, 18:16:46
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240603201646.0000319d@yahoo.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
User-Agent : Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
On Mon, 3 Jun 2024 17:24:36 +0100
bart <bc@freeuk.com> wrote:

On 03/06/2024 16:54, Bonita Montero wrote:
Am 03.06.2024 um 16:46 schrieb Michael S: 
On Mon, 3 Jun 2024 16:34:37 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
 
Am 02.06.2024 um 09:45 schrieb Michael S:
 
So, what were your conclusions?
Ignoring the speed of computation, would something like
cryptographic hash scaled to bucket size be a best hash for this
type of application? Or some sort of less thorough grinding of
the bits is better? 
>
There's no need for a crypto-hash here.
 
>
Do you think I don't know?
Crypto hash is just an example of near-ideal pseudo-random
uniformity.
 
As I've shown for pointers you get a perfect equal distribution with
multiplying by an appropriate prime.
 
 
A pointer with 8-byte or 16-byte alignment will have the bottom 3-4
bits zero.
 
No matter what number you multiply them by, prime or otherwise, those
3-4 bits will always be zero.
 
If you mask the result to fit a table of size power-of-two, then the
resulting index will can only ever refer to every 8th or every 16th
slot; there will 8-16x as many clashes as there ought to be.
 
So some extra work is needed to get around that, for example
right-shifting before masking as some here have done, something you
have never mentioned.
 
 

According to my understanding, Bonita and Tim are discussing hash
generator which output is not used as is. They assume that index of
the slot will be calculated as (Hash(key)*bucket_size)/(Hash_max+1).
For big enough Hash_max (Bonita suggests 2**63-1), poor quality of
few LS bits of Hash(key) does not matter.








Date Sujet#  Auteur
2 Jun 24 * Re: Good hash for pointers21Michael S
2 Jun 24 +* Re: Good hash for pointers2Chris M. Thomasson
3 Jun 24 i`- Re: Good hash for pointers1Chris M. Thomasson
3 Jun 24 +* Re: Good hash for pointers5Tim Rentsch
3 Jun 24 i`* Re: Good hash for pointers4Michael S
4 Jun 24 i `* Re: Good hash for pointers3Tim Rentsch
4 Jun 24 i  `* Re: Good hash for pointers2Michael S
5 Jun 24 i   `- Re: Good hash for pointers1Tim Rentsch
3 Jun 24 `* Re: Good hash for pointers13Bonita Montero
3 Jun 24  `* Re: Good hash for pointers12Michael S
3 Jun 24   `* Re: Good hash for pointers11Bonita Montero
3 Jun 24    +* Re: Good hash for pointers8bart
3 Jun 24    i+* Re: Good hash for pointers6Michael S
3 Jun 24    ii+* Re: Good hash for pointers4bart
3 Jun 24    iii+- Re: Good hash for pointers1Michael S
3 Jun 24    iii+- Re: Good hash for pointers1Michael S
4 Jun 24    iii`- Re: Good hash for pointers1Tim Rentsch
4 Jun 24    ii`- Re: Good hash for pointers1Tim Rentsch
3 Jun 24    i`- Re: Good hash for pointers1Bonita Montero
3 Jun 24    `* Re: Good hash for pointers2Michael S
3 Jun 24     `- Re: Good hash for pointers1Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal