Re: WIP Patch: Add a function that returns binary JSONB as a bytea
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: John Naylor <john.naylor@enterprisedb.com>
Cc: Jelte Fennema <me@jeltef.nl>, Merlin Moncure <mmoncure@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Andrew Dunstan <andrew.dunstan@2ndquadrant.com>, Stephen Frost <sfrost@snowman.net>, kevinvan@shift.com, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2022-06-24T17:12:02Z
Lists: pgsql-hackers
Hi, On 2022-06-24 14:33:00 +0700, John Naylor wrote: > On Thu, Jun 23, 2022 at 9:06 PM Andres Freund <andres@anarazel.de> wrote: > > It looks like there's quite a bit of low hanging fruits to optimize... > > Yeah, if escapes and control characters are rare, adding an SSE2 fast > path would give a boost to json_lex_string: check 16 bytes at a time > for those chars (plus the ending double-quote). The biggest thing I see is building the string in bigger chunks. Doing a separate appendStringInfoChar() for each input character is obviously bad for performance. I'd bet a good chunk of the time attributed to json_lex_string() in Jelte's flamegraph is actually setting up the external function call to appendStringInfoChar(). Which then proceeds to do a check whether the buffer needs to be enlarged and maintains the trailing null byte on every call. Greetings, Andres Freund
Commits
-
Build de-escaped JSON strings in larger chunks during lexing
- 3838fa269c15 16.0 landed