Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eTSkO-0001V4-JH for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Dec 2017 13:24:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eTSkN-0006e5-2W for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Dec 2017 13:24:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eTSkM-0006dv-Kb for pgsql-hackers@lists.postgresql.org; Mon, 25 Dec 2017 13:24:50 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eTSkD-0000cy-T7 for pgsql-hackers@postgresql.org; Mon, 25 Dec 2017 13:24:49 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 30D0021C1AA1; Mon, 25 Dec 2017 16:24:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from zilders-MacBook-Pro.local (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id F219B21C03E8; Mon, 25 Dec 2017 16:24:38 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1514208279; bh=B/X0b6nVyg0Rc5WkxeMAdEBg4bQ1petQKYP80g6fBnM=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=FJJYZ3snbm9SBbwDdVH8Wmv/WRuJahzRud0LNsP+ypenqpq8YCBS9T0r2DqQJYeKm fZA5Paf4dUPifGRWOhZFhS/bR0r/0Xzdu75zR1MglSTlaB8EzyMU1tjEYY1HwUKdyw +rM5RDzGWmlTZYyRg77zwujNUWvoZHq3qMJtM95E= Subject: Re: General purpose hashing func in pgbench To: Fabien COELHO Cc: pgsql-hackers References: <0e8bd39e-dfcd-2879-f88f-272799ad7ef2@postgrespro.ru> <699225ee-c30c-b22e-4028-415e9eab26b2@postgrespro.ru> <80e9c570-5c49-1a01-f309-3d8d0cbbae42@postgrespro.ru> From: Ildar Musin Message-ID: <38f1503e-7b63-4612-24a9-041af25bb022@postgrespro.ru> Date: Mon, 25 Dec 2017 16:24:38 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Fabien, 24/12/2017 11:12, Fabien COELHO пишет: > > Yep. The ugliness is significantly linked to the choice of name. With > MM2_MUL and MM2_ROT ISTM that it is more readable: > >>     k *= MM2_MUL; >>     k ^= k >> MM2_ROT; >>     k *= MM2_MUL; >>     result ^= k; >>     result *= MM2_MUL; Ok, will do. > >> [...] So I'd better leave it the way it is. Actually I was thinking >> to do the same to fnv1a too : ) > > I think that the implementation style should be homogeneous, so I'd > suggest at least to stick to one style. > > I noticed from the source of all human knowledege (aka Wikipedia:-) > that there seems to be a murmur3 successor. Have you considered it? > One good reason to skip it would be that the implementation is long > and complex. I'm not sure about a 8-byte input simplified version. Murmur2 naturally supports 8-byte data. Murmur3 has 32- and 128-bit versions. So to handle int64 I could 1) split input value into two halfs and combine somehow the results of 32 bit version or 2) use 128-bit version and discard higher bytes. Btw, postgres core already has a 32bit murmur3 implementation, but it only uses the finalization part of algorithm (see murmurhash32). As my colleague Yura Sokolov told me in a recent conversation it alone provides pretty good randomization. I haven't tried it yet though. > > Just a question: Have you looked at SipHash24? > >     https://en.wikipedia.org/wiki/SipHash > > The interesting point is that it can use a key and seems somehow > cryptographically secure, for a similar cost. However the how to > decide for/control the key is unclear. > Not yet. As I can understand from the wiki its main feature is to prevent attacks with crafted input data. How can it be useful in benchmarking? Unless it shows superior performance and randomization. -- Ildar Musin Postgres Professional: http://www.postgrespro.com Russian Postgres Company