Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save florianl/64164fcb559f0beb7bf974a3e92f1503 to your computer and use it in GitHub Desktop.

Select an option

Save florianl/64164fcb559f0beb7bf974a3e92f1503 to your computer and use it in GitHub Desktop.
gotraceui - flight recorder
From 461be79cb4e3275b54727fff506799c063ae13ed Mon Sep 17 00:00:00 2001
From: Florian Lehner <[email protected]>
Date: Wed, 11 Jun 2025 21:29:53 +0200
Subject: [PATCH] Support new flight recorder format
Signed-off-by: Florian Lehner <[email protected]>
---
cmd/gotraceui/goroutine.go | 4 ++--
cmd/gotraceui/span.go | 5 ++---
go.mod | 4 ++--
go.sum | 8 ++++----
trace/ptrace/ptrace.go | 10 ++++------
5 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/cmd/gotraceui/goroutine.go b/cmd/gotraceui/goroutine.go
index aa46d15..82089f7 100644
--- a/cmd/gotraceui/goroutine.go
+++ b/cmd/gotraceui/goroutine.go
@@ -320,9 +320,9 @@ func goroutineSpanTooltip(win *theme.Window, gtx layout.Context, tr *Trace, span
for _, attr := range attrs {
switch attr.Name {
case "bytes swept":
- swept = attr.Value.Uint64()
+ swept = attr.Value.ToUint64()
case "bytes reclaimed":
- reclaimed = attr.Value.Uint64()
+ reclaimed = attr.Value.ToUint64()
}
}
label += local.Sprintf("\nSwept %d bytes, reclaimed %d bytes", swept, reclaimed)
diff --git a/cmd/gotraceui/span.go b/cmd/gotraceui/span.go
index b57a4dd..5601231 100644
--- a/cmd/gotraceui/span.go
+++ b/cmd/gotraceui/span.go
@@ -148,10 +148,9 @@ func (si *SpansInfo) init(win *theme.Window) {
ev := si.trace.Event(spans.AtPtr(0).StartEvent)
stk := ev.Stack()
sb := strings.Builder{}
- stk.Frames(func(frame exptrace.StackFrame) bool {
+ for frame := range stk.Frames() {
fmt.Fprintf(&sb, "%s\n %s:%d\n", frame.Func, frame.File, frame.Line)
- return true
- })
+ }
stacktrace := sb.String()
if len(stacktrace) > 0 && stacktrace[len(stacktrace)-1] == '\n' {
stacktrace = stacktrace[:len(stacktrace)-1]
diff --git a/go.mod b/go.mod
index 5d1e30b..c5d019b 100644
--- a/go.mod
+++ b/go.mod
@@ -1,12 +1,12 @@
module honnef.co/go/gotraceui
-go 1.23
+go 1.24
require (
gioui.org v0.4.1
gioui.org/x v0.4.0
github.com/golang/snappy v0.0.4
- golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
+ golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476
golang.org/x/image v0.7.0
golang.org/x/text v0.9.0
honnef.co/go/curve v0.0.0-20250106034005-bfbc0c6fe0cc
diff --git a/go.sum b/go.sum
index 563279a..b617b39 100644
--- a/go.sum
+++ b/go.sum
@@ -22,8 +22,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
-golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
+golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 h1:bsqhLWFR6G6xiQcb+JoGqdKdRU6WzPWmK8E0jxTjzo4=
+golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91 h1:ryT6Nf0R83ZgD8WnFFdfI8wCeyqgdXWN4+CkFVNPAT0=
golang.org/x/exp/shiny v0.0.0-20220827204233-334a2380cb91/go.mod h1:VjAR7z0ngyATZTELrBSkxOOHhhlnVUxDye4mcjx5h/8=
golang.org/x/image v0.7.0 h1:gzS29xtG1J5ybQlv0PuyfE3nmc6R4qB73m6LUUmvFuw=
@@ -58,8 +58,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
-golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
-golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
+golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
+golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
honnef.co/go/curve v0.0.0-20250106034005-bfbc0c6fe0cc h1:obxBLi/4kFCM1oKlrEoYEEplJ2267W+lfKsYaGSQ1Zs=
honnef.co/go/curve v0.0.0-20250106034005-bfbc0c6fe0cc/go.mod h1:qoI+1aKyxvS7Ni/ZX2NKQe2S6PfL08gR3hTHK3/E+io=
diff --git a/trace/ptrace/ptrace.go b/trace/ptrace/ptrace.go
index c9c0773..8cb80af 100644
--- a/trace/ptrace/ptrace.go
+++ b/trace/ptrace/ptrace.go
@@ -134,11 +134,9 @@ func (t *Trace) addStack(stk exptrace.Stack) {
stacks := (*dataTable)(table.Elem().FieldByName("stacks").Addr().UnsafePointer())
pcs, _ := get(stacks, reflect.ValueOf(stk).FieldByName("id").Uint())
t.Stacks[stk] = pcs
-
- stk.Frames(func(f exptrace.StackFrame) bool {
- t.PCs[f.PC] = f
- return true
- })
+ for frame := range stk.Frames() {
+ t.PCs[frame.PC] = frame
+ }
}
// Start returns the time of the first event in the trace.
@@ -616,7 +614,7 @@ func processEvents(r *exptrace.Reader, tr *Trace, progress func(float64)) error
m := ev.Metric()
mm := tr.Metrics[m.Name]
mm.Timestamps = append(mm.Timestamps, ev.Time())
- mm.Values = append(mm.Values, m.Value.Uint64())
+ mm.Values = append(mm.Values, m.Value.ToUint64())
tr.Metrics[m.Name] = mm
case exptrace.EventRangeActive:
if synced {
--
2.49.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment