Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Aug 2013 10:45:13 -0600
From:      Alan Somers <asomers@freebsd.org>
To:        "T.C. Gubatayao" <tgubatayao@barracuda.com>
Cc:        Jack F Vogel <jfv@freebsd.org>, "Justin T. Gibbs" <gibbs@freebsd.org>, Andre Oppermann <andre@freebsd.org>, Alan Somers <asomers@freebsd.org>, "net@freebsd.org" <net@freebsd.org>
Subject:   Re: Flow ID, LACP, and igb
Message-ID:  <CAOtMX2h5SGh5eYV50y%2BQB_s367V9iattGU862wwXcONDV%2BTG8g@mail.gmail.com>
In-Reply-To: <BCC2C62D4FE171479E2F1C2593FE508B0BE24383@BN-SCL-MBX03.Cudanet.local>
References:  <D01A0CB2-B1E3-4F4B-97FA-4C821C0E3FD2@FreeBSD.org> <521BBD21.4070304@freebsd.org> <CAOtMX2jvKGY==t9i-a_8RtMAPH2p1VDj950nMHHouryoz3nbsA@mail.gmail.com> <521EE8DA.3060107@freebsd.org> <BCC2C62D4FE171479E2F1C2593FE508B0BE24383@BN-SCL-MBX03.Cudanet.local>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 29, 2013 at 1:27 AM, T.C. Gubatayao <tgubatayao@barracuda.com>wrote:

> > No problem with fnv_hash().
>
> Doesn't it have bad mixing?  Good distribution is important since this
> code is
> for load balancing.
>

The poor mixing in FNV hash comes from the 8-bit XOR operation.  But that
provides fine mixing of the last 8 bits, which should be sufficient for
lagg_hash unless people are lagging together > 256 ports.


>
> FNV is also slower compared to most of the newer non-cryptographic hashes,
> certainly on large keys, but even on small ones.  Of course, performance
> will
> vary with the architecture.
>
> > While I agree that it is likely that siphash24() is slower if you could
> afford
> > the time do a test run it would be great to from guess to know.
>
> +1


> You might want to consider lookup3 too, since it's also readily available
> in the
> kernel [1].
>

I pulled all four hash functions out into userland and microbenchmarked
them.  The upshot is that hash32 and fnv_hash are the fastest, jenkins_hash
is slower, and siphash24 is the slowest.  Also, Clang resulted in much
faster code than gcc.

http://people.freebsd.org/~asomers/lagg_hash/

[root@sm4u-4 /usr/home/alans/ctest/lagg_hash]# ./lagg_hash-gcc-4.8
FNV: 0.76
hash32: 1.18
SipHash24: 44.39
Jenkins: 6.20
[root@sm4u-4 /usr/home/alans/ctest/lagg_hash]# ./lagg_hash-gcc-4.2.1
FNV: 0.74
hash32: 1.35
SipHash24: 55.25
Jenkins: 7.37
[root@sm4u-4 /usr/home/alans/ctest/lagg_hash]# ./lagg_hash.clang-3.3
FNV: 0.30
hash32: 0.30
SipHash24: 55.97
Jenkins: 6.45
[root@sm4u-4 /usr/home/alans/ctest/lagg_hash]# ./lagg_hash.clang-3.2
FNV: 0.30
hash32: 0.30
SipHash24: 44.52
Jenkins: 6.48



> T.C.
>
> [1]
> http://svnweb.freebsd.org/base/head/sys/libkern/jenkins_hash.c?view=markup



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2h5SGh5eYV50y%2BQB_s367V9iattGU862wwXcONDV%2BTG8g>