Re: appendBinaryStringInfo stuff

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Andres Freund <andres@anarazel.de>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-12-22T09:19:16Z
Lists: pgsql-hackers
On Thu, 22 Dec 2022 at 20:56, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> David Rowley <dgrowleyml@gmail.com> writes:
> >   22.57%  postgres          [.] escape_json
>
> Hmm ... shouldn't we do something like
>
> -                appendStringInfoString(buf, "\\b");
> +                appendStringInfoCharMacro(buf, '\\');
> +                appendStringInfoCharMacro(buf, 'b');
>
> and so on in that function?  I'm not convinced that this one
> hotspot justifies inlining appendStringInfoString everywhere.

It improves things slightly:

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
  22.55%  postgres          [.] escape_json
   8.58%  postgres          [.] JsonbIteratorNext.part.0
   6.80%  postgres          [.] AllocSetAlloc
   4.23%  postgres          [.] pg_mbstrlen_with_len
   3.88%  postgres          [.] JsonbToCStringWorker
   3.79%  postgres          [.] fillJsonbValue
   3.18%  postgres          [.] appendBinaryStringInfo
   2.43%  postgres          [.] enlargeStringInfo
   2.02%  postgres          [.] palloc
   1.61%  postgres          [.] jsonb_put_escaped_value

David



Commits

  1. Change argument type of pq_sendbytes from char * to void *

  2. Remove useless casts to (void *) in hash_search() calls

  3. Change argument of appendBinaryStringInfo from char * to void *

  4. Use appendStringInfoString instead of appendBinaryStringInfo where possible