Re: speed up unicode normalization quick check

Mark Dilger <mark.dilger@enterprisedb.com>

From: Mark Dilger <mark.dilger@enterprisedb.com>
To: John Naylor <john.naylor@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-09-18T19:41:54Z
Lists: pgsql-hackers

Attachments


> On Sep 18, 2020, at 9:41 AM, John Naylor <john.naylor@2ndquadrant.com> wrote:
> 
> Attached is version 4, which excludes the output file from pgindent,
> to match recent commit 74d4608f5. Since it won't be indented again, I
> also tweaked the generator script to match pgindent for the typedef,
> since we don't want to lose what pgindent has fixed already. This last
> part isn't new to v4, but I thought I'd highlight it anyway.

0001 looks ok to me.  The change is quite minor.  I reviewed it by comparing the assembly generated for perfect hash functions before and after applying the patch.

For 0001, the assembly code generated from the perfect hash functions in src/common/keywords.s and src/pl/plpgsql/src/pl_scanner.s do not appear to differ in any performance significant way.  The assembly code generated in src/interfaces/ecpg/preproc/ecpg_keywords.s and src/interfaces/ecpg/preproc/c_keywords.s change enough that I wouldn't try to compare them just by visual inspection.

Compiled using  -g -O2

Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I'm attaching the diffs of the old and new assembly files, if anyone cares to look.

Commits

  1. Review format of code generated by PerfectHash.pm

  2. Fix compilation warning in unicode_norm.c

  3. Use perfect hash for NFC and NFKC Unicode Normalization quick check

  4. Improve set of candidate multipliers for perfect hash function generation

  5. Further improve pgindent's list of file exclusions.