go tool pprof http://localhost:6060/debug/pprof/profile 下面将不再赘述了。 剩下可以可以使用的命令包含 go tool pprof http://localhost:6060/debug/pprof/heapgo tool pprof http://localhost:6060/debug/pprof/profile?seconds=30go tool pprof http://localhost:6060/debug/pprof/blockgo tool pprof http...
gotoolpprofhttp://192.168.1.27:8080/debug/pprof/allocsgotoolpprofhttp://192.168.1.27:8080/debug/pprof/blockgotoolpprofhttp://192.168.1.27:8080/debug/pprof/cmdlinegotoolpprofhttp://192.168.1.27:8080/debug/pprof/heapgotoolpprofhttp://192.168.1.27:8080/debug/pprof/mutexgotoolpprofhttp://192.168.1.2...
# 下载cpu profile,默认从当前开始收集30s的cpu使用情况,需要等待30s go tool pprof http://localhost:8080/debug/pprof/profile #30-second CPU profile go tool pprof http://localhost:8080/debug/pprof/profile?seconds=120 #wait 120s # 下载heap profile go tool pprof http://localhost:8080/debug/pprof/...
我们再看下具体的goruntine信息http://localhost:8001/debug/pprof/goroutine?debug=1,会发现goruntine出现在哪一行代码 然后我们还可以使用Go自带的pprof查看工具来看一下: 代码语言:shell 复制 go tool pprof-seconds=10-http=:9999 http://localhost:8001/debug/pprof/heap 然后我们打开http://localhost:9999/ui...
可以看到 CPU 占用相当高,这显然是有问题的,我们使用go tool pprof来排场一下: 代码语言:javascript 复制 go tool pprof http://localhost:6060/debug/pprof/profile 等待一会儿后,进入一个交互式终端: image 输入top 命令,查看 CPU 占用较高的调用:
mutex(Mutex Profiling):$HOST/debug/pprof/mutex,查看导致互斥锁的竞争持有者的堆栈跟踪 threadcreate:$HOST/debug/pprof/threadcreate,查看创建新OS线程的堆栈跟踪 通常我们比较关心的就是 cpu/block/heap/mutex 相关信息了。 2.通过命令行 go tool pprof http://localhost:8080/debug/pprof/profile?seconds=20 查...
packagecontrollerimport("github.com/gin-gonic/gin""pay/service")varHeap=new(heap)typeheapstruct{}func(h*heap)Log(ctx*gin.Context){service.Heap.GetNum()} 3、使用pprof进行排查 对用例进行内存排查和定位,可以用如下的命令 gotool pprof http://localhost:8001/pprof/heap ...
pprof主要核心就是将pprof路由注册到服务中,并可以访问此服务即可 数据分析 数据分析通过命令 go tool pprof 进行,主要有2种查看模式 1:通过http路径进入交互模式 2:通过文件进入交互模式或者进入web页面查看 交互模式 进入命令行,基于http路径的数据分析:
golang pprof 的使用调试 cpu,heap,gc,逃逸 golang 的服务调优大体需要从cpu, heap,gc入手。 cpu分析是从抽样程序里各个模块的运行效率,单位是ms heap分析是分析抽样程序各个模块的内存损耗, 单位是 MB gc分析是记录gc时的一些样本状态,比如gc的次数,gc时对象数量,gc后对象数量,堆大小等...
最常用的4种pprof类型包括了堆分析heap、协程栈分析goroutine、CPU占用分析profile、程序运行跟踪信息trace 3.2 交互式分析 下面以堆内存(heap)分析为示例: # 进入交互命令 ➜gotool pprof http://127.0.0.1:6060/debug/pprof/heap?debug=1Fetching profile over HTTP from http://127.0.0.1:6060/debug/pprof/he...