Re: Making aggregate deserialization (and WAL receive) functions slightly faster
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2023-10-04T06:47:11Z
Lists: pgsql-hackers
Thanks for taking a look at this. On Wed, 4 Oct 2023 at 16:57, Michael Paquier <michael@paquier.xyz> wrote: > + buf.len = VARSIZE_ANY_EXHDR(sstate); > + buf.maxlen = 0; > + buf.cursor = 0; > > Perhaps it would be worth hiding that in a macro defined in > stringinfo.h? The original patch had a new function in stringinfo.c which allowed a StringInfoData to be initialised from an existing string with some given length. Tom wasn't a fan of that because there wasn't any protection against someone trying to use the given StringInfoData and then calling appendStringInfo to append another string. That can't be done in this case as we can't repalloc the VARDATA_ANY(state) pointer due to it not pointing directly to a palloc'd chunk. Tom's complaint seemed to be about having a reusable function which could be abused, so I modified the patch to remove the reusable code. I think your macro idea in stringinfo.h would put the patch in the same position as it was initially. It would be possible to do something like have maxlen == -1 mean that the StringInfoData.data field isn't being managed internally in stringinfo.c and then have all the appendStringInfo functions check for that, but I really don't want to add overhead to everything that uses appendStringInfo just for this. David
Commits
-
Make use of initReadOnlyStringInfo() in more places
- ac7d6f5f831e 17.0 landed
-
Optimize various aggregate deserialization functions, take 2
- 0c882a298881 17.0 landed
-
Introduce the concept of read-only StringInfos
- f0efa5aec193 17.0 landed
-
Revert "Optimize various aggregate deserialization functions"
- 4f3b56eea235 17.0 landed
-
Optimize various aggregate deserialization functions
- 608fd198def5 17.0 landed