在pprof堆剖析中,glob.func表示全局函数。

huangapple go评论68阅读模式
英文:

glob.func in pprof heap profiles

问题

在使用go tool pprof进行堆剖析时,我看到一些条目,例如github.com/anacrolix/utp.glob.func1。这似乎不对应于我能看到的任何命名函数,我猜它是一个闭包。glob是指什么?我如何将这样的名称与适当的函数关联起来?

英文:

When doing a heap profile using go tool pprof, I see some entries like github.com/anacrolix/utp.glob.func1. This doesn't correspond to any named function I can see, I assume it's a closure. What does glob refer to? How can I associate names like this to the appropriate function?在pprof堆剖析中,glob.func表示全局函数。

答案1

得分: 2

glob指的是全局环境,func1表示匿名函数。因此,它应该指的是某个全局的匿名函数。请查看这个示例及其panic信息:

示例:

package main

import (
	"fmt"
)

var (
	p = func() string {
		panic("a")

		return "asdf"
	}()
)

func main() {
	fmt.Println(p)
}

Panic信息:

panic: a

goroutine 1 [running]:
panic(0x128360, 0x1040a120)
	/usr/local/go/src/runtime/panic.go:464 +0x700
main.glob.func1(0x0, 0x0)
	/tmp/sandbox715198144/main.go:9 +0x80
main.init()
	/tmp/sandbox715198144/main.go:12 +0xa0
英文:

glob refers to global environment, func1 means anonymous function. So it should refer to some global anonymous function. Check this example and its panic information:

Example:

package main

import (
	"fmt"
)

var (
	p = func() string {
		panic("a")

		return "asdf"
	}()
)

func main() {
	fmt.Println(p)
}

Panic information:

panic: a

goroutine 1 [running]:
panic(0x128360, 0x1040a120)
	/usr/local/go/src/runtime/panic.go:464 +0x700
main.glob.func1(0x0, 0x0)
	/tmp/sandbox715198144/main.go:9 +0x80
main.init()
	/tmp/sandbox715198144/main.go:12 +0xa0

huangapple
  • 本文由 发表于 2016年4月15日 11:29:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/36637758.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定