pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve performance of Unicode {de,re}composition in the backend
Date: Fri, 23 Oct 2020 02:09:42 +0000
Message-ID: <E1kVmWU-0005ls-SS@gemulon.postgresql.org> (raw)

Improve performance of Unicode {de,re}composition in the backend

This replaces the existing binary search with two perfect hash functions
for the composition and the decomposition in the backend code, at the
cost of slightly-larger binaries there (35kB in libpgcommon_srv.a).  Per
the measurements done, this improves the speed of the recomposition and
decomposition by up to 30~40 times for the NFC and NFKC conversions,
while all other operations get at least 40% faster.  This is not as
"good" as what libicu has, but it closes the gap a lot as per the
feedback from Daniel Verite.

The decomposition table remains the same, getting used for the binary
search in the frontend code, where we care more about the size of the
libraries like libpq over performance as this gets involved only in code
paths related to the SCRAM authentication.  In consequence, note that
the perfect hash function for the recomposition needs to use a new
inverse lookup array back to to the existing decomposition table.

The size of all frontend deliverables remains unchanged, even with
--enable-debug, including libpq.

Author: John Naylor
Reviewed-by: Michael Paquier, Tom Lane
Discussion: https://postgr.es/m/CAFBsxsHUuMFCt6-pU+oG-F1==CmEp8wR+O+bRouXWu6i8kXuqA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/783f0cc64dcc05e3d112a06b1cd181e5a1ca9099

Modified Files
--------------
src/common/unicode/Makefile                       |    4 +-
src/common/unicode/generate-unicode_norm_table.pl |  226 +-
src/common/unicode_norm.c                         |  106 +-
src/include/common/unicode_norm_hashfunc.h        | 2932 +++++++++++++++++++++
src/tools/pgindent/exclude_file_patterns          |    3 +-
5 files changed, 3227 insertions(+), 44 deletions(-)



Message-ID: <E1kVmWU-0005ls-SS@gemulon.postgresql.org>
Permalink:  ../E1kVmWU-0005ls-SS@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kVmWU-0005ls-SS@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Improve performance of Unicode {de,re}composition in the backend
  In-Reply-To: <E1kVmWU-0005ls-SS@gemulon.postgresql.org>
  References: <E1kVmWU-0005ls-SS@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox