in dictadd we set new key in entry list head, but in rehash we will reverse it
Comment From: ohye3166
@oranagra hello, is necessary to do it?
Comment From: sundb
@ohye3166 In fact there is no reverse, i.g. there are 10 keys in slot 0 of the first table, after they are rehashed, they will be indifferent slots in the second table.
Comment From: ohye3166
@sundb for example before table[0][0] entry list is 1->2->3->4->5->6, 1 is the lastest insert ,but after rehash maybe in table[1][0] is 6->4->2 ,table[1][n] is 5->3->1, lastest one became the last. i think after rehash, we prefer to see 2->4->6 and 1->3->5
Comment From: oranagra
I think we don't care about the order of keys in that linked list.
in fact, considering the dictSetHashFunctionSeed mechanism, maybe it's better to keep the user on his toes, and not rely on the order.
Comment From: ohye3166
i think the point is whether there have more likely to use lastly insert value in common
Comment From: oranagra
i don't know if we can expect that or maybe the opposite (use first older ones more). either way, we aim to keep these lists very short (if the hash function distribution, and the rehashing threshold are good)
Comment From: sundb
@ohye3166 From a probabilistic point of view, when a dict is rehashed, the elements in the slot should also be evenly distributed, and it may consume more performance and not make much sense to keep it ordered.
Comment From: ohye3166
i don't know if we can expect that or maybe the opposite (use first older ones more). either way, we aim to keep these lists very short (if the hash function distribution, and the rehashing threshold are good)
we keep the list short ,because it's expensive to find a key when list long. is there a data about list long?i don't know if we can expect that or maybe the opposite (use first older ones more).
either way is there a willing to make a parameter for user to decide insert value in list head or tail?
Comment From: sundb
@ohye3166 Opening a parameter that the user doesn't even care about will only confuse the user. Any element that appears in a slot at a certain point in time is actually random (related to random seeds), and when you insert a piece of data, then restart the server, all the elements will be messed up again.
Comment From: ohye3166
tks
Comment From: oranagra
closing this.. as stated, even if we could change this, it probably doesn't have any actual effect, and even when it does, there's no one that can predict if the effect is for the better or the worse. (adding a config for that is certainly wrong too)