fix: nodata timeout check

This commit is contained in:
langhuihui
2025-09-26 11:12:44 +08:00
parent c0a13cbbf2
commit 5fb769bfa2
8 changed files with 374 additions and 19 deletions

View File

@@ -557,6 +557,12 @@ func (p *DebugPlugin) GetHeapGraph(ctx context.Context, empty *emptypb.Empty) (*
if err != nil {
return nil, err
}
// 清理不重要的函数,使图形更干净明了
if err := profile.RemoveUninteresting(); err != nil {
return nil, fmt.Errorf("could not remove uninteresting functions: %v", err)
}
// Generate dot graph.
dot, err := debug.GetDotGraph(profile)
if err != nil {

View File

@@ -9,7 +9,12 @@ import (
)
func GetDotGraph(profile *profile.Profile) (string, error) {
rpt := report.NewDefault(profile, report.Options{})
// 设置节点数量限制,使图形更简洁(类似官方 pprof
options := report.Options{
NodeCount: 80, // 限制最大节点数
NodeFraction: 0.005, // 过滤掉小于 0.5% 的节点
}
rpt := report.NewDefault(profile, options)
g, config := report.GetDOT(rpt)
dot := &bytes.Buffer{}
graph.ComposeDot(dot, g, &graph.DotAttributes{}, config)

View File

@@ -166,9 +166,10 @@ func (i *NodeInfo) PrintableName() string {
// NameComponents returns the components of the printable name to be used for a node.
func (i *NodeInfo) NameComponents() []string {
var name []string
if i.Address != 0 {
name = append(name, fmt.Sprintf("%016x", i.Address))
}
// 注释掉内存地址显示,使图形更简洁
// if i.Address != 0 {
// name = append(name, fmt.Sprintf("%016x", i.Address))
// }
if fun := i.Name; fun != "" {
name = append(name, fun)
}