Re: build environment: a different makefile

Lists: pgsql-hackers
From: Paul van den Bogaard <Paul(dot)Vandenbogaard(at)Sun(dot)COM>
To: pgsql-hackers(at)postgresql(dot)org
Subject: build environment: a different makefile
Date: 2008-02-06 17:19:48
Message-ID: 023EB482-B0A8-4E7D-B5EA-F6254CB7C6D3@sun.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Currently trying to "enhance" the way we can make binaries that run
on Solaris. One thing I found was a scalability bottleneck in the
use of the ProcArrayLock. (this one has also been reported by a
couple of my colleagues).
One big user of this lock is GetSnapshotData. After it has taken
this lock it does its work and releases it again. While it is holding
the lock it is not doing any system calls and the lock holding
process is barely preempted.

The only way to make this code faster is making the code use less CPU
cycles to achieve its goal. One way is having the compiler do some
strong code in-lining.
The SunStudio compiler we are using fortunately has an option for
this. Unfortunately there are restrictions. One restriction I face is
its inability to deal with "ld -r"s. These are used in the build
environment to create all the SUBSYS.o object files.

I was hoping someone in the community already has a makefile that
"just" creates object files from C-sources directly that I can use to
try out the effect of in-lining to the performance of postgres.
Any other hints to achieve my goal are welcome too, of-course. Please
note that in-lining is done in both the compiler and the linker.

Thanks,
Paul

------------------------------------------------------------------------
---------------------
Paul van den Bogaard
Paul(dot)vandenBogaard(at)sun(dot)com
ISV-E -- ISV Engineering, Opensource Engineering group

Sun Microsystems, Inc phone: +31
334 515 918
Saturnus 1
extentsion: x (70)15918
3824 ME Amersfoort mobile: +31
651 913 354
The Netherlands
fax: +31 334 515 001


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Paul van den Bogaard <Paul(dot)Vandenbogaard(at)sun(dot)com>
Subject: Re: build environment: a different makefile
Date: 2008-02-06 22:08:04
Message-ID: 200802062308.04740.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Paul van den Bogaard wrote:
> The SunStudio compiler we are using fortunately has an option for  
> this. Unfortunately there are restrictions. One restriction I face is  
> its inability to deal with "ld -r"s. These are used in the build  
> environment to create all the SUBSYS.o object files.
>
> I was hoping someone in the community already has a makefile that  
> "just" creates object files from C-sources directly that I can use to  
> try out the effect of in-lining to the performance of postgres.

I don't know if anyone has a makefile for it, but the following seems to work
for me:

pgsql/src/backend$ cc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -g -L../../src/port -Wl,-rpath,'/home/peter/devel/pg83/pg-install/lib' -Wl,-E $(find -name "*.o" | grep -v SUBSYS | grep -v conversion_procs) ../../src/timezone/SUBSYS.o ../../src/port/libpgport_srv.a -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lcrypt -ldl -lm -lldap -o postgres

If you find that the optimizations you are hoping for are useful, I'm sure
we could put an option of that sort somewhere in the makefiles.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Paul van den Bogaard <Paul(dot)Vandenbogaard(at)sun(dot)com>
Subject: Re: build environment: a different makefile
Date: 2008-02-06 23:12:31
Message-ID: 19718.1202339551@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> I don't know if anyone has a makefile for it, but the following seems to work
> for me:

> pgsql/src/backend$ cc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -g -L../../src/port -Wl,-rpath,'/home/peter/devel/pg83/pg-install/lib' -Wl,-E $(find -name "*.o" | grep -v SUBSYS | grep -v conversion_procs) ../../src/timezone/SUBSYS.o ../../src/port/libpgport_srv.a -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lcrypt -ldl -lm -lldap -o postgres

> If you find that the optimizations you are hoping for are useful, I'm sure
> we could put an option of that sort somewhere in the makefiles.

I've sometimes wondered whether the SUBSYS.o files really offer any
advantage compared to just linking all the individual .o files. They
certainly eat disk space, but perhaps they save some time ... or perhaps
not, especially in a one-off build.

