From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Proposal: add new API to stringinfo |
Date: | 2024-12-26 03:15:42 |
Message-ID: | CAApHDvrxXG1yrELvi+ZKjEk9DvAo0j6y4Lr28aOuTqgw1zQvtQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, 25 Dec 2024 at 16:37, Tatsuo Ishii <ishii(at)postgresql(dot)org> wrote:
> Currently the StringInfo package provides StringInfo object creation
> API with fixed length initial allocation size (1024 bytes). However,
> if we want to allocate much smaller size of initial allocation, this
> is waste of space.
I think it would be good to have some method to allow callers to
specify the initial size. I'm personally surprise that the 1024
setting has been ok with all callers so far. StringInfo has always
reminded me of C#'s StringBuilder class, which has an overloaded
constructor to allow callers to specify the initial size. It seems
they realised that the default size isn't always ideal, so I don't
find it surprising that we've realised that too.
If you have trouble convincing people we need this for some new
reason, then maybe you could review the existing callers to see if
some of the existing call sites make it any more convincing.
A very quick review, I found:
send_message_to_frontend() initStringInfo(&buf) 1024 is probably too big
HandleParallelMessages() seems to know exactly how many bytes are
needed. Can this use a read-only StringInfo?
send_feedback() seems to know what size of the buffer it needs
buf_init() knows the exact size.
I didn't review the patch in detail, but I think "initsize" would be a
better parameter name than "size".
David
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2024-12-26 03:37:12 | Re: Proposal: add new API to stringinfo |
Previous Message | Tatsuo Ishii | 2024-12-26 00:53:09 | Re: Proposal: add new API to stringinfo |