Re: appendBinaryStringInfo stuff
John Naylor <john.naylor@enterprisedb.com>
From: John Naylor <john.naylor@enterprisedb.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Andres Freund <andres@anarazel.de>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-12-22T12:20:37Z
Lists: pgsql-hackers
On Thu, Dec 22, 2022 at 4:19 PM David Rowley <dgrowleyml@gmail.com> wrote:
>
> Test 1 (from earlier)
>
> master + escape_json using appendStringInfoCharMacro
> $ pgbench -n -T 60 -f bench.sql -M prepared postgres | grep latency
> latency average = 1.807 ms
> latency average = 1.800 ms
> latency average = 1.812 ms (~4.8% faster than master)
> 23.05% postgres [.] pg_utf_mblen
I get about 20% improvement by adding an ascii fast path in
pg_mbstrlen_with_len, which I think would work with all encodings we
support:
@@ -1064,7 +1064,12 @@ pg_mbstrlen_with_len(const char *mbstr, int limit)
while (limit > 0 && *mbstr)
{
- int l = pg_mblen(mbstr);
+ int l;
+
+ if (!IS_HIGHBIT_SET(*mbstr))
+ l = 1;
+ else
+ l = pg_mblen(mbstr);
--
John Naylor
EDB: http://www.enterprisedb.com
Commits
-
Change argument type of pq_sendbytes from char * to void *
- 3b12e68a5c46 16.0 landed
-
Remove useless casts to (void *) in hash_search() calls
- 54a177a948b0 16.0 cited
-
Change argument of appendBinaryStringInfo from char * to void *
- 1f605b82ba66 16.0 landed
-
Use appendStringInfoString instead of appendBinaryStringInfo where possible
- 33a33f0ba4d7 16.0 landed