profiling on win32

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

profiling on win32

Merlin Moncure
has andbody managed to get profiling working on windows?  I'm hacking
the makefile.global with -pg in CFLAGS the postgres library compiles ok
but the next one fails:

what I am I doing wrong?  libgmon.a is provided with mingw.

Merlin



gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wold-style-definition -Wendif-labels
-fno-strict-aliasing -pg  -I../../../../../../src/include
-I./src/include/port/win32 -DEXEC_BACKEND
"-I../../../../../../src/include/port/win32"  -c -o ascii_and_mic.o
ascii_and_mic.c
dlltool --export-all  --output-def ascii_and_mic.def ascii_and_mic.o
dllwrap  -o libascii_and_mic.dll --dllname libascii_and_mic.dll  --def
ascii_and_mic.def ascii_and_mic.o -L../../../../../../src/backend
-L../../../../../../src/port -lpostgres
ascii_and_mic.o(.text+0x9):ascii_and_mic.c: undefined reference to
`mcount'
ascii_and_mic.o(.text+0x29):ascii_and_mic.c: undefined reference to
`mcount'
ascii_and_mic.o(.text+0x4c):ascii_and_mic.c: undefined reference to
`mcount'
ascii_and_mic.o(.text+0x7c):ascii_and_mic.c: undefined reference to
`mcount'
collect2: ld returned 1 exit status
c:\mingw\bin\dllwrap.exe: c:\mingw\bin\gcc exited with status 1
make[2]: *** [libascii_and_mic.dll] Error 1
make[2]: Leaving directory
`/postgres/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic'
make[1]: *** [all] Error 2
make[1]: Leaving directory
`/postgres/pgsql/src/backend/utils/mb/conversion_procs'
make: *** [all] Error 2


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [hidden email] so that your
       message can get through to the mailing list cleanly
Reply | Threaded
Open this post in threaded view
|

Re: profiling on win32

Tom Lane-2
"Merlin Moncure" <[hidden email]> writes:
> has andbody managed to get profiling working on windows?  I'm hacking
> the makefile.global with -pg in CFLAGS the postgres library compiles ok
> but the next one fails:

> what I am I doing wrong?  libgmon.a is provided with mingw.

It could be that libgmon.a can't be linked into a shared library.

(I deal with this all the time on HPUX; it's basically impossible to get
any profiling data about shared library add-ons.  However, you can
install your profilable postgres executable into a matching installation
tree built without profiling, and go from there.  The data about the
core system will all be fine --- its basically just the PLs and encoding
conversion that you can't measure.)

Theory B is that it's one of those symbol-visibility issues that we've
seen before.  Don't recall how to fix that on Windows though.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
Reply | Threaded
Open this post in threaded view
|

Re: profiling on win32

Merlin Moncure
In reply to this post by Merlin Moncure
Finally got profiling going on windows.  Just a little FYI for other
win32 developers/users who might be interested.  gprof is probably the
easiest way to do it.  gprof is the gnu profiler which is built into
gcc.

Some quick observations:

1. no timings, just function call counts were output until I upgraded to
mingw 4.1 current

2. make sure you use mingw provided gprof, not cygwin etc.  Make sure
gprof version matches gcc version.

3. syntax to get profile graph is
gprof postgres.exe gmon.out
this actually tripped me up for a bit due to confusing error message
from gprof.

4. to compile postgresql for profiling (assumes you already have mingw,
etc. installed).
a. do make clean, make, and make install as normal.
b. edit makefile.global and add -pg to the end of cflags line.
c. do make clean, and make, and make install of just the backend.  you
can do this by running make from backend folder.

5. profile file (gmon.out) is dumped into database folder when
postgresql is run as a service.

That's it! I'm sure the unix people are thinking, 'duh!' but it took me
a bit of effort to get profiling going so I'd thought I'd pass the
information along.

Merlin

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq
Reply | Threaded
Open this post in threaded view
|

Re: profiling on win32

Dave Page
In reply to this post by Merlin Moncure
Thanks for posting this Merlin. Bruce, perhaps this should be added to
"Compiling PostgreSQL On Native Win32 FAQ" for reference?

Regards, Dave.

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf
> Of Merlin Moncure
> Sent: 25 August 2005 21:36
> To: [hidden email]
> Subject: Re: [pgsql-hackers-win32] profiling on win32
>
> Finally got profiling going on windows.  Just a little FYI for other
> win32 developers/users who might be interested.  gprof is probably the
> easiest way to do it.  gprof is the gnu profiler which is built into
> gcc.
>
> Some quick observations:
>
> 1. no timings, just function call counts were output until I
> upgraded to
> mingw 4.1 current
>
> 2. make sure you use mingw provided gprof, not cygwin etc.  Make sure
> gprof version matches gcc version.
>
> 3. syntax to get profile graph is
> gprof postgres.exe gmon.out
> this actually tripped me up for a bit due to confusing error message
> from gprof.
>
> 4. to compile postgresql for profiling (assumes you already
> have mingw,
> etc. installed).
> a. do make clean, make, and make install as normal.
> b. edit makefile.global and add -pg to the end of cflags line.
> c. do make clean, and make, and make install of just the backend.  you
> can do this by running make from backend folder.
>
> 5. profile file (gmon.out) is dumped into database folder when
> postgresql is run as a service.
>
> That's it! I'm sure the unix people are thinking, 'duh!' but
> it took me
> a bit of effort to get profiling going so I'd thought I'd pass the
> information along.
>
> Merlin
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq
>

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org
Reply | Threaded
Open this post in threaded view
|

Re: profiling on win32

Tom Lane-2
In reply to this post by Merlin Moncure
"Merlin Moncure" <[hidden email]> writes:
> 4. to compile postgresql for profiling (assumes you already have mingw,
> etc. installed).
> a. do make clean, make, and make install as normal.
> b. edit makefile.global and add -pg to the end of cflags line.
> c. do make clean, and make, and make install of just the backend.  you
> can do this by running make from backend folder.

You shouldn't have to touch Makefile.global; there's a parameter built
into the makefiles for this.  Just do

        cd .../src/backend
        make clean
        make PROFILE="-pg" all

(Quoting syntax might be different on Windows, but as long as it's
GNU make I'd expect this to work.)

I tend to abuse the PROFILE option for any old random compile/link flags
I'd like to add to a particular build ...

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org
Reply | Threaded
Open this post in threaded view
|

Re: profiling on win32

Merlin Moncure
In reply to this post by Merlin Moncure
> "Merlin Moncure" <[hidden email]> writes:
> > 4. to compile postgresql for profiling (assumes you already have
mingw,
> > etc. installed).
> > a. do make clean, make, and make install as normal.
> > b. edit makefile.global and add -pg to the end of cflags line.
> > c. do make clean, and make, and make install of just the backend.
you

> > can do this by running make from backend folder.
>
> You shouldn't have to touch Makefile.global; there's a parameter built
> into the makefiles for this.  Just do
>
> cd .../src/backend
> make clean
> make PROFILE="-pg" all
>
> (Quoting syntax might be different on Windows, but as long as it's
> GNU make I'd expect this to work.)

That works as-is in the msys shell.  cool.
Merlin

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [hidden email] so that your
       message can get through to the mailing list cleanly