[ovs-dev] [optimize 19/26] mac-learning: Speed up mac_table_hash().

Ben Pfaff blp at nicira.com
Wed Apr 18 02:52:10 UTC 2012


On Tue, Apr 17, 2012 at 07:22:49PM -0700, Ethan Jackson wrote:
> > -    return hash_bytes(mac, ETH_ADDR_LEN, vlan ^ ml->secret);
> > +    unsigned int mac1 = get_unaligned_u32((uint32_t *) mac);
> > +    unsigned int mac2 = get_unaligned_u16((uint16_t *) (mac + 4));
> > +    return hash_3words(mac1, mac2 | (vlan << 16), ml->secret);
> 
> Would we get better hash distribution if we did something like:
> hash_3words(mac1, mac2, ml->secret ^ vlan)?  OR ing seems a bit
> strange to me, but I may not fully understand the algorithm.

mac2 and vlan are both 16 bits, so this doesn't overlap any bits.



More information about the dev mailing list