Re: Fix incorrect comments in tuplesort.c

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: cca5507 <cca5507(at)qq(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix incorrect comments in tuplesort.c
Date: 2025-12-07 22:09:37
Message-ID: CAApHDvrN3PNF0G4uxzT87i5034wYLG1MPZtzaCzjDaX8iJ3tOQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 7 Dec 2025 at 21:34, cca5507 <cca5507(at)qq(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mihail Nikalayeu 2025-12-07 22:18:22 Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY
Previous Message Álvaro Herrera 2025-12-07 21:14:54 Re: bt_index_parent_check and concurrently build indexes