From: John Naylor <john.naylor@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve worst-case performance of text_position_get_match_pos()
Date: Fri, 04 Feb 2022 15:57:18 +0000
Message-ID: <E1nG0xa-0005QF-E8@gemulon.postgresql.org> (raw)
Improve worst-case performance of text_position_get_match_pos()
This function converts a byte position to a character position after
a successful string match. Rather than calling pg_mblen() in a loop,
use pg_mbstrlen_with_len() since the latter can inline its own call to
pg_mblen(). When the string match is at the end of the haystack text, this
change results in 10-20% performance improvement, depending on platform and
typical character length in bytes. This also simplifies the code a little.
Specializing for UTF-8 could result in further improvement, but the
performance gain was not found to be reliable between platforms. The modest
gain in this commit is stable between platforms and usable by all server
encodings.
Discussion:
https://www.postgresql.org/message-id/CAFBsxsH1Yutrmu+6LLHKK8iXY+vG--Do6zN+2900spHXQNNQKQ@mail.gmail...
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/b31e3f561365136b48d63e8561f32b697df16d1d
Modified Files
--------------
src/backend/utils/adt/varlena.c | 28 +++++-----------------------
1 file changed, 5 insertions(+), 23 deletions(-)
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: john.naylor@postgresql.org
Subject: Re: pgsql: Improve worst-case performance of text_position_get_match_pos()
In-Reply-To: <E1nG0xa-0005QF-E8@gemulon.postgresql.org>
References: <E1nG0xa-0005QF-E8@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