Re: Fix incorrect comments in tuplesort.c

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: cca5507 <cca5507(at)qq(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix incorrect comments in tuplesort.c
Date: 2025-12-07 03:55:45
Message-ID: CFD53790-6157-4A8E-8E4F-918AB3657710@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Dec 6, 2025, at 22:56, cca5507 <cca5507(at)qq(dot)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/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message cca5507 2025-12-07 05:48:14 Re: Fix incorrect comments in tuplesort.c
Previous Message 河田達也 2025-12-07 03:37:08 Re: [PATCH] Add sampling statistics to autoanalyze log output