Re: Proposal: add new API to stringinfo - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Proposal: add new API to stringinfo
Date
Msg-id Z4BbR4RGpL4O5iYj@nathan
Whole thread Raw
In response to Re: Proposal: add new API to stringinfo  (Nathan Bossart <nathandbossart@gmail.com>)
List pgsql-hackers
On Thu, Jan 09, 2025 at 03:21:41PM +0900, Tatsuo Ishii wrote:
> Ok, I have created v3 patch to do more inlining as you suggested. With
> the patch I confirmed that there's no call to functions except palloc
> in makeStringInfo, makeStringInfoExt, initStringInfo and
> initStringInfoExt in the asm codes (see attached stringinfo.s).

Looks generally reasonable to me.

+/*
+ * initStringInfoInternal
+ *
+ * Initialize a StringInfoData struct (with previously undefined contents)
+ * to describe an empty string.
+ * The initial memory allocation size is specified by 'initsize'.
+ * The valid range for 'initsize' is 1 to MaxAllocSize.
+ */
+static inline void
+initStringInfoInternal(StringInfo str, int initsize)
+{
+    Assert(initsize > 0);
+
+    str->data = (char *) palloc(initsize);
+    str->maxlen = initsize;
+    resetStringInfo(str);
+}

nitpick: Should we Assert(initsize <= MaxAllocSize) here, too?

-- 
nathan



pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Adjusting hash join memory limit to handle batch explosion
Next
From: Tomas Vondra
Date:
Subject: Re: Adjusting hash join memory limit to handle batch explosion