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 1mCi4B-0005w0-RH for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Aug 2021 12:38:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mCi4A-0006sE-LV for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Aug 2021 12:38:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mCi4A-0006s5-2k for pgsql-hackers@lists.postgresql.org; Sun, 08 Aug 2021 12:38:10 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mCi43-0004xL-TQ for pgsql-hackers@lists.postgresql.org; Sun, 08 Aug 2021 12:38:06 +0000 Received: by mail-ej1-x62d.google.com with SMTP id hw6so23996796ejc.10 for ; Sun, 08 Aug 2021 05:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=DGhBEBOejO6o7hfPwVW1ViIezRol5GIw8D7M83QZ/nw=; b=h1o2vG/lnSJ8j2PzIwJ3zc0yQXGIn+nklQ5ojxsXg0iHd0hvT9N23jo3V2M1OtMHMA ArMNK5p90Pdtvj558FPPdb6FJtD7K7xDXUc5/I7pdxbrBZGBven0zBgUmPwrsDunR7f6 Rvm50EAVEgBgpwyxqC7LnUUEXM6C9XBFziVlV4Al7lDoE1+ETLHVTlQXsQYyFxijhZcP 3IRsY4q/n6sq+JpFIpY6LczYIK6HqITjl56KAwCPODh8K/If7At/uQs3EQgXGVa1HRQX LB+dS1UHOhq57z9dTuUnd3Eu/JJ1DCUf0kmErLh2efv6eDrxtxZFSsIzeWBg9xLN+cWe mwpQ== 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=DGhBEBOejO6o7hfPwVW1ViIezRol5GIw8D7M83QZ/nw=; b=r/Ah7pE0z8jn6jR+MndC4rSTwr+eDuBw+cI0c1MApSjvyJFBsA+DC+YFBi86Ei0pnR oUCCjmJNQyH6Zor5g9Bh31XX6xKPPlFtZaxmSP/xiqN3KLZqQKax9FPbFvfyF74Lh6Yl bNC8R7nhrzj4/EGqZhiqvXg2OcA74HiEkq/KnixGD8j3PyUNaZl0iDbmUa2l9zkd34Lw ReS/lgVSCwhMa/KS8lDq8X7EdzwveDayFpNmgeCB1B9XGab2JpZW5ZsAdplqUwi99rC/ H65nbzphsSU28aWDM9KZfePTyvgQ6Hy8HzXAP1JxqfW7ZiIn23M32yTVCK9fEkOixxyN IYxw== X-Gm-Message-State: AOAM532p2JqYGbUc4Sc3QYlB5iSZLHz0Y/ap1rEcsilNyXbG98NfdgnL B5O9tvB/5OFePzfdOSBJJDgARDsY833oEzS79rt68ty5OZf/DaK/V1dJYIzELIhvSqFj5Evxx9v wf7pNsHxUx0l9iw+9NQGEUfocPtERdqiAp1i4yMjdBbr2yHlivA5eO7F6qSiIoJFc0BuJUYZNDv 6DNH0kTdT7ubw4Ni3JRRt4Qknp2QUVIk1us98DWT+LkLxYbKC4nUJVTKpOyYnDJzo3tmXZkl+PD wHVDT9e8gOA/xocUYeb56S5mcoI/NxLQufh6nij48P3Jy9pcuZmXQ== X-Google-Smtp-Source: ABdhPJzrzpGY3HV/bcruLM7M0dTrRKa0Brq8Xk33duaclb81S/b4DUpiF/64xQsT+8X345Htfl8TAA== X-Received: by 2002:a17:906:fb0a:: with SMTP id lz10mr18054616ejb.502.1628426282309; Sun, 08 Aug 2021 05:38:02 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-254-183.net.upcbroadband.cz. [86.49.254.183]) by smtp.gmail.com with ESMTPSA id dg24sm178016edb.6.2021.08.08.05.38.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Aug 2021 05:38:02 -0700 (PDT) Subject: Re: Use generation context to speed up tuplesorts To: David Rowley Cc: Andres Freund , Tomas Vondra , PostgreSQL Developers References: <20210730203853.utjj43f6zzn5e2hy@alap3.anarazel.de> <36829a8a-63d0-c428-89d5-07e49561973e@enterprisedb.com> <13808af0-2bb5-b506-62d0-1fb67e3385d0@enterprisedb.com> From: Tomas Vondra Message-ID: <1bbb8151-d86e-099f-f279-5427a708d4eb@enterprisedb.com> Date: Sun, 8 Aug 2021 14:38:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed 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: Archived-At: Precedence: bulk On 8/8/21 12:11 PM, David Rowley wrote: > On Sat, 7 Aug 2021 at 12:10, Tomas Vondra wrote: >>> All of the tests show that the patches to improve the allocation >>> efficiency of generation.c don't help to improve the results of the >>> test cases. I wondered if it's maybe worth trying to see what happens >>> if instead of doubling the allocations each time, quadruple them >>> instead. I didn't try this. >>> >> >> I doubt quadrupling the allocations won't help very much, but I suspect >> the problem might be in the 0004 patch - at least that's what shows >> regression in my results. Could you try with just 0001-0003 applied? > > I tried the quadrupling of the buffer instead of doubling it each time > and got the attached. Column E, or green in the graphs show the > results of that. It's now much closer to the original patch which just > made the block size 8MB. > Interesting, I wouldn't have expected that to make such difference. I'm not sure quadrupling the size is a good idea, though, because it increases the amount of memory we might be wasting. With the doubling, the amount of wasted /unused memory is limited to ~50%, because the next block is (roughly) equal to sum of already allocated blocks, so allocating just 1B on it leaves us with 50%. But quadrupling the size means we'll end up with ~75% free space. Of course, this is capped by the maximum block size etc. but still ... regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company