Re: [PATCH] Optimize json_lex_string by batching character copying
John Naylor <john.naylor@enterprisedb.com>
From: John Naylor <john.naylor@enterprisedb.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, Jelte Fennema <Jelte.Fennema@microsoft.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>,
Merlin Moncure <mmoncure@gmail.com>, Andrew Dunstan <andrew.dunstan@2ndquadrant.com>,
Stephen Frost <sfrost@snowman.net>
Date: 2022-08-25T06:35:45Z
Lists: pgsql-hackers
Attachments
- v9-0002-Speed-up-json_lex_string-via-vector-operations.patch (text/x-patch) patch v9-0002
- v9-0001-Add-optimized-functions-for-linear-search-within-.patch (text/x-patch) patch v9-0001
On Wed, Aug 24, 2022 at 11:56 PM Nathan Bossart <nathandbossart@gmail.com> wrote: > > On Wed, Aug 24, 2022 at 11:59:25AM +0700, John Naylor wrote: > > It seems "scalar" would be a bad choice since it already means > > (confusingly) operating on the least significant element of a vector. > > I'm thinking of *_has and *_has_le, matching the already existing in > > the earlier patch *_has_zero. > > That seems reasonable to me. Okay, done that way, also in v9: - a convenience macro in the test suite which is handy now and can be used for 32-bit element tests if we like - more tests - pgindent and some additional comment smithing - split out the json piece for a later commit - For the following comment, pgindent will put spaced operands on a separate line which is not great for readability. and our other reference to the Stanford bithacks page keeps the in-page link, and I see no reason to exclude it -- if it goes missing, the whole page will still load. So I put back those two details. + * To find bytes <= c, we can use bitwise operations to find bytes < c+1, + * but it only works if c+1 <= 128 and if the highest bit in v is not set. + * Adapted from + * https://graphics.stanford.edu/~seander/bithacks.html#HasLessInWord I think I'll go ahead and commit 0001 in a couple days pending further comments. -- John Naylor EDB: http://www.enterprisedb.com
Commits
-
Speed up lexing of long JSON strings
- 0a8de93a48ce 16.0 landed
-
Add optimized functions for linear search within byte arrays
- e813e0e16852 16.0 landed
-
Build de-escaped JSON strings in larger chunks during lexing
- 3838fa269c15 16.0 landed
-
Simplify json lexing state
- 3de359f18f2b 16.0 landed