I have my hash table set to size = 16 modparam("htable", "htable", "a=>size=16;autoexpire=0;dbtable=htable;")
I had around 3000 entries in that table, some entries with more than 10 duplicate keys (key_type = 1) and we found that when reading the entries of the duplicated keys it could not go pass index 9 even though in the physical table there were 17 entries. I deleted some old entries and now the table is about 2000 items and it seems to work properly again ,(loads all value in memory). I say seems because I can not dump all values: ``` ./kamcmd htable.dump a ERROR: reply too big ```
But I check manually all the ones that were not being loaded and they are now Questions: 1- the size parameter is for the buckets or entries size ? 2- is 16 a good value for a table with 3000 entries? ( 2^16 is 65k so I figured it would be ok) 3- can the the way I define my key impose a limitation? 4- what is the max size for an htable to be dumped with the above command?
Duplicate key names (or arrays) are actually stored in hash table with distinctive keys, the key for hash table being the string built like `key[index]`.
The size attribute is for the number of buckets (slots) for the hash table, not the number of items that can be stored in the hash table. The number of items is limited by the shared memory, when it is no more enough free shared memory, then you get memory errors and new items no longer stored in hash table. The number of slots has relevance in searching for items, making it faster if there are no very many items on a bucket (slot).
At 3000 items, even size=12 (2^12 = 4096 slots) results in more slots than items, but of course there can be hashid collisions and many items stored in the same slot. Each slot keeps a linked list of values. Items are not deleted on hashid collision, they are just added to the same slot in the linked list.
For 3. maybe you can give explicit examples to be able to comment more.
For 4 you have to change the values of ctl module parameters related to buffers. Or try `kamctl rpc htable.dump a`, you need to use jsonrpcs module.
thank you Daniel 3- the key is created as follows: a.b.c.d:5060:X.Y.Z where "a.b.c.d" is the IP where we receive the call on, IP of the proxy "X.Y.Z" are the first 3 octets of the source IP, customer sending calls to the proxy
some times they are very similar for example 10.20.30.41:5060:10.20.30
for 4 I will look into your suggestion
by the way the kamailio has 16 GB of ram, this is the output of "kamcmd core.shmmem"
`[root@aw-atl-proxy-02 sbin]# ./kamcmd core.shmmem { total: -2147483648 free: 2108379744 used: 37308232 real_used: 39103904 max_used: 39571432 fragments: 6458 } `
That style of key for 3) is ok, there should be no problem with them.
So this looks like usage issues, needs tuning of modparams for ctl module for full output or use jsonrpcs module. kamcmd is also supporting only signed int, printing large numbers in negative value.
I am closing this one, let's discuss on sr-users if you still have issues getting them working as expected. If proves to be some issue in the code, this can be reopen.
Closed #2311.
ok, thank you Daniel