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 1iZzF1-0002S2-I3 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Nov 2019 15:28:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iZzF0-0006FV-07 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Nov 2019 15:28:30 +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 1iZzEz-0006FI-3Z for pgsql-hackers@lists.postgresql.org; Wed, 27 Nov 2019 15:28:29 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iZzEu-0005k9-Bq for pgsql-hackers@lists.postgresql.org; Wed, 27 Nov 2019 15:28:27 +0000 Received: by mail-wm1-x343.google.com with SMTP id a131so3223873wme.5 for ; Wed, 27 Nov 2019 07:28:24 -0800 (PST) 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; bh=Yag8pD2zLDl6rx/0q9FucE0uAToEhlNNE6UB8BRj5ao=; b=a8xmyg2FEZqjjW95zDa8t4P+cVun9GmJX7wjJzN0dOTB2Cv2z2kElj9UJCmtZg5AZa V52zjR12Sk0r+VEf1Nh6f4Eftgdl0RPHzATAO7mQvGVcE0tbtBxKNaq3bPuuM1egz1dq oRaWN+P5l8csWNzPPLGKlU2pC6PaRf4XPOAJvLLiqv3GAkwEd5R4KZ3NMo4qWsroRV65 VzfBW1XHinQTB3Lg/8v4nmOa6X7FaWV7KEEODj/An+g/JH1ekuFU6M7/NKQMLsFq9eEo iw48NAGx7DzL+/P3ANm5/AdQCbmBzRkKiK5bVIKhq9vRMcoEWisCXtDXc/4ABQPPugjS qG/w== 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; bh=Yag8pD2zLDl6rx/0q9FucE0uAToEhlNNE6UB8BRj5ao=; b=kq+lHOxs1o9HK0hAlRR+JlS/qGc9DfflRh2QHkUoIx2Gsamxcvn2TQUDqepkGACpaW M3c083v72reqtNYzS1jnxjEZB/hugAUpParAqF+oFFkTBq9Yij9/iU9DlNcZSMRU0+6j LfywsTJYhRhEGhnhR9MOyU/AxI6fBo3Cev+HgQ5NjC55nXwtx+1Fjw1kpsFLQyqOLzv1 EzDHXP6oNtMJ31723JpMDvfPxHjt9h7fAWIMvCNLaW6BhPs9XYkv+/8k2RS6oQCwvy7d rXQ0mp2LS9sD0j2y6fufd+wqOb4zMhDIpc4aQRGu5MNWcb1szl/9yXPkqtiSWDQVAetN +eww== X-Gm-Message-State: APjAAAUKBeD1+xNPdXgqPXZbib1+Otc1bscXyAT34lQGwYOkR1BQxOYg AYlxX1llrZXgWBrKNpHXe8+iLQ== X-Google-Smtp-Source: APXvYqwAOpY0hWffu6UGITL+kOMdd8N7QTHPLV4hqApy5L0eiBB5YXRLQ7mXpJJdcHFBS/MB5YUuDg== X-Received: by 2002:a1c:39c2:: with SMTP id g185mr4838426wma.88.1574868501759; Wed, 27 Nov 2019 07:28:21 -0800 (PST) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id f12sm7122153wmf.28.2019.11.27.07.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 07:28:20 -0800 (PST) Date: Wed, 27 Nov 2019 16:28:18 +0100 From: Tomas Vondra To: Andrey Borodin Cc: Michael Paquier , Peter Eisentraut , Alvaro Herrera , Gasper Zejn , pgsql-hackers@lists.postgresql.org Subject: Re: pglz performance Message-ID: <20191127152818.ojgfrxfzr7pqkpic@development> References: <3c2d92d0-e715-f9ed-e1a7-3c510ed65940@2ndquadrant.com> <20191101154828.GA15829@alvherre.pgsql> <20191101165950.b5azncggaqfan5fi@development> <35c2a448-06b8-eab0-05ea-34a3f51ba9a8@2ndquadrant.com> <20191125080309.GK99720@paquier.xyz> <13C6049A-C3D9-4021-9934-41488DE38BE9@yandex-team.ru> <20191125082940.GP99720@paquier.xyz> <20191126094324.7y2n3n3houetavwd@development> <51E4C9A3-E2A3-4122-B5BC-B6A70BA64253@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: <51E4C9A3-E2A3-4122-B5BC-B6A70BA64253@yandex-team.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Nov 27, 2019 at 05:47:25PM +0500, Andrey Borodin wrote: >Hi Tomas! > >Thanks for benchmarking this! > >> 26 нояб. 2019 г., в 14:43, Tomas Vondra написал(а): >> >> On Mon, Nov 25, 2019 at 05:29:40PM +0900, Michael Paquier wrote: >>> On Mon, Nov 25, 2019 at 01:21:27PM +0500, Andrey Borodin wrote: >>>> I think status Needs Review describes what is going on better. It's >>>> not like something is awaited from my side. >>> >>> Indeed. You are right so I have moved the patch instead, with "Needs >>> review". The patch status was actually incorrect in the CF app, as it >>> was marked as waiting on author. >>> >>> @Tomas: updated versions of the patches have been sent by Andrey. >> >> I've done benchmarks on the two last patches, using the data sets from >> test_pglz repository [1], but using three simple queries: >> >> 1) prefix - first 100 bytes of the value >> >> SELECT length(substr(value, 0, 100)) FROM t >> >> 2) infix - 100 bytes from the middle >> >> SELECT length(substr(value, test_length/2, 100)) FROM t >> >> 3) suffix - last 100 bytes >> >> SELECT length(substr(value, test_length - 100, 100)) FROM t >> >> See the two attached scripts, implementing this benchmark. The test >> itself did a 60-second pgbench runs (single client) measuring tps on two >> different machines. >> >> patch 1: v4-0001-Use-memcpy-in-pglz-decompression.patch >> patch 2: v4-0001-Use-memcpy-in-pglz-decompression-for-long-matches.patch >> >> The results (compared to master) from the first machine (i5-2500k CPU) >> look like this: >> >> patch 1 | patch 2 >> dataset prefix infix suffix | prefix infix suffix >> ------------------------------------------------------------------------- >> 000000010000000000000001 99% 134% 161% | 100% 126% 152% >> 000000010000000000000006 99% 260% 287% | 100% 257% 279% >> 000000010000000000000008 100% 100% 100% | 100% 95% 91% >> 16398 100% 168% 221% | 100% 159% 215% >> shakespeare.txt 100% 138% 141% | 100% 116% 117% >> mr 99% 120% 128% | 100% 107% 108% >> dickens 100% 129% 132% | 100% 100% 100% >> mozilla 100% 119% 120% | 100% 102% 104% >> nci 100% 149% 141% | 100% 143% 135% >> ooffice 99% 121% 123% | 100% 97% 98% >> osdb 100% 99% 99% | 100% 100% 99% >> reymont 99% 130% 132% | 100% 106% 107% >> samba 100% 126% 132% | 100% 105% 111% >> sao 100% 100% 99% | 100% 100% 100% >> webster 100% 127% 127% | 100% 106% 106% >> x-ray 99% 99% 99% | 100% 100% 100% >> xml 100% 144% 144% | 100% 130% 128% >> >> and on the other one (xeon e5-2620v4) looks like this: >> >> patch 1 | patch 2 >> dataset prefix infix suffix | prefix infix suffix >> ------------------------------------------------------------------------ >> 000000010000000000000001 98% 147% 170% | 98% 132% 159% >> 000000010000000000000006 100% 340% 314% | 98% 334% 355% >> 000000010000000000000008 99% 100% 105% | 99% 99% 101% >> 16398 101% 153% 205% | 99% 148% 201% >> shakespeare.txt 100% 147% 149% | 99% 117% 118% >> mr 100% 131% 139% | 99% 112% 108% >> dickens 100% 143% 143% | 99% 103% 102% >> mozilla 100% 122% 122% | 99% 105% 106% >> nci 100% 151% 135% | 100% 135% 125% >> ooffice 99% 127% 129% | 98% 101% 102% >> osdb 102% 100% 101% | 102% 100% 99% >> reymont 101% 142% 143% | 100% 108% 108% >> samba 100% 132% 136% | 99% 109% 112% >> sao 99% 101% 100% | 99% 100% 100% >> webster 100% 132% 129% | 100% 106% 106% >> x-ray 99% 101% 100% | 90% 101% 101% >> xml 100% 147% 148% | 100% 127% 125% >> >> In general, I think the results for both patches seem clearly a win, but >> maybe patch 1 is bit better, especially on the newer (xeon) CPU. So I'd >> probably go with that one. > > > From my POV there are two interesting new points in your benchmarks: >1. They are more or lesss end-to-end benchmarks with whole system involved. >2. They provide per-payload breakdown > Yes. I was considering using the test_pglz extension first, but in the end I decided an end-to-end test is easier to do and more relevant. >Prefix experiment is mostly related to reading from page cache and not >directly connected with decompression. It's a bit strange that we >observe 1% degradation in certain experiments, but I believe it's a >noise. > Yes, I agree it's probably noise - it's not always a degradation, there are cases where it actually improves by ~1%. Perhaps more runs would even this out, or maybe it's due to different bin layout or something. I should have some results from a test with longer (10-minute) run soon, but I don't think this is a massive issue. >Infix and Suffix results are correlated. We observe no impact of the >patch on compressed data. > TBH I have not looked at which data sets are compressible etc. so I can't really comment on this. FWIW the reason why I did the prefix/infix/suffix is primarily that I was involved in some recent patches tweaking TOAST slicing, so I wanted to se if this happens to negatively affect it somehow. And it does not. >test_pglz also includes slicing by 2Kb and 8Kb. This was done to >imitate toasting. But as far as I understand, in your test data payload >will be inserted into toast table too, won't it? If so, I agree that >patch 1 looks like a better option. > Yes, the tests simply do whatever PostgreSQL would do when loading and storing this data, including TOASTing. >> 27 нояб. 2019 г., в 1:05, Tomas Vondra написал(а): >> >> Code-wise I think the patches are mostly fine, although the comments >> might need some proof-reading. >> >> 1) I wasn't really sure what a "nibble" is, but maybe it's just me and >> it's a well-known term. >I've took the word from pg_lzcompress.c comments > * The offset is in the upper nibble of T1 and in T2. > * The length is in the lower nibble of T1. Aha, good. I haven't noticed that word before, so I assumed it's introduced by those patches. And the first thing I thought of was "nibbles" video game [1]. Which obviously left me a bit puzzled ;-) But it seems to be a well-known term, I just never heard it before. [1] https://en.wikipedia.org/wiki/Nibbles_(video_game) >> >> 2) First byte use lower -> First byte uses lower >> >> 3) nibble contain upper -> nibble contains upper >> >> 4) to preven possible uncertanity -> to prevent possible uncertainty >> >> 5) I think we should briefly explain why memmove would be incompatible >> with pglz, it's not quite clear to me. >Here's the example >+ * Consider input: 112341234123412341234 >+ * At byte 5 here ^ we have match with length 16 and >+ * offset 4. 11234M(len=16, off=4) > >If we simply memmove() this 16 bytes we will produce >112341234XXXXXXXXXXXX, where series of X is 12 undefined bytes, that >were at bytes [6:18]. > OK, thanks. >> >> 6) I'm pretty sure the comment in the 'while (off < len)' branch will be >> badly mangled by pgindent. > >I think I can just write it without line limit and then run pgindent. >Will try to do it this evening. Also, I will try to write more about >memmove. > >> >> 7) The last change moving "copy" to the next line seems unnecessary. > >Oh, looks like I had been rewording this comment, and eventually came >to the same text..Yes, this change is absolutely unnecessary. > >Thanks! > Good. I'll wait for an updated version of the patch and then try to get it pushed by the end of the CF. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services