Re: speed up unicode decomposition and recomposition

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "John Naylor" <john(dot)naylor(at)enterprisedb(dot)com>
Cc: "Kyotaro Horiguchi" <horikyota(dot)ntt(at)gmail(dot)com>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>,"Michael Paquier" <michael(at)paquier(dot)xyz>,"pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: speed up unicode decomposition and recomposition
Date: 2020-10-16 18:08:55
Message-ID: 041d6bff-9b37-430c-80f6-67e1cb68dab2@manitou-mail.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

John Naylor wrote:

> I'd be curious how it compares to ICU now

I've made another run of the test in [1] with your v2 patches
from this thread against icu_ext built with ICU-67.1.
The results show the times in milliseconds to process
about 10 million short strings:

operation | unpatched | patched | icu_ext
------------+-----------+---------+---------
nfc check | 7968 | 5989 | 4076
nfc conv | 700894 | 15163 | 6808
nfd check | 16399 | 9852 | 3849
nfd conv | 17391 | 10916 | 6758
nfkc check | 8259 | 6092 | 4301
nfkc conv | 700241 | 15354 | 7034
nfkd check | 16585 | 10049 | 4038
nfkd conv | 17587 | 11109 | 7086

The ICU implementation still wins by a large margin, but
the improvements brought by the patch are gorgeous,
especially for the conversion to NFC/NFKC.
This test ran on a slower machine than what I used for [1], so
that's why all queries take longer.

For the two queries upthread, I get this:

1)
select count(normalize(t, NFC)) from (
select md5(i::text) as t from
generate_series(1,100000) as i
) s;
count
--------
100000
(1 row)

Time: 371.043 ms

VS ICU:

select count(icu_normalize(t, 'NFC')) from (
select md5(i::text) as t from
generate_series(1,100000) as i
) s;
count
--------
100000
(1 row)

Time: 125.809 ms

2)
select count(normalize(t, NFC)) from (
select repeat(U&'\00E4\00C5\0958\00F4\1EBF\3300\1FE2\3316\2465\322D', i % 3
+ 1) as t from
generate_series(1,100000) as i
) s;
count
--------
100000
(1 row)
Time: 428.214 ms

VS ICU:

select count(icu_normalize(t, 'NFC')) from (
select repeat(U&'\00E4\00C5\0958\00F4\1EBF\3300\1FE2\3316\2465\322D', i % 3
+ 1) as t from
generate_series(1,100000) as i
) s;
count
--------
100000
(1 row)

Time: 147.713 ms

[1]
https://www.postgresql.org/message-id/2c5e8df9-43b8-41fa-88e6-286e8634f00a%40manitou-mail.org

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: https://www.manitou-mail.org
Twitter: @DanielVerite

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-10-16 18:57:28 Re: Commitfest manager 2020-11
Previous Message Anastasia Lubennikova 2020-10-16 18:04:45 Re: Commitfest manager 2020-11