From owner-freebsd-net@FreeBSD.ORG Thu Aug 29 16:45:15 2013 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 17E6A5AE; Thu, 29 Aug 2013 16:45:15 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-qa0-x233.google.com (mail-qa0-x233.google.com [IPv6:2607:f8b0:400d:c00::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 851C2273F; Thu, 29 Aug 2013 16:45:14 +0000 (UTC) Received: by mail-qa0-f51.google.com with SMTP id bv4so561234qab.17 for ; Thu, 29 Aug 2013 09:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=HAyNn9bc3yaMa1x5xVTCmpi6ny00uipYeGPrsNlbhdk=; b=Q0IVXH1ksA0z0LLG7P4FpTpfLN6uun8FIlmCgIUGcNaHfxxdoDZnTNnWv6GqU6b5lI 9zlXV4dyxWKobcttaYvssbvZ9RBzMZw8QNGZ7g+737HR7mxLn2VrSyBp7P9e0rQ8Y0eb p4c9pWamP6QRSkjLIJIHhyG2ig+sA11JnwU25eukaoln93Sczh+JhGKfIg5AExnz8VI9 /Xbx0sEBSHzN8jdE9ACUGEGnpxeGayBLsT8112dCyGm+VXGOhCF7s+ePII4aBNGvwWDS WtSP9gtXEHak9y4svuFXO5HmhLgJjdYpxJndcmAr/2f/nqVsTBi6Tsq8Nga5yyTrznnI n4Aw== MIME-Version: 1.0 X-Received: by 10.224.122.195 with SMTP id m3mr6296790qar.9.1377794713672; Thu, 29 Aug 2013 09:45:13 -0700 (PDT) Sender: asomers@gmail.com Received: by 10.49.39.101 with HTTP; Thu, 29 Aug 2013 09:45:13 -0700 (PDT) In-Reply-To: References: <521BBD21.4070304@freebsd.org> <521EE8DA.3060107@freebsd.org> Date: Thu, 29 Aug 2013 10:45:13 -0600 X-Google-Sender-Auth: 7eBMBpBK73wvS-Ufq7TRJZINz8s Message-ID: Subject: Re: Flow ID, LACP, and igb From: Alan Somers To: "T.C. Gubatayao" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Jack F Vogel , "Justin T. Gibbs" , Andre Oppermann , Alan Somers , "net@freebsd.org" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Aug 2013 16:45:15 -0000 On Thu, Aug 29, 2013 at 1:27 AM, T.C. Gubatayao 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