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

From David G. Johnston
Subject Re: Fix incorrect comments in tuplesort.c
Date
Msg-id CAKFQuwaEXRcvDn7S3o5hEnB9Yt5jgecbfyGY+gLohAcV2p=Pzg@mail.gmail.com
Whole thread Raw
In response to Re: Fix incorrect comments in tuplesort.c  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Fix incorrect comments in tuplesort.c
List pgsql-hackers
On Sun, Dec 7, 2025 at 3:09 PM David Rowley <dgrowleyml@gmail.com> wrote:
The comment is effectively
explaining that we don't want to make the array big enough so that a
malloc will always be required.
 
Doesn't what you are saying contradict both the formula (the +1 post-division) and the comments:

/*
* Initial size of array must be more than ALLOCSET_SEPARATE_THRESHOLD;
* see comments in grow_memtuples().
*/
state->memtupsize = INITIAL_MEMTUPSIZE;
state->memtuples = NULL;

and in grow_memtuples:

* That shouldn't happen because we chose the
* initial array size large enough to ensure that palloc will be treating
* both old and new arrays as separate chunks.

?

David J.

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Moving _bt_readpage and _bt_checkkeys into a new .c file
Next
From: Michael Paquier
Date:
Subject: Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY