public inbox for [email protected]
help / color / mirror / Atom feedFrom: Andy Fan <[email protected]>
Subject: [PATCH v20240912 3/4] add unlikely hint for enlargeStringInfo.
Date: Wed, 11 Sep 2024 12:25:52 +0800
enlargeStringInfo has a noticeable ratio in perf peport with a
"select * from pg_class" workload). So add a unlikely hint in
enlargeStringinfo to avoid some overhead.
---
src/common/stringinfo.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/common/stringinfo.c b/src/common/stringinfo.c
index eb9d6502fc..838d9b80d0 100644
--- a/src/common/stringinfo.c
+++ b/src/common/stringinfo.c
@@ -297,7 +297,7 @@ enlargeStringInfo(StringInfo str, int needed)
* Guard against out-of-range "needed" values. Without this, we can get
* an overflow or infinite loop in the following.
*/
- if (needed < 0) /* should not happen */
+ if (unlikely(needed < 0)) /* should not happen */
{
#ifndef FRONTEND
elog(ERROR, "invalid string enlargement request size: %d", needed);
@@ -306,7 +306,7 @@ enlargeStringInfo(StringInfo str, int needed)
exit(EXIT_FAILURE);
#endif
}
- if (((Size) needed) >= (MaxAllocSize - (Size) str->len))
+ if (unlikely(((Size) needed) >= (MaxAllocSize - (Size) str->len)))
{
#ifndef FRONTEND
ereport(ERROR,
--
2.45.1
--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
filename=v20240912-0001-Refactor-float8out_internval-for-better-pe.patch
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH v20240912 3/4] add unlikely hint for enlargeStringInfo.
In-Reply-To: <no-message-id-77772@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox