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).