From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Improve a few appendStringInfo calls new to v18 |
Date: | 2025-04-10 22:40:57 |
Message-ID: | CAApHDvotxnpFZgJn2UCOWSZKc1J-_miP_vg_ojpRctBAQp3nhw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 11 Apr 2025 at 02:51, Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
> This probably isn't v18 material, but this reminds me of my idea to change
> appendStringInfoString() into a macro for appendBinaryStringInfo() so that
> the compiler can remove the runtime strlen() calls for string literals [0].
> In most cases, the benefits are probably negligible, but StringInfo is
> sometimes used in hot paths.
>
> [0] https://postgr.es/m/20231218164135.GA530790%40nathanxps13
That one has come up a few times. The most lengthy discussion I
remember was in [1]. It didn't come to anything, but I don't think
there were any objections to it, so maybe we should just do it.
In the thread I did some measurements of binary size increases. For
non-compile-time consts, it does mean putting the strlen() call in the
calling function, which is a bit of overhead in terms of size. The
macro trick I suggested should have fixed that, but I admit the macro
is a bit ugly. The macro version also still has the overhead of having
to pass the length of the string when it detects a compile-time const.
David
[1] https://postgr.es/m/flat/a0086cfc-ff0f-2827-20fe-52b591d2666c%40enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Matthias van de Meent | 2025-04-10 22:47:19 | Re: MergeJoin beats HashJoin in the case of multiple hash clauses |
Previous Message | Daniel Gustafsson | 2025-04-10 22:38:02 | Re: Add missing PGDLLIMPORT markings |