Re: Profiling code execution on amd64?

2011-01-17 Thread Fabien Thomas
Last time i've used it it was working but I dont think it is really useful now 
(from my POV) because
you cant have a global view of the system with it and all other reports overlap.

With the current state you have:
- top mode for fast lookup
- text output (replace gprof for me)
- kcachegrind (calltree) for in depth analysis
- gprof 

Fabien

 On Fri, Jan 14, 2011 at 10:10 PM, Steve Kargl
 s...@troutmask.apl.washington.edu wrote:
 On Fri, Jan 14, 2011 at 03:40:46PM -0500, George Neville-Neil wrote:
 
 On Jan 13, 2011, at 23:05 , Steve Kargl wrote:
 
 On Thu, Jan 13, 2011 at 10:08:30PM -0500, Ryan Stone wrote:
 I would suggest using hwpmc for profiling:
 
 # kldload hwpmc
 # pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
 # pmcstat -R /tmp/samples.out -G /tmp/penetration.txt
 
 
 You can also get pmcstat to generate gprof-compatible output with -g,
 but I never use the mode so I'm really not sure what it gives you.  I
 think that you have to run gprof on the output or something, but don't
 hold me to that.
 
 
 Thanks.  I'll give it a try, but my initial attempt seems to
 indicate that one needs to be root to use hwpmc.
 
 laptop:kargl[210] pmcstat -S unhalted-cycles -O /tmp/samples.out 
 ../penetration
 pmcstat: ERROR: Cannot allocate system-mode pmc with specification
 unhalted-cycles: Operation not permitted
 
 
 You only need to be root to profile the kernel or someone else's process.
 
 This tutorial might help:
 
 www.dcbsdcon.org/speakers/slides/neville-neil_dcbsdcon2009.pdf
 
 
 Thanks.  I'll look at the tutorial.  Meanwhile, should gprof
 be removed from the base system because it appears broken?
 
 Instead of just removing things, why not determine why things are
 broken and try to fix them?
 -Garrett
 ___
 freebsd-current@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-current
 To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: Profiling code execution on amd64?

2011-01-17 Thread Steve Kargl
On Mon, Jan 17, 2011 at 09:45:44AM +0100, Fabien Thomas wrote:
 Last time i've used it it was working but I dont think it is
 really useful now (from my POV) because you cant have a global
 view of the system with it and all other reports overlap.

To what does 'it' refer? 

 
 With the current state you have:
 - top mode for fast lookup
 - text output (replace gprof for me)
 - kcachegrind (calltree) for in depth analysis
 - gprof 

Please, don't top post, and check to see if
the 'enter' key on your computer is functioning
properly.

-- 
Steve
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: Profiling code execution on amd64?

2011-01-15 Thread Hans Ottevanger

On 01/15/11 07:15, Garrett Cooper wrote:

On Fri, Jan 14, 2011 at 10:10 PM, Steve Kargl
s...@troutmask.apl.washington.edu  wrote:

On Fri, Jan 14, 2011 at 03:40:46PM -0500, George Neville-Neil wrote:


On Jan 13, 2011, at 23:05 , Steve Kargl wrote:


On Thu, Jan 13, 2011 at 10:08:30PM -0500, Ryan Stone wrote:

I would suggest using hwpmc for profiling:

# kldload hwpmc
# pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
# pmcstat -R /tmp/samples.out -G /tmp/penetration.txt


You can also get pmcstat to generate gprof-compatible output with -g,
but I never use the mode so I'm really not sure what it gives you.  I
think that you have to run gprof on the output or something, but don't
hold me to that.



Thanks.  I'll give it a try, but my initial attempt seems to
indicate that one needs to be root to use hwpmc.

laptop:kargl[210] pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
pmcstat: ERROR: Cannot allocate system-mode pmc with specification
unhalted-cycles: Operation not permitted



You only need to be root to profile the kernel or someone else's process.

This tutorial might help:

www.dcbsdcon.org/speakers/slides/neville-neil_dcbsdcon2009.pdf



Thanks.  I'll look at the tutorial.  Meanwhile, should gprof
be removed from the base system because it appears broken?


