Re: pgsql: Speed up conversion of signed integers to C strings.

Lists: pgsql-committers
From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-20 03:15:41
Message-ID: E1PJdvR-0001kd-Dn@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Speed up conversion of signed integers to C strings.

A hand-coded implementation turns out to be much faster than calling
printf(). In passing, add a few more regresion tests.

Andres Freund, with assorted, mostly cosmetic changes.

Branch
------
master

Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=4fc115b2e981f8c63165ca86a23215380a3fda66

Modified Files
--------------
src/backend/utils/adt/int8.c | 8 +--
src/backend/utils/adt/numutils.c | 115 ++++++++++++++++++++++++++++++++----
src/include/utils/builtins.h | 1 +
src/test/regress/expected/int2.out | 13 ++++
src/test/regress/expected/int4.out | 13 ++++
src/test/regress/expected/int8.out | 13 ++++
src/test/regress/sql/int2.sql | 4 +
src/test/regress/sql/int4.sql | 4 +
src/test/regress/sql/int8.sql | 4 +
9 files changed, 157 insertions(+), 18 deletions(-)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-20 03:48:58
Message-ID: 6577.1290224938@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Robert Haas <rhaas(at)postgresql(dot)org> writes:
> Speed up conversion of signed integers to C strings.

This patch breaks the build here:

gcc -O1 -Wall -Wmissing-prototypes -Wpointer-arith -fno-strict-aliasing -g -I../../../../src/include -D_XOPEN_SOURCE_EXTENDED -c -o numutils.o numutils.c
numutils.c: In function `pg_ltoa':
numutils.c:139: `INT32_MIN' undeclared (first use in this function)
numutils.c:139: (Each undeclared identifier is reported only once
numutils.c:139: for each function it appears in.)
numutils.c: In function `pg_lltoa':
numutils.c:190: `INT64_MIN' undeclared (first use in this function)
make: *** [numutils.o] Error 1
$
regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-20 04:47:16
Message-ID: 11604.1290228436@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

I wrote:
> Robert Haas <rhaas(at)postgresql(dot)org> writes:
>> Speed up conversion of signed integers to C strings.

> This patch breaks the build here:

... and while I'm looking at it, the added int8 regression test cases
definitely merit a WTF. They aren't testing what I would expect.
What they are testing is platform-specific behavior of excessive
shifting, which is why some of the buildfarm members are pink.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-20 06:10:31
Message-ID: AANLkTikFFW3iqzh_Hz1y7pGr1X+xUszYj55H_NULJF_2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

On Fri, Nov 19, 2010 at 11:47 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I wrote:
>> Robert Haas <rhaas(at)postgresql(dot)org> writes:
>>> Speed up conversion of signed integers to C strings.
>
>> This patch breaks the build here:
>
> ... and while I'm looking at it, the added int8 regression test cases
> definitely merit a WTF.  They aren't testing what I would expect.
> What they are testing is platform-specific behavior of excessive
> shifting, which is why some of the buildfarm members are pink.

Ugh. I made an attempt at a fix to both of these issues, but I'm not
totally sure I got it right, and I'm too tired to stay up any later to
see what happens. I'll check the BF in the morning.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-20 10:23:27
Message-ID: 4CE7A19F.1060207@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

On 11/20/2010 01:10 AM, Robert Haas wrote:
> On Fri, Nov 19, 2010 at 11:47 PM, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I wrote:
>>> Robert Haas<rhaas(at)postgresql(dot)org> writes:
>>>> Speed up conversion of signed integers to C strings.
>>> This patch breaks the build here:
>> ... and while I'm looking at it, the added int8 regression test cases
>> definitely merit a WTF. They aren't testing what I would expect.
>> What they are testing is platform-specific behavior of excessive
>> shifting, which is why some of the buildfarm members are pink.
> Ugh. I made an attempt at a fix to both of these issues, but I'm not
> totally sure I got it right, and I'm too tired to stay up any later to
> see what happens. I'll check the BF in the morning.

If you change a test that has alternative result files, you need to
change all the result files. See src/test/regress/resultmap.

In this case you missed out changing int8-exp-three-digits.out - see
<http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=dawn_bat&dt=2010-11-20%2005%3A30%3A07>

cheers

andrew


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-20 12:10:56
Message-ID: AANLkTikchY=xx=nsP2Xj22Sh9grtitrBtRKWxyxrGcwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

On Sat, Nov 20, 2010 at 5:23 AM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>> Ugh.  I made an attempt at a fix to both of these issues, but I'm not
>> totally sure I got it right, and I'm too tired to stay up any later to
>> see what happens.  I'll check the BF in the morning.
>
> If you change a test that has alternative result files, you need to change
> all the result files. See src/test/regress/resultmap.
>
> In this case you missed out changing int8-exp-three-digits.out - see
> <http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=dawn_bat&dt=2010-11-20%2005%3A30%3A07>

Sorry, I always forget about the alternate expected output files,
because they never seem to be the ones that my platform needs.

Ah, the joy of debugging by buildfarm. Nothing better than having the
whole world watch your mistakes in painstaking detail!

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-20 14:30:22
Message-ID: 4CE7DB7E.1060103@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

On 11/20/2010 07:10 AM, Robert Haas wrote:
> Ah, the joy of debugging by buildfarm. Nothing better than having the
> whole world watch your mistakes in painstaking detail!

At least this way you get to do it while your memory is fresh. In the
old days we only found out some things were broken weeks or months later.

cheers

andrew


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-27 22:33:33
Message-ID: 201011272233.oARMXXP07810@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Robert Haas wrote:
> On Sat, Nov 20, 2010 at 5:23 AM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> >> Ugh. ?I made an attempt at a fix to both of these issues, but I'm not
> >> totally sure I got it right, and I'm too tired to stay up any later to
> >> see what happens. ?I'll check the BF in the morning.
> >
> > If you change a test that has alternative result files, you need to change
> > all the result files. See src/test/regress/resultmap.
> >
> > In this case you missed out changing int8-exp-three-digits.out - see
> > <http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=dawn_bat&dt=2010-11-20%2005%3A30%3A07>
>
> Sorry, I always forget about the alternate expected output files,
> because they never seem to be the ones that my platform needs.
>
> Ah, the joy of debugging by buildfarm. Nothing better than having the
> whole world watch your mistakes in painstaking detail!

Yes, in a way when you commit a patch you become a slave of the
buildfarm. I can say that with experience based on the recent patches I
have written.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Speed up conversion of signed integers to C strings.
Date: 2010-11-27 22:34:11
Message-ID: 201011272234.oARMYBq07942@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers

Andrew Dunstan wrote:
>
>
> On 11/20/2010 07:10 AM, Robert Haas wrote:
> > Ah, the joy of debugging by buildfarm. Nothing better than having the
> > whole world watch your mistakes in painstaking detail!
>
> At least this way you get to do it while your memory is fresh. In the
> old days we only found out some things were broken weeks or months later.

That is true. I used to pull CVS using binary search to find the commit
that broke things.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +