[ovs-dev] [PATCH v10 1/1] Avoid dp_hash recirculation for balance-tcp bond selection mode

Ilya Maximets i.maximets at ovn.org
Wed Jan 22 19:49:50 UTC 2020


On 21.01.2020 21:54, Ben Pfaff wrote:
> On Mon, Jan 20, 2020 at 05:09:05PM +0100, Ilya Maximets wrote:
>>> +static struct tx_bond *
>>> +tx_bond_lookup(const struct hmap *hmap, uint32_t bond_id)
>>> +{
>>> +    struct tx_bond *tx;
>>> +
>>> +    HMAP_FOR_EACH_IN_BUCKET (tx, node, hash_bond_id(bond_id), hmap) {
>>
>> Why not HMAP_FOR_EACH_WITH_HASH ?
> 
> HMAP_FOR_EACH_IN_BUCKET is a small optimization over
> HMAP_FOR_EACH_WITH_HASH in cases where the comparison of the key is
> cheap.  Comparing the hash is an optimization if the key is expensive to
> compare (like an arbitrary string) but it just costs an extra integer
> comparison if the key is a small integer as here.

OK.  Thanks for explanation.
 
>> BTW, it's better to calculate hash before the loop to be sure that
>> we're not recalculating it on each iteration.
> 
> A lot of code assumes that the hash only gets evaluated once.
> 

Sure.  And there is no real issue here, but this just catches my eyes
for some reason.


More information about the dev mailing list