[Kamailio-Users] What happens with filled htables?
Alex Balashov
abalashov at evaristesys.com
Wed Aug 26 16:14:13 CEST 2009
Daniel-Constantin Mierla wrote:
> just to be sure everyone got it right regarding the size attribute in
> htable parameter ... the number of slots for hash table is 2^size (2
> power size). So, size=4 means that the hash table has 16 slots.
>
> Reason for that is the speed in getting the slot number - modulo
> function is very fast in such cases, the slot number being actually a
> bitwise operation: hash_value & (2^size - 1)
> --- 2^size is cached at startup.
Thanks, that was a much-needed clarification omitted from my explanation.
I have always been told that table sizes that are prime numbers result
in better distribution of factors due to the way modulo works, although
I am not a mathematician and don't have a ready understanding of why.
Is this true? Is there some reason you did not take this approach? Is
hash_value & 2(^size - 1) equally fast?
--
Alex Balashov - Principal
Evariste Systems
Web : http://www.evaristesys.com/
Tel : (+1) (678) 954-0670
Direct : (+1) (678) 954-0671
More information about the Users
mailing list