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 1iEy27-0005sl-NL for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Sep 2019 15:56:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iEy26-0000ag-IU for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Sep 2019 15:56:18 +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 1iEy26-0000aS-5T for pgsql-hackers@lists.postgresql.org; Mon, 30 Sep 2019 15:56:18 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iEy23-0000Cn-1Y for pgsql-hackers@postgresql.org; Mon, 30 Sep 2019 15:56:17 +0000 Received: by mail-wr1-x444.google.com with SMTP id i1so11979550wro.4 for ; Mon, 30 Sep 2019 08:56:14 -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:in-reply-to:user-agent; bh=KXRD6cERl1a6wCpI6QU75pVm9tvlO6KkE5/ImmcQDAA=; b=koRIwEF6tUYxeBuoINjboiQ+29cz+GBaFBLoH8r+6gxzW3RDI7Fqh/sfsM8yPUPMJK Gxg5/VTAOUPvzSHhKXI/mw6dHTovDovSaArx3v2XqYzotbIrbK3cz+G0WVhZYu8AW10W 0R3EnZcm+l+YPIEvNw/SSknFpox5nUdkWETK6H53E3yHH5IJrYTiFVuZ0rz1qJpOjmSc R4IqrxCorIjdpOCKWIf3a68Cwx5ppVqYZsh+sieCOhsBMHj/XIKsZgbI3jJhb/Kxi/yc bMC3az0b0oLpyLPMUUU/iBOZjL/eXbzx6jHQp06+TQxFq/XiuCVztP1y+91fHhvo/sxP aqsA== 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:in-reply-to:user-agent; bh=KXRD6cERl1a6wCpI6QU75pVm9tvlO6KkE5/ImmcQDAA=; b=A12xz5G/JO3N/C6ZU2mOSDeK+RYgphnQxKLvFFoXJ2+mjrs9rGG9jAjV1//nJ6ifa9 cwWKk/qXOsu9qDd0lTY5lTkv3dkx3zAScd/VpoAn0VcAsDt/CK30O4dHsNfkA/sQGzxx ai2VuEueZcgsQq8ekkHGEdfGDfsWsBJ0pKWWjzXWedXcX1vvFADYgY1nXPBlexFiJ0Xj nJtbp4K57NToNE0RO3retsFkln0nslhZOGZQSdII2lCMBEAjjpLsCvkGiTSVxgFYWfTl t2JQFNiU3B56XkTDjOn8x0WRNvDM6JsCH5oxUox/2MPJRlV8D9eycH1jBziQqWYCegCw 1Erg== X-Gm-Message-State: APjAAAXwybdE5yl+qEOpocYgSVqg5DaiHv5cYhi8M5LrfwxHo8K4ahdN KbCtLpxrBy4Yj6nVHPS8vGGQ1g== X-Google-Smtp-Source: APXvYqwkJHrtv6LKodGX+F1DLgWddIxUkmf8ThJIubS8A4CeXHOkFeLEKuuVr1SkpFA4aCIdZseHlQ== X-Received: by 2002:adf:eb4d:: with SMTP id u13mr1561316wrn.224.1569858973530; Mon, 30 Sep 2019 08:56:13 -0700 (PDT) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id v4sm19365163wrg.56.2019.09.30.08.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:56:09 -0700 (PDT) Date: Mon, 30 Sep 2019 17:56:07 +0200 From: Tomas Vondra To: Alvaro Herrera Cc: Binguo Bao , Andrey Borodin , Paul Ramsey , Pgsql Hackers Subject: Re: Optimize partial TOAST decompression Message-ID: <20190930155607.5tnyzksijgm4imbg@development> References: <20190710144725.kaswinyw2bdgb6tz@development> <20190925203834.GA25060@alvherre.pgsql> <20190926230036.ubxzgkqsphbzmbdl@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190926230036.ubxzgkqsphbzmbdl@development> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Sep 27, 2019 at 01:00:36AM +0200, Tomas Vondra wrote: >On Wed, Sep 25, 2019 at 05:38:34PM -0300, Alvaro Herrera wrote: >>Hello, can you please update this patch? >> > >I'm not the patch author, but I've been looking at the patch recently >and I have a rebased version at hand - so attached. > >FWIW I believe the patch is solid and in good shape, and it got stuck >after I reported some benchmarks showing somewhat flaky performance. I >know Binguo Bao was trying to reproduce the benchmark, and I assume the >silence means he was not successful :-( > >On the larger data set the patch however performed very nicely, so maybe >I just did something stupid while running the smaller one, or maybe it's >just noise (the queries were just a couple of ms in that test). I do >plan to rerun the benchmarks and investigate a bit - if I find the patch >is fine, I'd like to commit it shortly. > OK, I was just about to push this after polishing it a bit, but then I noticed the patch does not address one of the points from Paul' review, asking for comment explaining the pglz_maximum_compressed_size formula. I mean this: /* * Use int64 to prevent overflow during calculation. */ compressed_size = (int32) ((int64) rawsize * 9 + 8) / 8; I'm not very familiar with pglz internals, but I'm a bit puzzled by this. My first instinct was to compare it to this: #define PGLZ_MAX_OUTPUT(_dlen) ((_dlen) + 4) but clearly that's a very different (much simpler) formula. So why shouldn't pglz_maximum_compressed_size simply use this macro? Regarding benchmarks - as I mentioned, I've repeated the tests and everything seems fine. The results from the two usual machines are available in [1]. There are only very few noise-level regressions and many very significant speedups. I have a theory what went wrong in the first run that showed some regressions - it's possible the machine had CPU power management enabled. I can't check this retroactively, but it'd explain variability for short queries, and smooth behavior on longer queries. [1] https://github.com/tvondra/toast-optimize regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services