| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
| Cc: | Japin Li <japinli(at)hotmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Avoid repeated scans of the output buffer in oidvectortypes() |
| Date: | 2026-10-15 12:15:31 |
| Message-ID: | C6806CAA-FA04-4161-89B9-349BB01AE73F@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Oct 15, 2026, at 18:43, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Thu, 15 Oct 2026 at 23:20, Japin Li <japinli(at)hotmail(dot)com> wrote:
>> I believe the current patch is the smallest correct fix. Introducing StringInfo
>> would be unnecessary over-engineering.
>
> I'm assuming this is master only, so why does it need to be a minimal
> fix? StringInfo is just the way we normally do incremental building of
> strings. It's an API that most people who work on our code understand.
> Manually calling repalloc() is tedious and more likely to have bugs.
>
> Using StringInfo will also cut down on the number of reallocs due to
> the size doubling. It'll also allow the
> PG_RETURN_TEXT_P(cstring_to_text(result)); to be updated to use
> cstring_to_text_with_len using the StringInfo's len field.
>
> David
I tried StringInfo first. A few minor reasons led me to choose the v1 approach:
* v1 made fewer changes to the existing code.
* v1 was slightly faster in my test. With debug and assertions disabled, v1 took about 20 ms and StringInfo about 24 ms, averaged over multiple runs.
I agree that using the usual API outweigh these minor considerations. I've updated the patch to use StringInfo in v2.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Use-StringInfo-to-build-the-result-in-oidvectorty.patch | application/octet-stream | 2.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nitin Jadhav | 2026-10-15 12:47:54 | Re: [PATCH] Fix recovery connection detail in EXEC_BACKEND builds |
| Previous Message | Heikki Linnakangas | 2026-10-15 12:08:49 | Re: enhancing pg_basebackup speeds up to ~23Gbps (small fixes + io_uring/Direct I/O) |