soudai / isucon9qr

the revenge
0 stars 0 forks source link

pprof #10

Open uzulla opened 3 years ago

uzulla commented 3 years ago

$ go get -u github.com/google/pprof $ sudo apt install graphviz

    //  pprof
    _ "net/http/pprof"
// mainの中に以下をいれる
    go func() {
        log.Println(http.ListenAndServe("localhost:6060", nil))
    }()

「ベンチをまわしながら」 以下を起動する。(動いているものに、後からアタッチするということである)

$ pprof -http=localhost:8888 ~/isucari/webapp/go/isucari/ http://localhost:6060/debug/pprof/profile
Fetching profile over HTTP from http://localhost:6060/debug/pprof/profile
/home/isucon/isucari/webapp/go/isucari/: open /home/isucon/isucari/webapp/go/isucari/: not a directory
Fetched 1 source profiles out of 2
Saved profile in /home/isucon/pprof/pprof.isucari.samples.cpu.002.pb.gz
Serving web UI on http://localhost:8888
Couldn't find a suitable web browser!
Set the BROWSER environment variable to your desired browser.

localhostにしかbindしてないんで、pfする $ ssh isucon@i1.cfe.jp -L 8888:127.0.0.1:8888

uzulla commented 3 years ago

image