Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936640AbcLUP5E (ORCPT ); Wed, 21 Dec 2016 10:57:04 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35453 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936446AbcLUP5B (ORCPT ); Wed, 21 Dec 2016 10:57:01 -0500 Message-ID: <1482335804.8944.44.camel@edumazet-glaptop3.roam.corp.google.com> Subject: Re: HalfSipHash Acceptable Usage From: Eric Dumazet To: "Jason A. Donenfeld" Cc: George Spelvin , "Theodore Ts'o" , Andi Kleen , David Miller , David Laight , "Daniel J . Bernstein" , Eric Biggers , Hannes Frederic Sowa , Jean-Philippe Aumasson , kernel-hardening@lists.openwall.com, Linux Crypto Mailing List , LKML , Andy Lutomirski , Netdev , Tom Herbert , Linus Torvalds , Vegard Nossum Date: Wed, 21 Dec 2016 07:56:44 -0800 In-Reply-To: References: <20161221032829.3031.qmail@ns.sciencehorizons.net> <1482298164.8944.8.camel@edumazet-glaptop3.roam.corp.google.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2263 Lines: 67 On Wed, 2016-12-21 at 15:42 +0100, Jason A. Donenfeld wrote: > Hi Eric, > > I computed performance numbers for both 32-bit and 64-bit using the > actual functions in which talking about replacing MD5 with SipHash. > The basic harness is here [1] if you're curious. SipHash was a pretty > clear winner for both cases. > > x86_64: > [ 1.714302] secure_tcpv6_sequence_number_md5# cycles: 102373398 > [ 1.747685] secure_tcp_sequence_number_md5# cycles: 92042258 > [ 1.773522] secure_tcpv6_sequence_number_siphash# cycles: 70786533 > [ 1.798701] secure_tcp_sequence_number_siphash# cycles: 68941043 > > x86: > [ 1.635749] secure_tcpv6_sequence_number_md5# cycles: 106016335 > [ 1.670259] secure_tcp_sequence_number_md5# cycles: 95670512 > [ 1.708387] secure_tcpv6_sequence_number_siphash# cycles: 105988635 > [ 1.740264] secure_tcp_sequence_number_siphash# cycles: 88225395 > > >>> 102373398 > 70786533 > True > >>> 92042258 > 68941043 > True > >>> 106016335 > 105988635 > True > >>> 95670512 > 88225395 > True > > While MD5 is probably faster for some kind of large-data > cycles-per-byte, due to its 64-byte internal state, SipHash -- the > "Sip" part standing "Short Input PRF" -- is fast for shorter inputs. > In practice with the functions we're talking about replacing, there's > no need to hash 64-bytes. So, SipHash comes out faster and more > secure. > > I also haven't begun to look focusedly at the assembly my SipHash > implemention is generating, which means there's still window for even > more performance improvements. > > Jason > > > [1] https://git.zx2c4.com/linux-dev/tree/net/core/secure_seq.c?h=siphash-bench#n194 Now I am quite confused. George said : > Cycles per byte on 1024 bytes of data: > Pentium Core 2 Ivy > 4 Duo Bridge > SipHash-2-4 38.9 8.3 5.8 > HalfSipHash-2-4 12.7 4.5 3.2 > MD5 8.3 5.7 4.7 That really was for 1024 bytes blocks, so pretty much useless for our discussion ? Reading your numbers last week, I thought SipHash was faster, but George numbers are giving the opposite impression. I do not have a P4 to make tests, so I only can trust you or George. Thanks.