Re: Fix incorrect comments in tuplesort.c

Chao Li <li.evan.chao@gmail.com>

From: Chao Li <li.evan.chao@gmail.com>
To: cca5507 <cca5507@qq.com>
Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-07T03:55:45Z
Lists: pgsql-hackers

> On Dec 6, 2025, at 22:56, cca5507 <cca5507@qq.com> wrote:
> 
> Hi,
> 
> The incorrect comment:
> 
> ```
> /*
> * Initial size of memtuples array.  We're trying to select this size so that
> * array doesn't exceed ALLOCSET_SEPARATE_THRESHOLD and so that the overhead of
> * allocation might possibly be lowered.  However, we don't consider array sizes
> * less than 1024.
> *
> */
> #define INITIAL_MEMTUPSIZE Max(1024, \
> ALLOCSET_SEPARATE_THRESHOLD / sizeof(SortTuple) + 1)
> ```
> 
> The "doesn't exceed" are contrary to the macro. Maybe "slightly exceed"?
> 
> Attach a small patch. (also remove the empty line in this comment)
> 
> --
> Regards,
> ChangAo Chen
> <v1-0001-Fix-incorrect-comments-in-tuplesort.c.patch>

I guess a native English speaker may read the sentence in a different way than our non-English speakers. So, it’s better to wait for an English-speaking committer to decide if this comment needs to be updated.

But I agree from a non-English speaker’s view, this sentence is a little bit confusing, at least makes us to spend more time to understand its real meaning.

However, if we really want to update the comment, I just feel “slightly” is not be best choice here, because “slightly” just means “not too much”, it doesn’t precisely describe the real meaning of the macro. I would suggest a rephrasing like: "We choose the smallest number of SortTuple entries whose total size exceeds ALLOCSET_SEPARATE_THRESHOLD, and so that …"

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix misleading comment in tuplesort.c

  2. Fix bogus "out of memory" reports in tuplestore.c.