Re: appendBinaryStringInfo stuff - Mailing list pgsql-hackers

From David Rowley
Subject Re: appendBinaryStringInfo stuff
Date
Msg-id CAApHDvqBcc=-7VgbB_YLT7Fn0xQMGJ25x7wJuooyHuTcN3z28Q@mail.gmail.com
Whole thread Raw
In response to Re: appendBinaryStringInfo stuff  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: appendBinaryStringInfo stuff
List 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



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Force streaming every change in logical decoding
Next
From: Amit Kapila
Date:
Subject: Re: Force streaming every change in logical decoding