30 Apr 2012 19:37
Re: pprof profiling data are empty
Close the file? I was able to get samples with the following:
package main
import (
"flag"
"log"
"os"
"os/signal"
"runtime/pprof"
"runtime"
)
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
func main() {
flag.Parse()
if *cpuprofile != "" {
prof, err := os.Create(*cpuprofile)
if err != nil {
panic(err.Error())
}
defer prof.Close()
pprof.StartCPUProfile(prof)
defer pprof.StopCPUProfile()
}
go func() {
x := make(chan bool, 1)
for {
x <- true
<-x
log.Printf("boo")
runtime.Gosched()
}
}()
// Waiting for terminating (i use a sighandler like in vitess)
terminate := make(chan os.Signal)
signal.Notify(terminate, os.Interrupt)
<-terminate
log.Printf("Server stopped")
}
On Mon, Apr 30, 2012 at 10:14 AM, Thomas Adam <thomas.adam-yqcaP4giWpuzQB+pC5nmwQ@public.gmane.org> wrote:
Here is a code snippet of my main function: http://pastebin.com/UNabLHciThe app is a socket server. The server runs so long I want (in my test more then 10 minutes) and I use only cpu profiling.Without some code, it's difficult to help. My guesses are that your program is exiting too fast, that you're not actually setting the profile rate, or that you're mixing memory/cpu profiling calls and confusing it.On Mon, Apr 30, 2012 at 9:11 AM, Thomas Adam <thomas.adam-yqcaP4giWpuzQB+pC5nmwQ@public.gmane.org> wrote:No. I use debian 2.6.32-5-amd64 and the last go version 1.0.1
Am Montag, 30. April 2012 17:49:38 UTC+2 schrieb minux:On Mon, Apr 30, 2012 at 4:10 PM, Thomas Adam <thomas.adam-yqcaP4giWpuzQB+pC5nmwQ@public.gmane.org> wrote:I have read the blog post http://blog.golang.org/2011/06/profiling-go-programs.html?m=1 and implemented it in my app.
But in the created profile file there are only some empty bytes and the pprof tool shows me that the file has 0 samples.Memory profiling and the pprof http handler doesn't work too.The call to "pprof.StopCPUProfile()" is executed befor the application stops. So why I get no profiling data?I hope somebody can help me.Are you using Mac OS X 10.6.x 64-bit kernel? pprof is known to misbehave on it.
RSS Feed