golang goroutine 采样:30 x 性能提升

202 阅读1分钟

综述

在 go 语言中,goroutine 性能分析需要 stop the world, 每 1000 个 goroutine 会使程序暂停 3 ms 左右。

不使用 gopcinfo 获取 traceback

原生的 goroutine profile 使用 gopcinfo 去查找调用栈,十分耗时。

不生成函数名

仅获取调用地址,异步解析函数名。

性能测试

经过测试,1 w 个 goroutine 只需要暂停 1ms 左右。