Re: Fix incorrect comments in tuplesort.c - Mailing list pgsql-hackers

From David Rowley
Subject Re: Fix incorrect comments in tuplesort.c
Date
Msg-id CAApHDvrN3PNF0G4uxzT87i5034wYLG1MPZtzaCzjDaX8iJ3tOQ@mail.gmail.com
Whole thread Raw
In response to Re: Fix incorrect comments in tuplesort.c  ("cca5507" <cca5507@qq.com>)
Responses Re: Fix incorrect comments in tuplesort.c
List pgsql-hackers
On Sun, 7 Dec 2025 at 21:34, cca5507 <cca5507@qq.com> wrote:
> I find that the initial size of memtuples array must be more than ALLOCSET_SEPARATE_THRESHOLD
> is not for lower overhead of allocation, but for a bug fixed in 8ea3e7a75c0d22c41c57f59c8b367059b97d0b66.
>
> Attach a new patch.

I find the current comment perfectly understandable and the text
you're proposing to be incorrect. What you might be missing is that
with aset.c, a palloc() request above ALLOCSET_SEPARATE_THRESHOLD is
certain to require a malloc() and a dedicated block. Sizes under that
may be able to use an existing AllocBlock. The comment is effectively
explaining that we don't want to make the array big enough so that a
malloc will always be required. You may need to read
AllocSetContextCreateInternal() around where allocChunkLimit is being
set to understand what this is all about.

David



pgsql-hackers by date:

Previous
From: Álvaro Herrera
Date:
Subject: Re: bt_index_parent_check and concurrently build indexes
Next
From: Mihail Nikalayeu
Date:
Subject: Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY