Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htXsb-0004KW-Lg for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Aug 2019 13:45:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1htXsZ-0002hJ-6r for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Aug 2019 13:45:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htXsY-0002Q2-GZ for pgsql-hackers@lists.postgresql.org; Fri, 02 Aug 2019 13:45:54 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1htXsQ-00047J-4s for pgsql-hackers@postgresql.org; Fri, 02 Aug 2019 13:45:52 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id C3C2621C4123; Fri, 2 Aug 2019 16:45: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.200] (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 9364A21C4122; Fri, 2 Aug 2019 16:45:43 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1564753543; bh=MkbLaQElE7IOd5MhsAMk5aHigdcgOokmTVb4zZJRIzM=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=PSLYd2sgI5ILKlThkOrRcKZi+D8l4hjnN7vKLlnBo61eUlyB9vaYgugxcVOmSKVeC anvM4F2sgBYtMcJEomlXaUUB4JGOT8T+EJRs/gZJF1Mw7LgggsqBQjc5e4ieMYmQyk FpFYXGO5VqED/CB5KQFeRdSArkvFTt/ywo3gIACU= Subject: Re: pglz performance To: Andrey Borodin , Michael Paquier Cc: pgsql-hackers , Vladimir Leskov References: <469C9ED9-348C-4FE7-A7A7-B0FA671BEE4C@yandex-team.ru> <20190513071427.GB2273@paquier.xyz> <169163A8-C96F-4DBE-A062-7D1CECBE9E5D@yandex-team.ru> From: Konstantin Knizhnik Message-ID: Date: Fri, 2 Aug 2019 16:45:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <169163A8-C96F-4DBE-A062-7D1CECBE9E5D@yandex-team.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 27.06.2019 21:33, Andrey Borodin wrote: > >> 13 мая 2019 г., в 12:14, Michael Paquier написал(а): >> >> Decompression can matter a lot for mostly-read workloads and >> compression can become a bottleneck for heavy-insert loads, so >> improving compression or decompression should be two separate >> problems, not two problems linked. Any improvement in one or the >> other, or even both, is nice to have. > Here's patch hacked by Vladimir for compression. > > Key differences (as far as I see, maybe Vladimir will post more complete list of optimizations): > 1. Use functions instead of macro-functions: not surprisingly it's easier to optimize them and provide less constraints for compiler to optimize. > 2. More compact hash table: use indexes instead of pointers. > 3. More robust segment comparison: like memcmp, but return index of first different byte > > In weighted mix of different data (same as for compression), overall speedup is x1.43 on my machine. > > Current implementation is integrated into test_pglz suit for benchmarking purposes[0]. > > Best regards, Andrey Borodin. > > [0] https://github.com/x4m/test_pglz It takes me some time to understand that your memcpy optimization is correct;) I have tested different ways of optimizing this fragment of code, but failed tooutperform your implementation! Results at my computer is simlar with yours: Decompressor score (summ of all times): NOTICE:  Decompressor pglz_decompress_hacked result 6.627355 NOTICE:  Decompressor pglz_decompress_hacked_unrolled result 7.497114 NOTICE:  Decompressor pglz_decompress_hacked8 result 7.412944 NOTICE:  Decompressor pglz_decompress_hacked16 result 7.792978 NOTICE:  Decompressor pglz_decompress_vanilla result 10.652603 Compressor score (summ of all times): NOTICE:  Compressor pglz_compress_vanilla result 116.970005 NOTICE:  Compressor pglz_compress_hacked result 89.706105 But ...  below are results for lz4: Decompressor score (summ of all times): NOTICE:  Decompressor lz4_decompress result 3.660066 Compressor score (summ of all times): NOTICE:  Compressor lz4_compress result 10.288594 There is 2 times advantage in decompress speed and 10 times advantage in compress speed. So may be instead of "hacking" pglz algorithm we should better switch to lz4? -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company