Cleaning up and speeding up string functions

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Cleaning up and speeding up string functions
Date: 2019-05-25 07:53:35
Message-ID: CAKJS1f9P=M-3ULmPvr8iCno8yvfDViHibJjpriHU8+SXUgeZ=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here's a small patch series aimed to both clean up a few misuses of
string functions and also to optimise a few things along the way.

0001: Converts various call that use appendPQExpBuffer() that really
should use appendPQExrBufferStr(). If there's no formatting then
using the former function is a waste of effort.

0002: Similar to 0001 but replaces various appendStringInfo calls with
appendStringInfoString calls.

0003: Adds a new function named appendStringInfoStringInfo() which
appends one StringInfo onto another. Various places did this using
appendStringInfoString(), but that required a needless strlen() call.
The length is already known and stored in the StringInfo's len field.
Not sure if this is the best name for this function, but can't think
of a better one right now.

0004: inlines appendStringInfoString so that any callers that pass in
a string constant (most of them) can have the strlen() call optimised
out.

I don't have any benchmarks to show workloads that this improves,
Likely the chances that it'll slow anything down are pretty remote.

I'll park this here until July.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
0001-Use-appendPQExpBufferStr-instead-of-appendPQExpBuffe.patch text/x-patch 36.3 KB
0002-Use-appendStringInfoString-instead-of-appendStringIn.patch text/x-patch 4.6 KB
0004-Add-appendStringInfoStringInfo-to-append-one-StringI.patch text/x-patch 7.0 KB
0003-Inline-appendStringInfoString.patch text/x-patch 3.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2019-05-25 10:14:11 Re: Fix link for v12
Previous Message David Rowley 2019-05-25 06:55:11 Re: Runtime pruning problem