[Ilugc] Profiling a C program.

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Thu Mar 13 20:40:11 2008

On 17:59:09 Mar 13, Logu wrote:

We have a product which hit some performance issues in some scenarios and I 
would like to trobleshoot the performance. Since I didnt get the correct 
gprof output, I wrote a simple program to see if profiling works. I dont 
think time(1) will help here.


Long long ago I used the time(1) command to figure out that an
encryption algorithm was spending far more time than before. Later it
turned out that the optimization flags were not enabled in the C
compiler.

Sorry it doesn't help you.

Can you explain what you mean by "performance issues in some scenarios"?

Is it a networking program? 

Have you measured network latency?

Performance enhancement can be performed without resorting to profiling. 

If your idea is to identify bottlenecks, then a simple strace can help
as well.

It will print out the system calls whereby you can know which system
call is invoked often.

But I understand it cannot catch all cases.

Usually protocols are not optimal/efficient and a simple rewrite can
help.

The bottlenecks typically are in inefficient file I/O, network I/O, too
many context switches(system calls) or if it is a threaded program, a lot of 
time
could be lost in waiting for locks.

Unless you give more details about the product we cannot proceed
further.

I have not used fstat and I dont think lsof will help for my requirement. 
And I am now more focused why gprof is not giving the time spent data.


I dunno.

My simple program has a function which spends atleast 2 seconds. Initially 
I have used sleep and replaced them with "for" loops containg simple 
calculations to ensure that they atleast spend two seconds.

Some of the internet documents mentioned about linking with libc_p instead 
of libc, but I could not find such library.


I don't think standard libraries will have bottlenecks. 

Perhaps you can throw some light on what your product does.

If your company does not permit disclosure, then some general idea would
do.

Thanks.

-Girish
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : 
http://www.ae.iitm.ac.in/pipermail/ilugc/attachments/20080313/9969ed87/attachment.bin

Other related posts: