Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdh7z-0006N4-Rg for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Nov 2020 22:01:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kdh7y-000075-Nb for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Nov 2020 22:01:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kdh7y-000055-6M for pgsql-hackers@lists.postgresql.org; Fri, 13 Nov 2020 22:01:06 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kdh7t-0005gV-LO for pgsql-hackers@postgresql.org; Fri, 13 Nov 2020 22:01:05 +0000 Received: by mail-wr1-x443.google.com with SMTP id p1so11731899wrf.12 for ; Fri, 13 Nov 2020 14:01:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=r3fbk8SRglHFBuGJu3yH0hRPjyjrGnzKmSbdrOf5Qhs=; b=YFOImmInqLaqwscULTVaTfcxnME5UMEU/avwsde9j/tJqmNTC2UG43H1eIQU3RChwh sUrk4UhUsn89D/JhuNmtJ8DQcpAtC8UTBXmm0ngtYTL0vmkdg50ZwvPkEnjFJSDgb3WZ is/65+9vUw0sONxEEk/kRQdCEhPwhvk9sFmuXlWHlcBccigeAGlymUCIVhgLvD0RM4PJ NU23LL9P2RiZLzRlKtifSuM8EiL+36nECdILZirvcbyaEXLakH3FdU8sZJtJcB8jORwM XQg+PSpsl3ixU20HLDbIhT372B/T8pt1OG1cL/ZPuRsqmJTqulev7aA2zc1cPHD4AZTq ysvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=r3fbk8SRglHFBuGJu3yH0hRPjyjrGnzKmSbdrOf5Qhs=; b=G3RKzglOBQaJdyA8aQoVFXWg3J1ZsjUz0BAzFdaarenUghjgyLIJCjt/PRWC//Xzee GJvnL/m735vMZuLjjFVPP+lHNjYuFntlAAgaPYe9KC6h0LkBayI7FTEAij/XGFmhyFcC xezrlHG5MTwaQbF8kw8jEuR0Q9fOMQ6yrfQAh1fM/uSYHQPlXIS8HitF18Tt2gTgUaAf JlHzL1yY0Q/oC1HgWXwGbqJjMPJJXf9k76F6sS3mngHFQuawI777xlw45gB5/xJLzLvQ u7Z7fkb+p7mwRoQbQ+Ufz7bdF6YnDTrKauvdkf/y4JTjtebUg1dWwnyZh0koK9/IXFtY sUKg== X-Gm-Message-State: AOAM5327lETs4bfsko62jSmB1I/6/Lp7UBzTrD8mP2qtfxaUxDjSIgmb fQo+IqwSSL30rBIWXdFFZb6/Vdgl+tcLIso0rYGBjkdfESUzZ37F4++pegqlOi6QtS4Z0af2ccD l8OXLey4QPD4QQ68mbkE9AoiURdqARF7sI0iAYnb6zlZ+MbrxQDBb3iB9HPs9NOLDtq/2sVoki4 Os/+aqjupepr2nvk9yynb28ksYTpda9xdQVvgDy2ZmEBIUybQM51RxhhRs1qnaTOyEjea15pJsO HMPb21oWKMK/HcvoHrgef4T4sSCZDh7E7wHZ99g X-Google-Smtp-Source: ABdhPJwo8u0QA98w5E/e/BCqwEdt2ZQqZzIxiD7AzR8DC+oHtq2KAUkm/gR9yfckWMjb7f50SE7tGg== X-Received: by 2002:a5d:6743:: with SMTP id l3mr5939480wrw.82.1605304859195; Fri, 13 Nov 2020 14:00:59 -0800 (PST) Received: from [10.137.0.4] (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id s4sm12589923wro.10.2020.11.13.14.00.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Nov 2020 14:00:58 -0800 (PST) Subject: Re: Zedstore - compressed in-core columnar storage To: Jacob Champion Cc: Soumyadeep Chakraborty , "Alexandra Wang (Pivotal)" , "Taylor Vesely (Pivotal)" , Ashutosh Sharma , Heikki Linnakangas , "Ashwin Agrawal (Pivotal)" , DEV_OPS , PostgreSQL mailing lists References: <3554cb64-3c77-ae98-491e-91f3221e37c1@iki.fi> <9e1077bc-c5c1-425b-07ad-424d3522363f@enterprisedb.com> From: Tomas Vondra Message-ID: Date: Fri, 13 Nov 2020 23:00:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/13/20 8:07 PM, Jacob Champion wrote: > On Nov 12, 2020, at 2:40 PM, Tomas Vondra wrote: >> >> Hi, >> >> Thanks for the updated patch. It's a quite massive amount of code - I I >> don't think we had many 2MB patches in the past, so this is by no means >> a full review. > > Thanks for taking a look! You're not kidding about the patch size. > > FYI, the tableam changes made recently have been extracted into their > own patch, which is up at [1]. > >> 1) the psql_1.out is missing a bit of expected output (due to 098fb0079) > > Yeah, this patch was rebased as of efc5dcfd8a. > >> 2) I'm getting crashes in intarray contrib, due to hitting this error in >> lwlock.c (backtrace attached): >> >> /* Ensure we will have room to remember the lock */ >> if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS) >> elog(ERROR, "too many LWLocks taken"); >> >> I haven't investigates this too much, but it's regular build with >> asserts and TAP tests, so it should be simple to reproduce using "make >> check-world" I guess. > > I've only seen this intermittently in installcheck, and I'm not able to > reproduce with the intarray tests on my machine (macOS). Definitely > something we need to look into. What OS are you testing on? > Fedora 32, nothing special. I'm not sure if I ran the tests with pglz or lz4, maybe there's some dependence on that, but it does fail for me quite reliably with this: ./configure --enable-debug --enable-cassert --enable-tap-tests --with-lz4 && make -s clean && make -s -j4 && make check-world >> It's mostly expected lz4 beats pglz in performance and compression >> ratio, but this seems a bit too extreme I guess. Per past benchmarks >> (e.g. [1] and [2]) the difference in compression/decompression time >> should be maybe 1-2x or something like that, not 35x like here. > > Yeah, something seems off about that. We'll take a look. > >> BTW the comments in general need updating and tidying up, to make >> reviews easier. For example the merge_attstream comment references >> attstream1 and attstream2, but those are not the current parameters of >> the function. > > Agreed. > >> 5) IHMO there should be a #define specifying the maximum number of items >> per chunk (60). Currently there are literal constants used in various >> places, sometimes 60, sometimes 59 etc. which makes it harder to >> understand the code. FWIW 60 seems a bit low, but maybe it's OK. > > Yeah, that seems like a good idea. > > I think the value 60 comes from the use of simple-8b encoding -- see the > comment at the top of zedstore_attstream.c. > Yeah, I understand where it comes from. I'm just saying that when you see 59 hardcoded, it may not be obvious where it came from, and something like ITEMS_PER_CHUNK would be better. I wonder how complicated would it be to allow larger chunks, e.g. by using one bit to say "there's another 64-bit codeword". Not sure if it's worth the extra complexity, though - it's just that 60 feels a bit low. >> 6) I do think ZSAttStream should track which compression is used by the >> stream, for two main reasons. Firstly, there's another patch to support >> "custom compression" methods, which (also) allows multiple compression >> methods per column. It'd be a bit strange to support that for varlena >> columns in heap table, and not here, I guess. Secondly, I think one of >> the interesting columnstore features down the road will be execution on >> compressed data, which however requires compression method designed for >> that purpose, and it's often datatype-specific (delta encoding, ...). >> >> I don't think we need to go as far as supporting "custom" compression >> methods here, but I think we should allow different built-in compression >> methods for different attstreams. > > Interesting. We'll need to read/grok that ML thread. > That thread is a bit long not sure it's worth reading as a whole unless you want to work on that feature. The gist is that to seamlessly support multiple compression algorithms we need to store an ID of the algorithm somewhere. For TOAST that's not too difficult, we can do that in the TOAST pointer - the the main challenge is in doing it in a backwards-compatible way. For zedstore we can actually design it from the start. I wonder if we should track version of the format somewhere, to allow future improvements. So that if/when we decide to change something in the future, we don't have to scavenge bits etc. Or perhaps just a "uint32 flags" field, unused/reserved for future use. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company