Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etCwh-0007Oi-7T for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Mar 2018 13:47:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1etCwf-00006E-Sw for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Mar 2018 13:47:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etCwf-000060-EX for pgsql-hackers@lists.postgresql.org; Tue, 06 Mar 2018 13:47:57 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1etCwU-0000rT-2W for pgsql-hackers@postgresql.org; Tue, 06 Mar 2018 13:47:56 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id E892921C1CFB; Tue, 6 Mar 2018 16:47:43 +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 [192.168.27.109] (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 AA9C421C1CFA; Tue, 6 Mar 2018 16:47:43 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1520344063; bh=OnXxc8pgFcBb7ZjuOASYx6bZtPeUYLU5bBQViBiT8ew=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=kXN9aigbcKpdjPCfi8ACI1Gsi8G+BSuf6EULw/ian2EQAp+GpmONChQf8yhdEDw+q 788v2xX+9RJxOdtGltk/bETyrtrJBydBFH/YUoO6t4LA+xQa8Uk1Dqst6cd+HVi5nm I8fx8TMVsmH6W524ku1ik5W7xEuk0dYEIAdaLM9g= Subject: Re: General purpose hashing func in pgbench To: Teodor Sigaev , Fabien COELHO References: <0e8bd39e-dfcd-2879-f88f-272799ad7ef2@postgrespro.ru> <63f5a6ac-0c5b-8d59-ca8b-fc8e11244a66@postgrespro.ru> <291822a3-0b3a-0b21-c694-c10776f516ac@postgrespro.ru> <6e47c84a-d42a-0e08-1b0d-33e6a6c87778@postgrespro.ru> <960a8096-dde5-5175-7d7c-ef151086cbee@postgrespro.ru> <12986cad-3dd9-a449-e318-4acd8a8e1697@postgrespro.ru> <736d5e10-8823-a0f8-574e-3ebd7c4a4920@postgrespro.ru> <1ad42902-ef1f-a715-7010-1288fb8aae89@sigaev.ru> Cc: pgsql-hackers From: Ildar Musin Message-ID: <75f45845-24ed-347b-66d5-2f18d39c6793@postgrespro.ru> Date: Tue, 6 Mar 2018 16:47:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1ad42902-ef1f-a715-7010-1288fb8aae89@sigaev.ru> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Teodor, Thank you for reviewing this patch. On 06.03.2018 15:53, Teodor Sigaev wrote: >>> Patch applies, compiles, pgbench & global "make check" ok, doc >>> built ok. > > Agree. > > If I understand upthread correctly, implementation of Murmur hash > algorithm based on Austin Appleby work > https://github.com/aappleby/smhasher/blob/master/src/MurmurHash2.cpp > > If so, I have notice and objections: > > 1) Seems, it's good idea to add credits to Austin Appleby to > comments. > Sounds fair, I'll send an updated version soon. > 2) Reference implementaion directly says (link above): // 2. It will > not produce the same results on little-endian and big-endian // > machines. > > I don't think that is good thing for testing and benchmarking for > several reasons: it could produce different data collection, > different selects, different distribution. > > 3) Again, from comments of reference implementation: // Note - This > code makes a few assumptions about how your machine behaves - // 1. > We can read a 4-byte value from any address without crashing > > It's not true for all supported platforms. Any box with strict > aligment will SIGBUSed here. > I think that both points refer to the fact that original algorithm accepts a byte string as an input, slices it up by 8 bytes and form unsigned int values from it. In that case the order of bytes in the input string does matter since it may result in different integers on different architectures. And it is also fair requirement for a byte string to be aligned as some architectures cannot handle unaligned data. In this patch though I slightly modified the original algorithm in a way that it takes unsigned ints as an input (not byte string), so neither of this points should be a problem as it seems to me. But I'll double check it on big-endian machine with strict alignment (Sparc). Thanks! -- Ildar Musin i.musin@postgrespro.ru