美文网首页
golang pprof

golang pprof

作者: 王侦 | 来源:发表于2023-07-28 08:15 被阅读0次

    0.flat/cum含义

    针对CPU:
    Total:总共采样次数,这里是2525次。
    Flat:函数在样本中处于运行状态的次数。简单来说就是函数出现在栈顶的次数,而函数在栈顶则意味着它在使用CPU。
    Flat%:Flat / Total。
    Sum%:自己以及所有前面的Flat%的累积值。解读方式:表中第3行Sum% 32.4%,意思是前3个函数(运行状态)的计数占了总样本数的32.4%
    Cum:函数在样本中出现的次数。只要这个函数出现在栈中那么就算进去,这个和Flat不同(必须是栈顶才能算进去)。也可以解读为这个函数的调用次数。
    Cum%:Cum / Total

    针对内存:
    Total:总共占用内存
    Flat:函数分配的内存,不包含它调用其他函数造成的内存分配。
    Flat%:Flat / Total
    Sum%:自己和前面所有的Flat%累积值
    Cum:这个函数分配的内存,以及它调用其他函数分配的内存之和。可以解读为因为这个函数所造成的所有内存分配。
    Cum%:Cum / Total

    1.排查CPU问题

    go tool pprof http://localhost:6060/debug/pprof/profile

    [root@br-apm-001 bonree]# go tool pprof http://localhost:6060/debug/pprof/profile
    Fetching profile over HTTP from http://localhost:6060/debug/pprof/profile
    
    Saved profile in /root/pprof/pprof.pprof-amd64-linux.samples.cpu.001.pb.gz
    File: pprof-amd64-linux
    Type: cpu
    Time: Jul 27, 2023 at 8:22pm (CST)
    Duration: 30.11s, Total samples = 22.09s (73.36%)
    Entering interactive mode (type "help" for commands, "o" for options)
    (pprof) top
    Showing nodes accounting for 22.08s, 100% of 22.09s total
    Dropped 10 nodes (cum <= 0.11s)
    Showing top 10 nodes out of 13
          flat  flat%   sum%        cum   cum%
        13.37s 60.53% 60.53%     13.56s 61.39%  github.com/wolfogre/go-pprof-practice/animal/felidae/tiger.(*Tiger).Eat
         5.64s 25.53% 86.06%      5.64s 25.53%  runtime.memmove
         2.70s 12.22% 98.28%      2.70s 12.22%  runtime.memclrNoHeapPointers
         0.19s  0.86% 99.14%      0.19s  0.86%  runtime.asyncPreempt
         0.16s  0.72% 99.86%      0.16s  0.72%  runtime.writeHeapBits.flush
         0.02s 0.091%   100%      8.51s 38.52%  github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Pee.func1
             0     0%   100%     13.56s 61.39%  github.com/wolfogre/go-pprof-practice/animal/felidae/tiger.(*Tiger).Live
             0     0%   100%     13.58s 61.48%  main.main
             0     0%   100%      0.17s  0.77%  runtime.(*mcache).allocLarge
             0     0%   100%      0.16s  0.72%  runtime.(*mspan).initHeapBits
    (pprof) list Eat
    Total: 22.09s
    ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/felidae/tiger.(*Tiger).Eat in E:/source/go/workspace/go-pprof-practice-master/animal/felidae/tiger/tiger.go
        13.37s     13.56s (flat, cum) 61.39% of Total
     Error: could not find file E:/source/go/workspace/go-pprof-practice-master/animal/felidae/tiger/tiger.go on path /home/bonree
    (pprof) 
    
    

    具体看看tiger.go的Eat方法,注释掉:

    func (t *Tiger) Eat() {
        log.Println(t.Name(), "eat")
        loop := 10000000000
        for i := 0; i < loop; i++ {
            // do nothing
        }
    }
    

    2.排查内存

    go tool pprof http://localhost:6060/debug/pprof/heap

    (pprof) top
    Showing nodes accounting for 4.55s, 99.56% of 4.57s total
    Dropped 2 nodes (cum <= 0.02s)
    Showing top 10 nodes out of 26
          flat  flat%   sum%        cum   cum%
         2.98s 65.21% 65.21%      2.98s 65.21%  runtime.memmove
         1.28s 28.01% 93.22%      1.28s 28.01%  runtime.memclrNoHeapPointers
         0.13s  2.84% 96.06%      4.36s 95.40%  github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Steal
         0.08s  1.75% 97.81%      0.08s  1.75%  runtime.writeHeapBits.flush
         0.06s  1.31% 99.12%      0.06s  1.31%  runtime.madvise
         0.01s  0.22% 99.34%      0.06s  1.31%  github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Pee.func1
         0.01s  0.22% 99.56%      0.08s  1.75%  runtime.(*scavengerState).run
             0     0% 99.56%      0.07s  1.53%  github.com/wolfogre/go-pprof-practice/animal/canidae/dog.(*Dog).Live
             0     0% 99.56%      0.07s  1.53%  github.com/wolfogre/go-pprof-practice/animal/canidae/dog.(*Dog).Run (inline)
             0     0% 99.56%      4.36s 95.40%  github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Live
    (pprof) list Steal 
    Total: 4.57s
    ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Steal in E:/source/go/workspace/go-pprof-practice-master/animal/muridae/mouse/mouse.go
         130ms      4.36s (flat, cum) 95.40% of Total
     Error: could not find file E:/source/go/workspace/go-pprof-practice-master/animal/muridae/mouse/mouse.go on path /home/bonree
    (pprof) 
    
    
    func (m *Mouse) Steal() {
        log.Println(m.Name(), "steal")
        max := constant.Gi
        for len(m.buffer)*constant.Mi < max {
            m.buffer = append(m.buffer, [constant.Mi]byte{})
        }
    }
    

    3.排查排查频繁内存回收

    GODEBUG=gctrace=1 ./pprof-amd64-linux | grep gc
    go tool pprof http://localhost:6060/debug/pprof/allocs

    [root@br-apm-001 bonree]# GODEBUG=gctrace=1 ./pprof-amd64-linux | grep gc
    gc 1 @0.007s 2%: 0.017+1.0+0.006 ms clock, 0.017+0.36/0.24/0+0.006 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 2 @3.042s 0%: 0.062+1.1+0.005 ms clock, 0.062+0.32/0.26/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 3 @6.076s 0%: 0.088+1.0+0.005 ms clock, 0.088+0.39/0.28/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 4 @9.126s 0%: 0.12+1.1+0.005 ms clock, 0.12+0.20/0.39/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 5 @12.158s 0%: 0.10+1.0+0.006 ms clock, 0.10+0.32/0.30/0+0.006 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 6 @15.202s 0%: 0.076+0.91+0.005 ms clock, 0.076+0.18/0.33/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 7 @18.223s 0%: 0.065+0.96+0.005 ms clock, 0.065+0.29/0.30/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 8 @21.247s 0%: 0.066+1.0+0.005 ms clock, 0.066+0.36/0.31/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 9 @24.270s 0%: 0.064+1.0+0.004 ms clock, 0.064+0.37/0.32/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 10 @27.298s 0%: 0.077+1.3+0.004 ms clock, 0.077+0.43/0.38/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 11 @30.320s 0%: 0.062+0.93+0.005 ms clock, 0.062+0.42/0.28/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 12 @33.019s 0%: 0.054+7.1+0.008 ms clock, 0.054+0/0.85/0+0.008 ms cpu, 7->7->6 MB, 7 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 13 @33.356s 0%: 0.092+1.4+0.005 ms clock, 0.092+0.82/0.43/0+0.005 ms cpu, 22->22->4 MB, 22 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 14 @34.028s 0%: 0.055+20+0.007 ms clock, 0.055+0/1.1/0+0.007 ms cpu, 12->12->12 MB, 12 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 15 @35.548s 0%: 0.057+44+0.008 ms clock, 0.057+0/1.0/0+0.008 ms cpu, 28->28->24 MB, 28 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 16 @37.599s 0%: 0.059+67+0.007 ms clock, 0.059+0/0.77/0+0.007 ms cpu, 72->72->48 MB, 72 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 17 @40.179s 0%: 0.089+175+0.007 ms clock, 0.089+0/0.70/0+0.007 ms cpu, 128->128->96 MB, 128 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 18 @44.369s 0%: 0.064+296+0.008 ms clock, 0.064+0/0.77/0+0.008 ms cpu, 240->240->192 MB, 240 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 19 @50.199s 0%: 0.060+642+0.007 ms clock, 0.060+0/0.83/0+0.007 ms cpu, 480->480->384 MB, 480 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 20 @58.815s 0%: 0.099+1373+0.007 ms clock, 0.099+0/1.2/0+0.007 ms cpu, 1456->1456->1280 MB, 1456 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 21 @72.880s 0%: 0.17+2.3+0.008 ms clock, 0.17+1.9/0/0+0.008 ms cpu, 12976->12976->12160 MB, 12976 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 22 @133.637s 0%: 0.085+5.5+0.009 ms clock, 0.085+5.0/0.44/0+0.009 ms cpu, 31921->31921->20544 MB, 31921 MB goal, 0 MB stacks, 0 MB globals, 1 P
    
    
    [root@br-apm-001 prometheus-2.40.1.linux-amd64]# go tool pprof http://localhost:6060/debug/pprof/allocs
    Fetching profile over HTTP from http://localhost:6060/debug/pprof/allocs
    Saved profile in /root/pprof/pprof.pprof-amd64-linux.alloc_objects.alloc_space.inuse_objects.inuse_space.001.pb.gz
    File: pprof-amd64-linux
    Type: alloc_space
    Time: Jul 28, 2023 at 9:05am (CST)
    Entering interactive mode (type "help" for commands, "o" for options)
    (pprof) top
    Showing nodes accounting for 1855.20MB, 99.95% of 1856.20MB total
    Dropped 5 nodes (cum <= 9.28MB)
          flat  flat%   sum%        cum   cum%
     1535.20MB 82.71% 82.71%  1535.20MB 82.71%  github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Pee.func1
         320MB 17.24% 99.95%      320MB 17.24%  github.com/wolfogre/go-pprof-practice/animal/canidae/dog.(*Dog).Run (inline)
             0     0% 99.95%   320.50MB 17.27%  github.com/wolfogre/go-pprof-practice/animal/canidae/dog.(*Dog).Live
             0     0% 99.95%      321MB 17.29%  main.main
             0     0% 99.95%      321MB 17.29%  runtime.main
    (pprof) list func1
    Total: 1.81GB
    ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Pee.func1 in E:/source/go/workspace/go-pprof-practice-master/animal/muridae/mouse/mouse.go
        1.50GB     1.50GB (flat, cum) 82.71% of Total
     Error: could not find file E:/source/go/workspace/go-pprof-practice-master/animal/muridae/mouse/mouse.go on path /data/br/base/prometheus-2.40.1.linux-amd64
    (pprof) 
    
    
    func (m *Mouse) Pee() {
        log.Println(m.Name(), "pee")
        go func() {
            time.Sleep(time.Second * 30)
            max := constant.Gi
            for len(m.slowBuffer)*constant.Mi < max {
                m.slowBuffer = append(m.slowBuffer, [constant.Mi]byte{})
                time.Sleep(time.Millisecond * 500)
            }
        }()
    }
    
    gc 130 @390.748s 0%: 0.090+1.0+0.005 ms clock, 0.090+0.44/0.30/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 131 @393.771s 0%: 0.094+1.0+0.004 ms clock, 0.094+0.38/0.28/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 132 @396.795s 0%: 0.12+0.82+0.004 ms clock, 0.12+0.33/0.26/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 133 @399.827s 0%: 0.064+0.97+0.004 ms clock, 0.064+0.33/0.29/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 134 @402.851s 0%: 0.066+0.83+0.004 ms clock, 0.066+0.38/0.24/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 135 @405.881s 0%: 0.10+1.5+0.004 ms clock, 0.10+0.36/0.44/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 136 @408.904s 0%: 0.084+1.1+0.005 ms clock, 0.084+0.42/0.31/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 137 @411.926s 0%: 0.085+1.0+0.004 ms clock, 0.085+0.36/0.33/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 138 @414.958s 0%: 0.087+1.1+0.022 ms clock, 0.087+0.56/0.28/0+0.022 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 139 @417.984s 0%: 0.14+1.1+0.005 ms clock, 0.14+0.40/0.37/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 140 @421.015s 0%: 0.10+0.88+0.004 ms clock, 0.10+0.41/0.26/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 141 @424.036s 0%: 0.066+1.0+0.004 ms clock, 0.066+0.40/0.28/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 142 @427.059s 0%: 0.094+1.0+0.004 ms clock, 0.094+0.50/0.34/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 143 @430.078s 0%: 0.12+1.4+0.005 ms clock, 0.12+0.38/0.39/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 144 @433.099s 0%: 0.092+0.88+0.004 ms clock, 0.092+0.40/0.25/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 145 @436.125s 0%: 0.083+1.2+0.004 ms clock, 0.083+0.55/0.36/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 146 @439.155s 0%: 0.13+1.3+0.005 ms clock, 0.13+0.72/0.36/0+0.005 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    gc 147 @442.170s 0%: 0.092+1.1+0.004 ms clock, 0.092+0.43/0.36/0+0.004 ms cpu, 16->16->0 MB, 16 MB goal, 0 MB stacks, 0 MB globals, 1 P
    
    
    [root@br-apm-001 prometheus-2.40.1.linux-amd64]# go tool pprof http://localhost:6060/debug/pprof/allocs
    Fetching profile over HTTP from http://localhost:6060/debug/pprof/allocs
    Saved profile in /root/pprof/pprof.pprof-amd64-linux.alloc_objects.alloc_space.inuse_objects.inuse_space.002.pb.gz
    File: pprof-amd64-linux
    Type: alloc_space
    Time: Jul 28, 2023 at 9:17am (CST)
    Entering interactive mode (type "help" for commands, "o" for options)
    (pprof) top
    Showing nodes accounting for 2.42GB, 100% of 2.42GB total
    Dropped 7 nodes (cum <= 0.01GB)
          flat  flat%   sum%        cum   cum%
        2.42GB   100%   100%     2.42GB   100%  github.com/wolfogre/go-pprof-practice/animal/canidae/dog.(*Dog).Run (inline)
             0     0%   100%     2.42GB   100%  github.com/wolfogre/go-pprof-practice/animal/canidae/dog.(*Dog).Live
             0     0%   100%     2.42GB   100%  main.main
             0     0%   100%     2.42GB   100%  runtime.main
    (pprof) list Run
    Total: 2.42GB
    ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/canidae/dog.(*Dog).Run in E:/source/go/workspace/go-pprof-practice-master/animal/canidae/dog/dog.go
        2.42GB     2.42GB (flat, cum)   100% of Total
     Error: could not find file E:/source/go/workspace/go-pprof-practice-master/animal/canidae/dog/dog.go on path /data/br/base/prometheus-2.40.1.linux-amd64
    (pprof) 
    
    
    func (d *Dog) Run() {
        log.Println(d.Name(), "run")
        _ = make([]byte, 16*constant.Mi)
    }
    

    4.排查协程泄露

    go tool pprof http://localhost:6060/debug/pprof/goroutine

    [root@br-apm-001 prometheus-2.40.1.linux-amd64]# go tool pprof http://localhost:6060/debug/pprof/goroutine
    Fetching profile over HTTP from http://localhost:6060/debug/pprof/goroutine
    Saved profile in /root/pprof/pprof.pprof-amd64-linux.goroutine.001.pb.gz
    File: pprof-amd64-linux
    Type: goroutine
    Time: Jul 28, 2023 at 9:20am (CST)
    Entering interactive mode (type "help" for commands, "o" for options)
    (pprof) top
    Showing nodes accounting for 90, 98.90% of 91 total
    Showing top 10 nodes out of 33
          flat  flat%   sum%        cum   cum%
            89 97.80% 97.80%         89 97.80%  runtime.gopark
             1  1.10% 98.90%          1  1.10%  runtime.goroutineProfileWithLabels
             0     0% 98.90%         80 87.91%  github.com/wolfogre/go-pprof-practice/animal/canidae/wolf.(*Wolf).Drink.func1
             0     0% 98.90%          1  1.10%  github.com/wolfogre/go-pprof-practice/animal/felidae/cat.(*Cat).Live
             0     0% 98.90%          1  1.10%  github.com/wolfogre/go-pprof-practice/animal/felidae/cat.(*Cat).Pee
             0     0% 98.90%          7  7.69%  github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Pee.func1
             0     0% 98.90%          1  1.10%  internal/poll.(*FD).Accept
             0     0% 98.90%          1  1.10%  internal/poll.(*pollDesc).wait
             0     0% 98.90%          1  1.10%  internal/poll.(*pollDesc).waitRead (inline)
             0     0% 98.90%          1  1.10%  internal/poll.runtime_pollWait
    (pprof) list Drink
    Total: 91
    ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/canidae/wolf.(*Wolf).Drink.func1 in E:/source/go/workspace/go-pprof-practice-master/animal/canidae/wolf/wolf.go
             0         80 (flat, cum) 87.91% of Total
     Error: could not find file E:/source/go/workspace/go-pprof-practice-master/animal/canidae/wolf/wolf.go on path /data/br/base/prometheus-2.40.1.linux-amd64
    
    
    func (w *Wolf) Drink() {
        log.Println(w.Name(), "drink")
        for i := 0; i < 10; i++ {
            go func() {
                time.Sleep(30 * time.Second)
            }()
        }
    }
    

    5.排查锁的争用

    go tool pprof http://localhost:6060/debug/pprof/mutex

    [root@br-apm-001 prometheus-2.40.1.linux-amd64]# go tool pprof http://localhost:6060/debug/pprof/mutex
    Fetching profile over HTTP from http://localhost:6060/debug/pprof/mutex
    Saved profile in /root/pprof/pprof.pprof-amd64-linux.contentions.delay.001.pb.gz
    File: pprof-amd64-linux
    Type: delay
    Time: Jul 28, 2023 at 9:25am (CST)
    Entering interactive mode (type "help" for commands, "o" for options)
    (pprof) top
    Showing nodes accounting for 5.01s, 100% of 5.01s total
          flat  flat%   sum%        cum   cum%
         5.01s   100%   100%      5.01s   100%  sync.(*Mutex).Unlock (inline)
             0     0%   100%      5.01s   100%  github.com/wolfogre/go-pprof-practice/animal/canidae/wolf.(*Wolf).Howl.func1
    (pprof) list Howl
    Total: 5.01s
    ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/canidae/wolf.(*Wolf).Howl.func1 in E:/source/go/workspace/go-pprof-practice-master/animal/canidae/wolf/wolf.go
             0      5.01s (flat, cum)   100% of Total
     Error: could not find file E:/source/go/workspace/go-pprof-practice-master/animal/canidae/wolf/wolf.go on path /data/br/base/prometheus-2.40.1.linux-amd64
    (pprof) 
    
    
    func (w *Wolf) Howl() {
        log.Println(w.Name(), "howl")
    
        m := &sync.Mutex{}
        m.Lock()
        go func() {
            time.Sleep(time.Second)
            m.Unlock()
        }()
        m.Lock()
    }
    
    

    6.排查阻塞操作

    go tool pprof http://localhost:6060/debug/pprof/block

    [root@br-apm-001 prometheus-2.40.1.linux-amd64]# go tool pprof http://localhost:6060/debug/pprof/block
    Fetching profile over HTTP from http://localhost:6060/debug/pprof/block
    Saved profile in /root/pprof/pprof.pprof-amd64-linux.contentions.delay.002.pb.gz
    File: pprof-amd64-linux
    Type: delay
    Time: Jul 28, 2023 at 9:28am (CST)
    Entering interactive mode (type "help" for commands, "o" for options)
    (pprof) top
    Showing nodes accounting for 8.01s, 100% of 8.01s total
          flat  flat%   sum%        cum   cum%
         8.01s   100%   100%      8.01s   100%  runtime.chanrecv1
             0     0%   100%      8.01s   100%  github.com/wolfogre/go-pprof-practice/animal/felidae/cat.(*Cat).Live
             0     0%   100%      8.01s   100%  github.com/wolfogre/go-pprof-practice/animal/felidae/cat.(*Cat).Pee
             0     0%   100%      8.01s   100%  main.main
             0     0%   100%      8.01s   100%  runtime.main
    (pprof) list Pee
    Total: 8.01s
    ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/felidae/cat.(*Cat).Pee in E:/source/go/workspace/go-pprof-practice-master/animal/felidae/cat/cat.go
             0      8.01s (flat, cum)   100% of Total
     Error: could not find file E:/source/go/workspace/go-pprof-practice-master/animal/felidae/cat/cat.go on path /data/br/base/prometheus-2.40.1.linux-amd64
    (pprof) 
    
    
    func (c *Cat) Pee() {
        log.Println(c.Name(), "pee")
    
        <-time.After(time.Second)
    }
    

    参考

    相关文章

      网友评论

          本文标题:golang pprof

          本文链接:https://www.haomeiwen.com/subject/czqkpdtx.html