| 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: Avoid building stderr message if possible |
| Date: | 2026-08-05 05:52:36 |
| Message-ID: | ED54E737-B936-471A-8FEB-979A8EF4E4F0@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Aug 2, 2026, at 23:51, cca5507 <cca5507(at)qq(dot)com> wrote:
>
> Hi hackers,
>
> Now we always build a message formatted for stderr in send_message_to_server_log()
> even if it's useless in some case, e.g., log_destination = 'csvlog'. Attach a patch to
> avoid building it if possible.
>
> Test
> ====
> I test it with a large sql (32MB) with guc:
> ```
> log_destination = 'csvlog'
> logging_collector = on
> log_min_duration_statement = 0
> ```
>
> master:
> ```
> pgbench (20devel)
> transaction type: large.sql
> scaling factor: 1
> query mode: simple
> number of clients: 1
> number of threads: 1
> maximum number of tries: 1
> duration: 60 s
> number of transactions actually processed: 205
> number of failed transactions: 0 (0.000%)
> latency average = 293.219 ms
> initial connection time = 0.767 ms
> tps = 3.410415 (without initial connection time)
> ```
>
> patched:
> ```
> pgbench (20devel)
> transaction type: large.sql
> scaling factor: 1
> query mode: simple
> number of clients: 1
> number of threads: 1
> maximum number of tries: 1
> duration: 60 s
> number of transactions actually processed: 229
> number of failed transactions: 0 (0.000%)
> latency average = 263.087 ms
> initial connection time = 1.068 ms
> tps = 3.801022 (without initial connection time)
> ```
>
> Thoughts?
>
> --
> Regards,
> ChangAo Chen
> <v1-0001-Avoid-building-stderr-message-if-possible.patch>
Hi ChangAo,
I just reviewed this patch. I think the idea is good, it builds the string buffer only when needed.
I’m not sure why you use “stderr” in the new function name build_stderr_message() and the variable name has_stderr_message, as the buffer is also consumed by syslog and eventlog. Maybe build_log_buffer() and buf_built?
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-08-05 06:28:24 | Re: Reduce memory overheads for storing a Memoize tuple |
| Previous Message | Rafia Sabih | 2026-08-05 05:49:14 | Re: [PATCH] Add tests for src/backend/nodes/extensible.c |