openvswitch / ovs-issues

Issue tracker repo for Open vSwitch
10 stars 3 forks source link

new connection stress test scenario for ct : conn_key_hash() function lead to large number of hash conflicts #287

Closed AsherBrook closed 1 year ago

AsherBrook commented 1 year ago

Now we conduct performance testing of CT's new connection,we used 10000 dports and 200 source IPs.But during the connection lookup with hash , we found that it occure a large number of hash conflicts; Both emc_cache and CT connections use cmap, mainly using same tuples as hash keys, but there are no hash conflicts in emc, So I conducted an experiment,using : hash = hash_add(hash, hsrc); hash = hash_add(hash, hdst); replace of hash = hsrc ^ hdst; Then the problem was solved, so I want to know why XOR calculation is used here instead of following emc_cache hash of hash_add() method.Is there anything special about XOR here? Looking forward to your answer,thanks.

igsilya commented 1 year ago

Is there anything special about XOR here?

The reason for XOR is explained in the comment: https://github.com/openvswitch/ovs/blob/f5188ff2147517612b410ed607e3843cdf4b51a6/lib/conntrack.c#L2187 i.e. the hash has to be symmetric, othwerwise you will not be able to find the connection in the other direction. And the hash_add is not symmetric.

Both emc_cache and CT connections use cmap,

EMC cache doesn't use cmap.

AsherBrook commented 1 year ago

@igsilya I konw, Thanks for your repley.