Thread: Using Gprof with Postgresql

Using Gprof with Postgresql

From
Reydan Cankur
Date:
Hi All,

I compile PostgreSQL-8.4.0 with icc and --enable profiling option. I
ran command psql and create table and make a select then I quit psql
and go to .../data/gprof folder there are some folders named with
numbers (I think they are query ids); all of them are empty. How can I
solve this issue?

Reydan

Re: Using Gprof with Postgresql

From
Grzegorz Jaśkiewicz
Date:
postgresql was faster than the files ;)

(sorry, I just couldn't resist).

Re: Using Gprof with Postgresql

From
Jeff Janes
Date:
On Mon, Sep 7, 2009 at 8:11 AM, Reydan Cankur <reydan.cankur@gmail.com> wrote:
Hi All,

I compile PostgreSQL-8.4.0 with icc and --enable profiling option. I ran command psql and create table and make a select then I quit psql and go to .../data/gprof folder there are some folders named with numbers (I think they are query ids);


They are the process ids (PIDs) of the backend processes.

 
all of them are empty. How can I solve this issue?


Does your compiler work for profiling in general?  Can you compile other simpler programs for profiling with icc and have it work for them?  If so, how?

I thought gprof was specific to GNU compilers.
 
Jeff

Re: Using Gprof with Postgresql

From
Tom Lane
Date:
Reydan Cankur <reydan.cankur@gmail.com> writes:
> I compile PostgreSQL-8.4.0 with icc and --enable profiling option. I
> ran command psql and create table and make a select then I quit psql
> and go to .../data/gprof folder there are some folders named with
> numbers (I think they are query ids); all of them are empty. How can I
> solve this issue?

Well, you could use gcc ... icc claims to support the -pg switch but
the above sounds like it just ignores it.

            regards, tom lane

Re: Using Gprof with Postgresql

From
Reydan Cankur
Date:
I just compiled it with gcc and produces the gmon.out file for every
process; by the way I am running below script in order to produce
readable .out files

  gprof .../pgsql/bin/postgres gmon.out > createtable2.out

is postgres the right executable?

regards
reydan

On Sep 7, 2009, at 8:24 PM, Tom Lane wrote:
>
> Well, you could use gcc ... icc claims to support the -pg switch but
> the above sounds like it just ignores it.
>
>             regards, tom lane


Re: Using Gprof with Postgresql

From
Reydan Cankur
Date:

>
> I just compiled it with gcc and produces the gmon.out file for every
> process; by the way I am running below script in order to produce
> readable .out files
>
> gprof .../pgsql/bin/postgres gmon.out > createtable2.out
>
> is postgres the right executable?
>
> regards
> reydan
>
> On Sep 7, 2009, at 8:24 PM, Tom Lane wrote:
>>
>> Well, you could use gcc ... icc claims to support the -pg switch but
>> the above sounds like it just ignores it.
>>
>>             regards, tom lane
>


Re: Using Gprof with Postgresql

From
Pierre Frédéric Caillaud
Date:
> I just compiled it with gcc and produces the gmon.out file for every
> process; by the way I am running below script in order to produce
> readable .out files
>
>   gprof .../pgsql/bin/postgres gmon.out > createtable2.out
>
> is postgres the right executable?
>
> regards
> reydan

    Off topic, but hace you tried oprofile ? It's excellent...

Re: Using Gprof with Postgresql

From
Craig James
Date:
Pierre Frédéric Caillaud wrote:
>> I just compiled it with gcc and produces the gmon.out file for every
>> process; by the way I am running below script in order to produce
>> readable .out files
>>
>>   gprof .../pgsql/bin/postgres gmon.out > createtable2.out
>>
>> is postgres the right executable?
>>
>> regards
>> reydan
>
>     Off topic, but hace you tried oprofile ? It's excellent...

I find valgrind to be an excellent profiling tool.  It has the advantage that it runs on an unmodified executable
(usinga virtual machine).  You can compile postgres the regular way, start the system up, and then create a short shell
scriptcalled "postgres" that you put in place of the original executable that invokes valgrind on the original
executable. Then when postgres starts up your backend, you have just one valgrind process running, rather than the
wholePostgres system. 

Valgrind does 100% tracing of the program rather than statistical sampling, and since it runs in a pure virtual
machine,it can detect almost all memory corruption and leaks. 

The big disadvantage of valgrind is that it slows the process WAY down, like by a factor of 5-10 on CPU.  For a pure
CPUprocess, it doesn't screw up your stats, but if a process is mixed CPU and I/O, the CPU will appear to dominate. 

Craig