pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Add more efficient functions to pqformat API.
4+ messages / 2 participants
[nested] [flat]
* pgsql: Add more efficient functions to pqformat API.
@ 2017-10-11 23:11 Andres Freund <andres@anarazel.de>
2017-11-30 19:49 ` Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 1 reply; 4+ messages in thread
From: Andres Freund @ 2017-10-11 23:11 UTC (permalink / raw)
To: pgsql-committers
Add more efficient functions to pqformat API.
There's three prongs to achieve greater efficiency here:
1) Allow reusing a stringbuffer across pq_beginmessage/endmessage,
with the new pq_beginmessage_reuse/endmessage_reuse. This can be
beneficial both because it avoids allocating the initial buffer,
and because it's more likely to already have an correctly sized
buffer.
2) Replacing pq_sendint() with pq_sendint$width() inline
functions. Previously unnecessary and unpredictable branches in
pq_sendint() were needed. Additionally the replacement functions
are implemented more efficiently. pq_sendint is now deprecated, a
separate commit will convert all in-tree callers.
3) Add pq_writeint$width(), pq_writestring(). These rely on sufficient
space in the StringInfo's buffer, avoiding individual space checks
& potential individual resizing. To allow this to be used for
strings, expose mbutil.c's MAX_CONVERSION_GROWTH.
Followup commits will make use of these facilities.
Author: Andres Freund
Discussion: https://postgr.es/m/20170914063418.sckdzgjfrsbekae4@alap3.anarazel.de
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1de09ad8eb1fa673ee7899d6dfbb2b49ba204818
Modified Files
--------------
src/backend/libpq/pqformat.c | 88 ++++++++-------------
src/backend/utils/mb/mbutils.c | 11 ---
src/include/libpq/pqformat.h | 168 ++++++++++++++++++++++++++++++++++++++++-
src/include/mb/pg_wchar.h | 11 +++
4 files changed, 208 insertions(+), 70 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API.
2017-10-11 23:11 pgsql: Add more efficient functions to pqformat API. Andres Freund <andres@anarazel.de>
@ 2017-11-30 19:49 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2017-12-05 00:58 ` Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 1 reply; 4+ messages in thread
From: Peter Eisentraut @ 2017-11-30 19:49 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; pgsql-committers
On 10/11/17 19:11, Andres Freund wrote:
> 3) Add pq_writeint$width(), pq_writestring(). These rely on sufficient
> space in the StringInfo's buffer, avoiding individual space checks
> & potential individual resizing. To allow this to be used for
> strings, expose mbutil.c's MAX_CONVERSION_GROWTH.
This has been causing warnings from cpluspluscheck. I suggest the
attached patch to address that.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
0001-Fix-warnings-from-cpluspluscheck.patch (text/plain, 1.8K) download
From 36afad4cd4ade040ae91b6a20041fba5edb98dd5 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 30 Nov 2017 14:46:22 -0500
Subject: [PATCH] Fix warnings from cpluspluscheck
Fix warnings about "comparison between signed and unsigned integer
expressions" in inline functions in header files by adding some casts.
---
src/include/libpq/pqformat.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/include/libpq/pqformat.h b/src/include/libpq/pqformat.h
index 4de9e6dd21..9f56d184fd 100644
--- a/src/include/libpq/pqformat.h
+++ b/src/include/libpq/pqformat.h
@@ -51,7 +51,7 @@ pq_writeint8(StringInfoData *pg_restrict buf, int8 i)
{
int8 ni = i;
- Assert(buf->len + sizeof(int8) <= buf->maxlen);
+ Assert(buf->len + (int) sizeof(int8) <= buf->maxlen);
memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(int8));
buf->len += sizeof(int8);
}
@@ -65,7 +65,7 @@ pq_writeint16(StringInfoData *pg_restrict buf, int16 i)
{
int16 ni = pg_hton16(i);
- Assert(buf->len + sizeof(int16) <= buf->maxlen);
+ Assert(buf->len + (int) sizeof(int16) <= buf->maxlen);
memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(int16));
buf->len += sizeof(int16);
}
@@ -79,7 +79,7 @@ pq_writeint32(StringInfoData *pg_restrict buf, int32 i)
{
int32 ni = pg_hton32(i);
- Assert(buf->len + sizeof(int32) <= buf->maxlen);
+ Assert(buf->len + (int) sizeof(int32) <= buf->maxlen);
memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(int32));
buf->len += sizeof(int32);
}
@@ -93,7 +93,7 @@ pq_writeint64(StringInfoData *pg_restrict buf, int64 i)
{
int64 ni = pg_hton64(i);
- Assert(buf->len + sizeof(int64) <= buf->maxlen);
+ Assert(buf->len + (int) sizeof(int64) <= buf->maxlen);
memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(int64));
buf->len += sizeof(int64);
}
--
2.15.0
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API.
2017-10-11 23:11 pgsql: Add more efficient functions to pqformat API. Andres Freund <andres@anarazel.de>
2017-11-30 19:49 ` Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
@ 2017-12-05 00:58 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2017-12-05 01:04 ` Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API. Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 4+ messages in thread
From: Peter Eisentraut @ 2017-12-05 00:58 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; pgsql-committers
On 11/30/17 14:49, Peter Eisentraut wrote:
> On 10/11/17 19:11, Andres Freund wrote:
>> 3) Add pq_writeint$width(), pq_writestring(). These rely on sufficient
>> space in the StringInfo's buffer, avoiding individual space checks
>> & potential individual resizing. To allow this to be used for
>> strings, expose mbutil.c's MAX_CONVERSION_GROWTH.
>
> This has been causing warnings from cpluspluscheck. I suggest the
> attached patch to address that.
committed
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API.
2017-10-11 23:11 pgsql: Add more efficient functions to pqformat API. Andres Freund <andres@anarazel.de>
2017-11-30 19:49 ` Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2017-12-05 00:58 ` Re: [COMMITTERS] pgsql: Add more efficient functions to pqformat API. Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
@ 2017-12-05 01:04 ` Andres Freund <andres@anarazel.de>
0 siblings, 0 replies; 4+ messages in thread
From: Andres Freund @ 2017-12-05 01:04 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: pgsql-committers
On 2017-12-04 19:58:01 -0500, Peter Eisentraut wrote:
> On 11/30/17 14:49, Peter Eisentraut wrote:
> > On 10/11/17 19:11, Andres Freund wrote:
> >> 3) Add pq_writeint$width(), pq_writestring(). These rely on sufficient
> >> space in the StringInfo's buffer, avoiding individual space checks
> >> & potential individual resizing. To allow this to be used for
> >> strings, expose mbutil.c's MAX_CONVERSION_GROWTH.
> >
> > This has been causing warnings from cpluspluscheck. I suggest the
> > attached patch to address that.
>
> committed
Thanks!
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2017-12-05 01:04 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-10-11 23:11 pgsql: Add more efficient functions to pqformat API. Andres Freund <andres@anarazel.de>
2017-11-30 19:49 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2017-12-05 00:58 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2017-12-05 01:04 ` Andres Freund <andres@anarazel.de>
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