Re: Fix incorrect comments in tuplesort.c

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

From: Chao Li <li.evan.chao@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: "David G. Johnston" <david.g.johnston@gmail.com>, cca5507 <cca5507@qq.com>, pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-08T01:20:00Z
Lists: pgsql-hackers

> On Dec 8, 2025, at 08:28, David Rowley <dgrowleyml@gmail.com> wrote:
> 
> + * in grow_memtuples().  However, we don't consider array sizes
> + * less than 1024.
> 
> Using "However" here indicates some exception to what's just been
> said, but there is no longer an exception. To write about what the
> 1024 is for, we might need to reverse engineer what that's for. I
> assume it's something like "Clamp at 1024 elements to avoid excessive
> reallocs of the array". Or perhaps that without the " of the array"
> part.

+1 for the “however” concern.

Also, I found 8ea3e7a75c might explain why we want initial memtuples array size to exceed ALLOCSET_SEPARATE_THRESHOLD. That's because we want to avoid switching between block chunk and separate chunk when growing.

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.