Instead of just removing things, why not determine why things are
broken and try to fix them?
-Garrett



gprof is not as badly broken as it seems 8-)

I have encountered the issue described by the original poster regularly 
over the last few years, using different versions of FreeBSD. The total 
time reported by gprof is often way shorter than the time reported by 
time. I have checked that the problem goes back to at least 7.3-RELEASE, 
and it occurs on both amd64 and i386.


I found that this problem is caused by neither the profile start-up code 
nor gprof knowing about dynamic linking. The start-up code calls 
profil() with etext as the upper limit of the address range to be 
profiled. This implies that all dynamically linked code will not be 
profiled, which explains the lost ticks in gprof.


A solution might be to teach both the profiling start-up code and gprof 
about dynamic linking, but I guess that is not that trivial ...


A good work-around is linking statically (-static). Also be aware that 
with dynamic linking and specifying -pg, a profiled (and static!) 
version is used only for the C library. So if e.g. the math library is 
needed -lm_p has to be specified explicitly instead of just -lm, or 
ticks will be lost. So specifying standard libraries with _p appended 
might already solve most of the problems.


I also remember (and just verified) that in the good old days (FreeBSD 
2.2.8) static linking took place automatically when profiling was 
requested, so the issues at hand might not even be new 8-)


Kind regards,

Hans Ottevanger

PS. Thanks for the link to your tutorial, George. I am very interested 
in hwpmc, and since documentation seems to be somewhat sparse, this 
really helps.

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: Profiling code execution on amd64?

2011-01-14 Thread George Neville-Neil

On Jan 13, 2011, at 23:05 , Steve Kargl wrote:

 On Thu, Jan 13, 2011 at 10:08:30PM -0500, Ryan Stone wrote:
 I would suggest using hwpmc for profiling:
 
 # kldload hwpmc
 # pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
 # pmcstat -R /tmp/samples.out -G /tmp/penetration.txt
 
 
 You can also get pmcstat to generate gprof-compatible output with -g,
 but I never use the mode so I'm really not sure what it gives you.  I
 think that you have to run gprof on the output or something, but don't
 hold me to that.
 
 
 Thanks.  I'll give it a try, but my initial attempt seems to
 indicate that one needs to be root to use hwpmc.  
 
 laptop:kargl[210] pmcstat -S unhalted-cycles -O /tmp/samples.out 
 ../penetration
 pmcstat: ERROR: Cannot allocate system-mode pmc with specification
 unhalted-cycles: Operation not permitted
 

You only need to be root to profile the kernel or someone else's process.

This tutorial might help:

www.dcbsdcon.org/speakers/slides/neville-neil_dcbsdcon2009.pdf

Best,
George

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: Profiling code execution on amd64?

2011-01-14 Thread Steve Kargl
On Fri, Jan 14, 2011 at 03:40:46PM -0500, George Neville-Neil wrote:
 
 On Jan 13, 2011, at 23:05 , Steve Kargl wrote:
 
  On Thu, Jan 13, 2011 at 10:08:30PM -0500, Ryan Stone wrote:
  I would suggest using hwpmc for profiling:
  
  # kldload hwpmc
  # pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
  # pmcstat -R /tmp/samples.out -G /tmp/penetration.txt
  
  
  You can also get pmcstat to generate gprof-compatible output with -g,
  but I never use the mode so I'm really not sure what it gives you.  I
  think that you have to run gprof on the output or something, but don't
  hold me to that.
  
  
  Thanks.  I'll give it a try, but my initial attempt seems to
  indicate that one needs to be root to use hwpmc.  
  
  laptop:kargl[210] pmcstat -S unhalted-cycles -O /tmp/samples.out 
  ../penetration
  pmcstat: ERROR: Cannot allocate system-mode pmc with specification
  unhalted-cycles: Operation not permitted
  
 
 You only need to be root to profile the kernel or someone else's process.
 
 This tutorial might help:
 
 www.dcbsdcon.org/speakers/slides/neville-neil_dcbsdcon2009.pdf
 

Thanks.  I'll look at the tutorial.  Meanwhile, should gprof
be removed from the base system because it appears broken?

-- 
Steve
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: Profiling code execution on amd64?

