英文:
Find out who started a goroutine (pprof)
问题
当检查pprof
的输出时,我可以看到一个goroutine的堆栈跟踪。然而,我想知道是谁启动(生成)了这个goroutine,这可能吗?
英文:
When examining the output of pprof
I can see the stacktrace of a goroutine. However I'd like to know who started (spawned?) this goroutine, is this possible?
答案1
得分: 1
如果您查看端点/debug/pprof/goroutine?debug=2
,您将获得稍微不同的堆栈跟踪输出:
goroutine 859579 [running]:
runtime/pprof.writeGoroutineStacks(0x176a0e0, 0xc43403a340, 0x178d740, 0x30)
/usr/local/go/src/runtime/pprof/pprof.go:585 +0x79
runtime/pprof.writeGoroutine(0x176a0e0, 0xc43403a340, 0x2, 0x0, 0xd)
/usr/local/go/src/runtime/pprof/pprof.go:574 +0x44
runtime/pprof.(*Profile).WriteTo(0x178f9e0, 0x176a0e0, 0xc43403a340, 0x2, 0xc43403a340, 0xc4587b5834)
/usr/local/go/src/runtime/pprof/pprof.go:298 +0x341
net/http/pprof.handler.ServeHTTP(0xc4587b5841, 0x9, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/pprof/pprof.go:209 +0x1a6
net/http/pprof.Index(0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/pprof/pprof.go:221 +0x205
net/http.HandlerFunc.ServeHTTP(0x12664a8, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:1726 +0x44
net/http.(*ServeMux).ServeHTTP(0x179dde0, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:2022 +0x7f
net/http.serverHandler.ServeHTTP(0xc46d06ed80, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc45dc83180, 0x17734a0, 0xc4942f0600)
/usr/local/go/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2293 +0x44d
其中包括最后的created by
行。
英文:
If you look at the endpoint /debug/pprof/goroutine?debug=2
you get a slightly different output for the stack traces:
goroutine 859579 [running]:
runtime/pprof.writeGoroutineStacks(0x176a0e0, 0xc43403a340, 0x178d740, 0x30)
/usr/local/go/src/runtime/pprof/pprof.go:585 +0x79
runtime/pprof.writeGoroutine(0x176a0e0, 0xc43403a340, 0x2, 0x0, 0xd)
/usr/local/go/src/runtime/pprof/pprof.go:574 +0x44
runtime/pprof.(*Profile).WriteTo(0x178f9e0, 0x176a0e0, 0xc43403a340, 0x2, 0xc43403a340, 0xc4587b5834)
/usr/local/go/src/runtime/pprof/pprof.go:298 +0x341
net/http/pprof.handler.ServeHTTP(0xc4587b5841, 0x9, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/pprof/pprof.go:209 +0x1a6
net/http/pprof.Index(0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/pprof/pprof.go:221 +0x205
net/http.HandlerFunc.ServeHTTP(0x12664a8, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:1726 +0x44
net/http.(*ServeMux).ServeHTTP(0x179dde0, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:2022 +0x7f
net/http.serverHandler.ServeHTTP(0xc46d06ed80, 0x1771320, 0xc43403a340, 0xc49a7093b0)
/usr/local/go/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc45dc83180, 0x17734a0, 0xc4942f0600)
/usr/local/go/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2293 +0x44d
That include the created by
line at the end.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论