Page MenuHomeFreeBSD

tcp: Use jenkins_hash32() in hostcache
ClosedPublic

Authored by rscheff on Mar 31 2021, 4:19 PM.
Tags
None
Referenced Files
F168859459: D29515.id.diff
Sun, Aug 30, 11:59 AM
F168844902: D29515.diff
Sun, Aug 30, 10:22 AM
F168813894: D29515.id87058.diff
Sun, Aug 30, 7:02 AM
F168679497: D29515.id86626.diff
Sat, Aug 29, 2:25 PM
F168675730: D29515.id87051.diff
Sat, Aug 29, 2:01 PM
F168673428: D29515.diff
Sat, Aug 29, 1:46 PM
Unknown Object (File)
Thu, Aug 27, 3:56 AM
Unknown Object (File)
Thu, Aug 27, 1:42 AM
Subscribers

Details

Summary

While investigating the reported hostcache
issues and adding a histogram to look at the
distribution of used hashbuckets, and
bucketdepth, I found that the exteremly
fast XOR "hash" would result in a rather
skewed utilization of the hostcache, for
randomly selected remote IP addresses.

As other parts of the base tcp stack (eg.
tcp fastopen) already use jenkins_hash32,
and the properties appear reasonably good,
switching to use that.

Test Plan

Anecdotal evidence (single trial, using
approximately 1000 randomly selected hosts,
overall, but ~400 for XOR and ~600 for Jenkins):

Unused Hash buckets: XOR ~51%, Jenkins ~35%
Average Bucket Depth: XOR ~2.44, Jenkins ~1.54

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 38425
Build 35314: arc lint + arc unit

Event Timeline

ae added inline comments.
sys/netinet/tcp_hostcache.c
222

Maybe would it be better to use full IPv6 address to compute hash?

ae added inline comments.
sys/netinet/tcp_hostcache.c
222

ah, sorry for the noise :)

transport call: initialize salt randomly, and change it when purging, when triggereing purge with "2" instead of "1".

  • initialize the hash salt with a random number
  • reseed the salt when purging all entries with "2"
  • adding man entries for all hostcache related sysctls
This revision is now accepted and ready to land.Apr 8 2021, 5:58 PM
This revision now requires review to proceed.Apr 8 2021, 6:25 PM
This revision is now accepted and ready to land.Apr 8 2021, 6:31 PM
This revision was automatically updated to reflect the committed changes.