Re: appendBinaryStringInfo stuff

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: appendBinaryStringInfo stuff
Date: 2022-12-22 09:19:16
Message-ID: CAApHDvqBcc=-7VgbB_YLT7Fn0xQMGJ25x7wJuooyHuTcN3z28Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 22 Dec 2022 at 20:56, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> David Rowley <dgrowleyml(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-12-22 09:19:40 Re: Force streaming every change in logical decoding
Previous Message Amit Kapila 2022-12-22 09:16:04 Re: Force streaming every change in logical decoding