2011-01-14 Thread Garrett Cooper
On Fri, Jan 14, 2011 at 10:10 PM, Steve Kargl
s...@troutmask.apl.washington.edu wrote:
 On Fri, Jan 14, 2011 at 03:40:46PM -0500, George Neville-Neil wrote:

 On Jan 13, 2011, at 23:05 , Steve Kargl wrote:

  On Thu, Jan 13, 2011 at 10:08:30PM -0500, Ryan Stone wrote:
  I would suggest using hwpmc for profiling:
 
  # kldload hwpmc
  # pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
  # pmcstat -R /tmp/samples.out -G /tmp/penetration.txt
 
 
  You can also get pmcstat to generate gprof-compatible output with -g,
  but I never use the mode so I'm really not sure what it gives you.  I
  think that you have to run gprof on the output or something, but don't
  hold me to that.
 
 
  Thanks.  I'll give it a try, but my initial attempt seems to
  indicate that one needs to be root to use hwpmc.
 
  laptop:kargl[210] pmcstat -S unhalted-cycles -O /tmp/samples.out 
  ../penetration
  pmcstat: ERROR: Cannot allocate system-mode pmc with specification
  unhalted-cycles: Operation not permitted
 

 You only need to be root to profile the kernel or someone else's process.

 This tutorial might help:

 www.dcbsdcon.org/speakers/slides/neville-neil_dcbsdcon2009.pdf


 Thanks.  I'll look at the tutorial.  Meanwhile, should gprof
 be removed from the base system because it appears broken?

Instead of just removing things, why not determine why things are
broken and try to fix them?
-Garrett
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Profiling code execution on amd64?

2011-01-13 Thread Steve Kargl
How does one profile one's code on freebsd-amd64?
It seems that gprof is broken.

troutmask:kargl[234] time ../penetration
CPU time: 7.327 min
Start time: 2011-01-13 08:59:18.419
 Stop time: 2011-01-13 09:06:39.082
  CPU time: 7.34 min
  440.68 real   440.25 user 0.11 sys

troutmask:kargl[235] gprof -b -l ../penetration penetration.gmon | more

granularity: each sample hit covers 4 byte(s) for 0.00% of 25.46 seconds

  %   cumulative   self  self total   
 time   seconds   secondscalls  ms/call  ms/call  name
 96.2  24.4824.48   282440 0.09 0.09  __mempoolm_MOD_memadd [4]
  1.4  24.84 0.350  100.00%   _mcount [5]
  0.7  25.03 0.191   188.65   188.82  __srfm_MOD_rms [6]
  0.5  25.14 0.12   608847 0.00 0.00  memcpy [11]

I cannot reconcile how 440.25 seconds is the same a 25.46.

Should src/usr.bin/gprof be disconnected from the build?

-- 
Steve
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: Profiling code execution on amd64?

2011-01-13 Thread Ryan Stone
I would suggest using hwpmc for profiling:

# kldload hwpmc
# pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
# pmcstat -R /tmp/samples.out -G /tmp/penetration.txt


You can also get pmcstat to generate gprof-compatible output with -g,
but I never use the mode so I'm really not sure what it gives you.  I
think that you have to run gprof on the output or something, but don't
hold me to that.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: Profiling code execution on amd64?

2011-01-13 Thread Steve Kargl
On Thu, Jan 13, 2011 at 10:08:30PM -0500, Ryan Stone wrote:
 I would suggest using hwpmc for profiling:
 
 # kldload hwpmc
 # pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
 # pmcstat -R /tmp/samples.out -G /tmp/penetration.txt
 
 
 You can also get pmcstat to generate gprof-compatible output with -g,
 but I never use the mode so I'm really not sure what it gives you.  I
 think that you have to run gprof on the output or something, but don't
 hold me to that.


Thanks.  I'll give it a try, but my initial attempt seems to
indicate that one needs to be root to use hwpmc.  

laptop:kargl[210] pmcstat -S unhalted-cycles -O /tmp/samples.out ../penetration
pmcstat: ERROR: Cannot allocate system-mode pmc with specification
unhalted-cycles: Operation not permitted

-- 
Steve
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org