pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Alexander Borisov <lex.borisov@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
To: pgsql-hackers@postgresql.org
Subject: Re: Optimization for lower(), upper(), casefold() functions.
Date: Wed, 12 Mar 2025 22:32:57 +0300
Message-ID: <fddf4811-8292-4da0-908b-77524002444c@gmail.com> (raw )
In-Reply-To: <be117144-0d26-4763-ae97-f12e87ee2741@gmail.com >
References: <7cac7e66-9a3b-4e3f-a997-42aa0c401f80@gmail.com >
<2a1b632e-4531-43cf-a6d9-51cc1a271dc1@gmail.com >
<e7abe9be-1f1a-4fed-9cc3-35be257bab34@gmail.com >
<7ab9d255-d7c0-4841-96c3-ed3ce9aa4abd@iki.fi >
<12956299-1496-4455-b3ab-299cc0a87d7c@gmail.com >
<340f2451-cd76-487b-a1e4-0f0a2fe91fba@gmail.com >
<3ffb8b75b26e76624668c0883cac7886468c5d07.camel@j-davis.com >
<5cf176fa-44b9-4019-b9b7-ee902352a844@gmail.com >
<3080de9bcce916cf8720ac197f634e381c4de564.camel@j-davis.com >
<1e3f4f6f-9b12-4109-b0d2-a4c52b5064f8@gmail.com >
<d0dd50662da84f582c34247f4ed43061e8d86d34.camel@j-davis.com >
<e9057c71-93ec-4a21-b02e-979c7da2b665@gmail.com >
<f1d9edd497cc799720cdb49c50cd0067460a5443.camel@j-davis.com >
<cc097475-8fc5-4d3a-8044-8438126933b2@gmail.com >
<4f3772355e038acd3cfe0be43ae2c1aacae1794d.camel@j-davis.com >
<be117144-0d26-4763-ae97-f12e87ee2741@gmail.com >
12.03.2025 19:55, Alexander Borisov wrote:
[...]
>> A couple questions:
>>
>> * Is there a reason the fast-path for codepoints < 0x80 is in
>> unicode_case.c rather than unicode_case_func.h?
>
> Yes, this is an important optimization, below are benchmarks that
[...]
I forgot to add the benchmark:
Benchmark
Anatation:
Patch v3j_0001: patch v3j_0001 without any changes.
Patch v3j_0001 + static: patch v3j_0001 with adding static to casemap().
Patch v3j_0001 + static + fast path: patch v3j_0001 with adding static
to casemap() and fast path for codepoint < 0x80.
v4_0001: v3j_0001 + static + fast path
v4_0001 + v3j_0002: v3j_0002 patch unchanged, but with static for
casemap() (inherited from v4_0001 patch)
v4_0001 + v4_0002: changed fast path for codepoint < 0x80. Made fast
return to avoid unnecessary checks.
Without: current version of the code without any patches.
All results are in tps.
* macOS 15.1 (Apple M3 Pro) (Apple clang version 16.0.0)
ASCII:
Repeated characters (700kb) in the range from 0x20 to 0x7E.
Patch v3j_0001: 201.029609
Patch v3j_0001 + static: 247.155438
Patch v3j_0001 + static + fast path: 267.941047
Patch v4_0001 + v3j_0002: 260.737601
Patch v4_0001 + v4_0002: 268.913658
Without: 260.437508
Cyrillic:
Repeated characters (1MB) in the range from 0x0410 to 0x042F.
Patch v3j_0001: 48.130350
Patch v3j_0001 + static: 49.365897
Patch v3j_0001 + static + fast path: 48.891842
Patch v4_0001 + v3j_0002: 88.833061
Patch v4_0001 + v4_0002: 88.329603
Without: 47.869687
Unicode:
A query consisting of all Unicode characters from 0xA0 to 0x2FA1D
(excluding 0xD800..0xDFFF).
Patch v3j_0001: 91.333557
Patch v3j_0001 + static: 92.464786
Patch v3j_0001 + static + fast path: 91.359428
Patch v4_0001 + v3j_0002: 103.390609
Patch v4_0001 + v4_0002: 102.819763
Without: 92.279652
Regards,
Alexander Borisov
view thread (33+ messages) latest in thread
Message-ID: <fddf4811-8292-4da0-908b-77524002444c@gmail.com>
Permalink: ../fddf4811-8292-4da0-908b-77524002444c@gmail.com/
Also on: postgresql.org/message-id/fddf4811-8292-4da0-908b-77524002444c@gmail.com
copy link · copy postgr.es
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: lex.borisov@gmail.com, pgsql@j-davis.com, hlinnaka@iki.fi
Subject: Re: Optimization for lower(), upper(), casefold() functions.
In-Reply-To: <fddf4811-8292-4da0-908b-77524002444c@gmail.com>
* 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