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