Re: Optimization for lower(), upper(), casefold() functions.

Alexander Borisov <lex.borisov@gmail.com>

From: Alexander Borisov <lex.borisov@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2025-01-30T13:39:53Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix headerscheck warning.

  2. Optimization for lower(), upper(), casefold() functions.

  3. Refactor convert_case() to prepare for optimizations.

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

Attachments

29.01.2025 23:52, Alexander Borisov пишет:
> Sorry, I made a mistake in the code. It's not worth watching this patch 
> yet.
> 

The code is fixed, now the patch passes all tests.

Change from the original patch (v1):
Reduce the main table from 3003 to 1677 (duplicates removed) records.
Added records from 0x00 to 0x80 for fast path.
Renamed get_case() function to pg_unicode_case_index().

Benchmark numbers have changed a bit.
casefold() test.

* macOS 15.1 (Apple M3 Pro) (Apple clang version 16.0.0)

ASCII:
Repeated characters (700kb) in the range from 0x20 to 0x7E.
Patch: tps = 270.044184
Without: tps = 259.185352

Cyrillic:
Repeated characters (1MB) in the range from 0x0410 to 0x042F.
Patch: tps = 84.120857
Without: tps = 48.731075

Unicode:
A query consisting of all Unicode characters from 0xA0 to 0x2FA1D
(excluding 0xD800..0xDFFF).
Patch: tps = 101.010641
Without: tps = 91.539395

* Ubuntu 24.04.1 (Intel(R) Xeon(R) Gold 6140) (gcc version 13.3.0)

ASCII:
Repeated characters (700kb) in the range from 0x20 to 0x7E.
Patch: tps = 141.719239
Without: tps = 121.453662

Cyrillic:
Repeated characters (1MB) in the range from 0x0410 to 0x042F.
Patch: tps = 44.062579
Without: tps = 24.999893

Unicode:
A query consisting of all Unicode characters from 0xA0 to 0x2FA1D
(excluding 0xD800..0xDFFF).
Patch: tps = 55.633318
Without: tps = 46.321490


--
SberTech
Alexander Borisov