I suppose that we might fall foul of command line length limits on
some platforms :-(. The output of your find command amounts to nearly
11000 characters in HEAD.

regards, tom lane


From: "Dave Page" <dpage(at)postgresql(dot)org>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, "Paul van den Bogaard" <Paul(dot)Vandenbogaard(at)sun(dot)com>
Subject: Re: build environment: a different makefile
Date: 2008-02-07 08:09:24
Message-ID: 937d27e10802070009i4c2c7472l5d498b60d06bc363@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Feb 6, 2008 11:12 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> I've sometimes wondered whether the SUBSYS.o files really offer any
> advantage compared to just linking all the individual .o files. They
> certainly eat disk space, but perhaps they save some time ... or perhaps
> not, especially in a one-off build.

Getting rid of them would certainly make building OSX universal binaries easier.

> I suppose that we might fall foul of command line length limits on
> some platforms :-(. The output of your find command amounts to nearly
> 11000 characters in HEAD.

What do other large build systems do?

/D


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Dave Page <dpage(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Paul van den Bogaard <Paul(dot)Vandenbogaard(at)sun(dot)com>
Subject: Re: build environment: a different makefile
Date: 2008-02-07 09:21:52
Message-ID: 20080207092152.GC12085@svr2.hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Feb 07, 2008 at 08:09:24AM +0000, Dave Page wrote:
> On Feb 6, 2008 11:12 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> > I've sometimes wondered whether the SUBSYS.o files really offer any
> > advantage compared to just linking all the individual .o files. They
> > certainly eat disk space, but perhaps they save some time ... or perhaps
> > not, especially in a one-off build.
>
> Getting rid of them would certainly make building OSX universal binaries easier.
>
> > I suppose that we might fall foul of command line length limits on
> > some platforms :-(. The output of your find command amounts to nearly
> > 11000 characters in HEAD.
>
> What do other large build systems do?

FWIW, the MSVC build ends up writing the list of object files to a temp
file and then having the linker read that list. (This is all done behind
the scenes though, it's not something we made up) IIRC the gcc linker can
also take the commandline from a file instead of the actual commandline,
which should be workable I think.

//Magnus


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Dave Page" <dpage(at)postgresql(dot)org>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, "Paul van den Bogaard" <Paul(dot)Vandenbogaard(at)sun(dot)com>
Subject: Re: build environment: a different makefile
Date: 2008-02-07 09:48:11
Message-ID: 200802071048.13541.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Am Donnerstag, 7. Februar 2008 schrieb Dave Page:
> What do other large build systems do?

I strongly suspect that they just fail unless run with GNU tools or some other
well-defined tool set.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Paul van den Bogaard <Paul(dot)Vandenbogaard(at)Sun(dot)COM>
Subject: Re: build environment: a different makefile
Date: 2008-02-07 10:08:15
Message-ID: 47AAD88F.7000400@sun.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut napsal(a):
> Paul van den Bogaard wrote:
>> The SunStudio compiler we are using fortunately has an option for
>> this. Unfortunately there are restrictions. One restriction I face is
>> its inability to deal with "ld -r"s. These are used in the build
>> environment to create all the SUBSYS.o object files.
>>
>> I was hoping someone in the community already has a makefile that
>> "just" creates object files from C-sources directly that I can use to
>> try out the effect of in-lining to the performance of postgres.
>
> I don't know if anyone has a makefile for it, but the following seems to work
> for me:
>
> pgsql/src/backend$ cc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -g -L../../src/port -Wl,-rpath,'/home/peter/devel/pg83/pg-install/lib' -Wl,-E $(find -name "*.o" | grep -v SUBSYS | grep -v conversion_procs) ../../src/timezone/SUBSYS.o ../../src/port/libpgport_srv.a -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lcrypt -ldl -lm -lldap -o postgres
>
> If you find that the optimizations you are hoping for are useful, I'm sure
> we could put an option of that sort somewhere in the makefiles.

Peter,
Suns studio performs inline optimization on -xO3 level. Optimization levels are
different from GCC. Maximal level is -xO5. I think Paul plays with xipo flag
which requires at least -xO4.

See
http://docs.sun.com/app/docs/doc/819-5265/bjapp?a=view

Zdenek


From: Paul van den Bogaard <Paul(dot)Vandenbogaard(at)Sun(dot)COM>
To: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: build environment: a different makefile
Date: 2008-02-07 10:43:32
Message-ID: 0146567C-B3EB-4BA6-AEB8-ADB391A752DC@Sun.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Zdenek is right.

Normal inlining using -O3 or higher means inlining within the source
file. I currently try to see the effect of inlining over all the
sources. The -xipo flag is specific to the Sun Studio (version 12)
suite. It creates large objects that now include meta data for the
final linking stage. During this linking stage all this stuff is
read, analyzed an the object files are changed. Later this can be
expanded by compiler profiling and/or other trickery. BTW the actual
binary does *not* include all that metadata and is just bigger due to
all that code being inlined in those objects.

This trick has been done for other applications and we find in
general significant approvement. Not a guarantee though ...

However my "suite" has a dependecy on dtrace so the initial idea I
saw from Peter is not complete. Currently creating a quick and dirty
build script. Just to get that "ipo"-ing done and tested.

I'll keep you all updated on the results. If we decide it is too good
to be excluded can we start thinking about an adaption of the build
environement. Hope this sound fair and acceptable to all.

Thanks so far for all that feedback

Cheers
Paul

BTW I build and test on a 16 SPARC @1350MHz V890. 64 bit mode,
currently 16GB of shared memory, and 7 disk arrays (RAID0). This to
exclude the IO part of the equation as much as possible, so we can
focus on CPU related matter: the need for faster (smarter) code
pathes and/or scalability issues like ProcArrayLock contention.

On 7-feb-2008, at 11:08, Zdenek Kotala wrote:

> Peter Eisentraut napsal(a):
>> Paul van den Bogaard wrote:
>>> The SunStudio compiler we are using fortunately has an option
>>> for this. Unfortunately there are restrictions. One restriction
>>> I face is its inability to deal with "ld -r"s. These are used in
>>> the build environment to create all the SUBSYS.o object files.
>>>
>>> I was hoping someone in the community already has a makefile
>>> that "just" creates object files from C-sources directly that I
>>> can use to try out the effect of in-lining to the performance of
>>> postgres.
>> I don't know if anyone has a makefile for it, but the following
>> seems to work
>> for me:
>> pgsql/src/backend$ cc -O2 -Wall -Wmissing-prototypes -Wpointer-
>> arith -Winline -Wdeclaration-after-statement -Wendif-labels -fno-
>> strict-aliasing -g -L../../src/port -Wl,-rpath,'/home/peter/devel/
>> pg83/pg-install/lib' -Wl,-E $(find -name "*.o" | grep -v SUBSYS |
>> grep -v conversion_procs) ../../src/timezone/SUBSYS.o ../../src/
>> port/libpgport_srv.a -lxslt -lxml2 -lpam -lssl -lcrypto -
>> lgssapi_krb5 -lcrypt -ldl -lm -lldap -o postgres
>> If you find that the optimizations you are hoping for are useful,
>> I'm sure
>> we could put an option of that sort somewhere in the makefiles.
>
> Peter,
> Suns studio performs inline optimization on -xO3 level.
> Optimization levels are different from GCC. Maximal level is -xO5.
> I think Paul plays with xipo flag which requires at least -xO4.
>
> See
> http://docs.sun.com/app/docs/doc/819-5265/bjapp?a=view
>
> Zdenek
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster

------------------------------------------------------------------------
---------------------
Paul van den Bogaard
Paul(dot)vandenBogaard(at)sun(dot)com
ISV-E -- ISV Engineering, Opensource Engineering group

Sun Microsystems, Inc phone: +31
334 515 918
Saturnus 1
extentsion: x (70)15918
3824 ME Amersfoort mobile: +31
651 913 354
The Netherlands
fax: +31 334 515 001


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Dave Page <dpage(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Paul van den Bogaard <Paul(dot)Vandenbogaard(at)sun(dot)com>
Subject: Re: build environment: a different makefile
Date: 2008-02-07 15:16:53
Message-ID: 3536.1202397413@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Thu, Feb 07, 2008 at 08:09:24AM +0000, Dave Page wrote:
>> What do other large build systems do?

> FWIW, the MSVC build ends up writing the list of object files to a temp
> file and then having the linker read that list. (This is all done behind
> the scenes though, it's not something we made up) IIRC the gcc linker can
> also take the commandline from a file instead of the actual commandline,
> which should be workable I think.

Hmm. I'm not sure that's universal, but if it is then a simple
incremental improvement on what we're doing now would be to replace the
SUBSYS.o files with "subsys include files" that just list all the .o
files to be included.

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Paul van den Bogaard <Paul(dot)Vandenbogaard(at)sun(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: build environment: a different makefile
Date: 2008-02-25 18:09:51
Message-ID: 200802251909.53554.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Am Mittwoch, 6. Februar 2008 schrieb Paul van den Bogaard:
> I was hoping someone in the community already has a makefile that
> "just" creates object files from C-sources directly that I can use to
> try out the effect of in-lining to the performance of postgres.

This is now the default in 8.4devel. Let us know what you find out.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Paul van den Bogaard <Paul(dot)Vandenbogaard(at)Sun(dot)COM>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: build environment: a different makefile
Date: 2008-03-28 07:33:44
Message-ID: 82E3AF32-D275-4340-B04E-0B77A6FAB2EC@Sun.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter,

finally I had a chance to check it out. One word: perfect!

Thanks
Paul

On 25-feb-2008, at 19:09, Peter Eisentraut wrote:

> Am Mittwoch, 6. Februar 2008 schrieb Paul van den Bogaard:
>> I was hoping someone in the community already has a makefile that
>> "just" creates object files from C-sources directly that I can use to
>> try out the effect of in-lining to the performance of postgres.
>
> This is now the default in 8.4devel. Let us know what you find out.
>
> --
> Peter Eisentraut
> http://developer.postgresql.org/~petere/
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

------------------------------------------------------------------------
---------------------
Paul van den Bogaard
Paul(dot)vandenBogaard(at)sun(dot)com
ISV-E -- ISV Engineering, Opensource Engineering group

Sun Microsystems, Inc phone: +31
334 515 918
Saturnus 1
extentsion: x (70)15918
3824 ME Amersfoort mobile: +31
651 913 354
The Netherlands
fax: +31 334 515 001