Re: appendBinaryStringInfo stuff - Mailing list pgsql-hackers

From John Naylor
Subject Re: appendBinaryStringInfo stuff
Date
Msg-id CAFBsxsFYqFamtTPXRPz7+qtLV2aDaCGywa18muyad4kgmRojLQ@mail.gmail.com
Whole thread Raw
In response to Re: appendBinaryStringInfo stuff  (David Rowley <dgrowleyml@gmail.com>)
List 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

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Perform streaming logical transactions by background workers and parallel apply
Next
From: Masahiko Sawada
Date:
Subject: Re: Perform streaming logical transactions by background workers and parallel apply