Re: Re: Re: Re: why lua table don't use prime number to hash
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Re: Re: Re: why lua table don't use prime number to hash
- From: Roberto Ierusalimschy <roberto@...>
- Date: 2021年3月12日 10:55:57 -0300
> I had test the two hashint macro. and when insert 10000000 keys, the new macro cost about 2.7s, while old macro cost about 4s.
>
> this is indeed faster.
>
>
>
> and I also test the three hashint macro by use auto increase int key. this is the test lua code:
>
> [...]
Many thanks for the feedback.
The new macro is obviously faster, but it is also more sensitive to
bad patterns (e.g., «for i = 1, 1e5 do a[(i << 32) | i] = i end»).
If we want a good hash, it may be worth paying the price of a full
64-bit modulo.
-- Roberto