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 1htYmg-0006bv-8t for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Aug 2019 14:43:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1htYme-0002PS-QF for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Aug 2019 14:43:52 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1htYme-0002PK-98 for pgsql-hackers@lists.postgresql.org; Fri, 02 Aug 2019 14:43:52 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1htYma-0007cE-SW for pgsql-hackers@postgresql.org; Fri, 02 Aug 2019 14:43:51 +0000 Received: by mail-wm1-x341.google.com with SMTP id f17so66563267wme.2 for ; Fri, 02 Aug 2019 07:43:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=e2q2Jeu/8EEJAGQm7HzD0LX/kXfG/eGyaeDdheBr4kY=; b=r+ohc0QBS5R7UD8lJnM554IS+b3bnozEl0cMXe0WCuTfjBSsJvYZrCvG/VBy6LxcOt KQOPJoPtOSJhU9ObATbiCO6BvF3xQydXdEmivq4tf4QPpUYk9Ax7HnCi23ghGnbxdmqq RmqlMg3Fjfu+RLfIBcLqjOO/KII6IISy56NOC72ZbncEgH+HMYtpiEyF+hodne3+/LTZ DzatvNrU0C3nOOPqBgGXkoVqko87ZXk+h79LIKyGrcPXnx7UByEL2h5UyO7M6F/byp3D 8Hd+gaMhph+L4XlpHv/DP3HgM0DTLnK/OriOrxoiCMqtwMSFOC/uJiHL87SvYkBD8l04 tGeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=e2q2Jeu/8EEJAGQm7HzD0LX/kXfG/eGyaeDdheBr4kY=; b=eJklepxJuMfC0Xeacwze5G1VnEOgVVLL9TukM2I53qGCc7eCklx8S/D6Z36O4n0tEE n1D/jC35K4/KmYOYymu9RNvce+LSzoYiSpK8F7Jtp/b3MPOyTkOr35ZSTsw0tnQPlFoB 76r2RM48Z/xyBR3NNY1x+ZInpD09XeXQRepj4UjA+sW8E7C0zcTc0w1opN5UqzGVg395 wUPJSr/hLCThpOLQdlqkPLoRMSqQbibzDMsouVBP7H5cs3xtBnFQ1af8iSI29+tq2Xvx ZPhrAM5yF41eyCGnTuM7K2aOkAbSLSFTesiSehdm8TNipWbL5wIxHCFwpIfzmXBBc9l/ +YAw== X-Gm-Message-State: APjAAAWf0QKDfncdcwyo3EGbu7PMqdf/qfC30MELixAMrUcuYy4RTg1G /IJZdIzq6DKH4+VKHXyfhfKRdA== X-Google-Smtp-Source: APXvYqwuk2IGYGA9UFbK+y0HI9PS9jB+rjny9qZaekgqFd48Rc5IbH0tLmN3NWV+OheWKsOkhZpzbQ== X-Received: by 2002:a1c:630a:: with SMTP id x10mr5088733wmb.113.1564757027634; Fri, 02 Aug 2019 07:43:47 -0700 (PDT) Received: from localhost (ip-86-49-253-160.net.upcbroadband.cz. [86.49.253.160]) by smtp.gmail.com with ESMTPSA id s10sm58988819wrt.49.2019.08.02.07.43.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 07:43:46 -0700 (PDT) Date: Fri, 2 Aug 2019 16:43:45 +0200 From: Tomas Vondra To: Konstantin Knizhnik Cc: Andrey Borodin , Michael Paquier , pgsql-hackers , Vladimir Leskov Subject: Re: pglz performance Message-ID: <20190802144345.d62jtiyyx6r2y73f@development> References: <469C9ED9-348C-4FE7-A7A7-B0FA671BEE4C@yandex-team.ru> <20190513071427.GB2273@paquier.xyz> <169163A8-C96F-4DBE-A062-7D1CECBE9E5D@yandex-team.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Aug 02, 2019 at 04:45:43PM +0300, Konstantin Knizhnik wrote: > > >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? > I think we should just bite the bullet and add initdb option to pick compression algorithm. That's been discussed repeatedly, but we never ended up actually doing that. See for example [1]. If there's anyone willing to put some effort into getting this feature over the line, I'm willing to do reviews & commit. It's a seemingly small change with rather insane potential impact. But even if we end up doing that, it still makes sense to optimize the hell out of pglz, because existing systems will still use that (pg_upgrade can't switch from one compression algorithm to another). regards [1] https://www.postgresql.org/message-id/flat/55341569.1090107%402ndquadrant.com -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services