Re: pgsql: Improve performance of SendRowDescriptionMessage.

Noah Misch <noah@leadboat.com>

From: Noah Misch <noah@leadboat.com>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-committers@postgresql.org
Date: 2017-10-13T02:39:04Z
Lists: pgsql-hackers
On Thu, Oct 12, 2017 at 04:48:29PM -0700, Andres Freund wrote:
> On 2017-10-12 16:08:44 -0700, Andres Freund wrote:
> > wrap-gcc -D_THREAD_SAFE=1 -D_LARGE_FILES=1 -maix64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O2 -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS  -DFRONTEND -DUNSAFE_STAT_OK -I. -I../../../src/include   -I../../../src/port -I../../../src/port -DSO_MAJOR_VERSION=5  -c -o fe-connect.o fe-connect.c
> > fe-connect.c: In function 'PQconnectPoll':
> > fe-connect.c:2382:6: warning: implicit declaration of function 'getpeereid' [-Wimplicit-function-declaration]
> >       if (getpeereid(conn->sock, &uid, &gid) != 0)
> >       ^
> > 
> > Looks like we're missing
> > #include <sys/types.h>
> 
> Hm, it got removed as part of
> http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=9e3755ecb2d058f7d123dd35a2e1784006190962
> but that's not an explanation, because
> c.h includes sys/types.h. Which according to IBM's docs
> https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.basetrf1/getpeereid.htm
> is the right thing to include.  Given that xlc doesn't complain, I'll
> just assume this is some issue with the headers gcc uses on aix, but I'm
> far from confident.

The relevant xlc warning is disabled by default.  "xlc -qinfo=pro" does
complain.  <sys/types.h> provides no such prototype.  <sys/socket.h> provides
a getpeereid() prototype, but under C++ only.  (For getpeername(), it provides
both C and C++ prototypes.)  Thus, the AIX documentation is wrong, and
/usr/include is buggy.


Commits

  1. Force "restrict" not to be used when compiling with xlc.

  2. Rely on sizeof(typename) rather than sizeof(variable) in pqformat.h.

  3. Use C99 restrict via pg_restrict, rather than restrict directly.

  4. Improve performance of SendRowDescriptionMessage.

  5. Partially flatten struct tupleDesc so that it can be used in DSM.

  6. Remove useless duplicate inclusions of system header files.