mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-12-24 13:48:04 +08:00
fix: nodata timeout check
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user