tcp: Use 4-tuple hash to optimize local port selection.
commit02353b181a6deaef5e813abfa1c41a2de5fbf49f
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 27 Oct 2015 12:43:11 +0000 (27 20:43 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 30 Oct 2015 03:39:54 +0000 (30 11:39 +0800)
tree9a44de3c324e6e5c29de8756cb5521698efec4bb
parent10039f4ea041c1d4ecee39c67f36a9f1510073d6
tcp: Use 4-tuple hash to optimize local port selection.

So that the connection can:
- Stay in the current netisr to avoid connection forwarding.
- Use the portinfo of the target netisr to avoid portinfo
  contention, if connection forwarding could not be avoided,
  e.g. when the ports of current netisr are depleted.

And don't try too hard to perform this local port selection
optimization (it's relative time consuming).  Number of tries
for this optimized local port selection is controlled by sysctl
node net.inet.ip.porthash_trycount (15 by default).  Setting
this sysctl node to 0 will disable this local port selection
optimization.

Total IPI rate and MP collision rate is significantly reduced,
when tools/kq_connect_client runs @395Kconns/s:
- Total IPI rate is reduced by 64K/s (421K/s -> 357K/s).
- Total MP collision rate is reduced by 81K/s (310K/s -> 229K/s).
sys/netinet/in_pcb.c