Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions internal/plot/plot_gc_cleanups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//go:build go1.26

package plot

import (
"runtime/metrics"
"time"
)

var _ = register(description{
metrics: []string{
"/gc/cleanups/executed:cleanups",
"/gc/cleanups/queued:cleanups",
},
getvalues: func() getvalues {
return func(_ time.Time, samples []metrics.Sample) any {
executed := samples[idx_gc_cleanups_executed_cleanups].Value.Uint64()
queued := samples[idx_gc_cleanups_queued_cleanups].Value.Uint64()
return []uint64{queued - executed}
}
},
layout: Scatter{
Name: "gc-cleanups",
Tags: []tag{tagGC},
Title: "GC Cleanups Queue",
Type: "bar",
Layout: ScatterLayout{
BarMode: "stack",
Yaxis: ScatterYAxis{
Title: "cleanups",
},
},
Subplots: []Subplot{
{Unitfmt: "%{y}", Type: "bar", Name: "queue size"},
},
InfoText: `Approximate length of the cleanup functions queue (created by runtime.AddCleanup).
Its <i>/gc/cleanups/queued:cleanups</i> - <i>/gc/cleanups/executed:cleanups</i>.
Useful for detecting slow cleanups holding up the queue.
`},
})
40 changes: 40 additions & 0 deletions internal/plot/plot_gc_finalizers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//go:build go1.26

package plot

import (
"runtime/metrics"
"time"
)

var _ = register(description{
metrics: []string{
"/gc/finalizers/executed:finalizers",
"/gc/finalizers/queued:finalizers",
},
getvalues: func() getvalues {
return func(_ time.Time, samples []metrics.Sample) any {
executed := samples[idx_gc_finalizers_executed_finalizers].Value.Uint64()
queued := samples[idx_gc_finalizers_queued_finalizers].Value.Uint64()
return []uint64{queued - executed}
}
},
layout: Scatter{
Name: "gc-finalizers",
Tags: []tag{tagGC},
Title: "GC Finalizers Queue",
Type: "bar",
Layout: ScatterLayout{
BarMode: "stack",
Yaxis: ScatterYAxis{
Title: "finalizers",
},
},
Subplots: []Subplot{
{Unitfmt: "%{y}", Type: "bar", Name: "queue size"},
},
InfoText: `Length of the finalizer functions queue (created by runtime.AddFinalizer).
Its <i>/gc/finalizers/queued:cleanups</i> - <i>/gc/finalizers/executed:cleanups</i>.
Useful for detecting finalizers overwhelming the queue, either by being too slow, or by there being too many of them.
`},
})
4 changes: 4 additions & 0 deletions internal/plot/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (r *registry) register(desc description) {
}

r.descriptions = append(r.descriptions, desc)

for _, metric := range desc.metrics {
r.mustidx(metric)
}
}

func mustidx(metric string) int {
Expand Down
Loading