-
-
Save brancz/9e56f8a302d6e196f57c4953156595b5 to your computer and use it in GitHub Desktop.
Adapt pprof profile data downloaded from Parca to be on index position 1. This is needed because in the Go 1.20 release the compiler hard-codes this position. See: https://github.com/golang/go/issues/58292
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
"github.com/google/pprof/profile" | |
) | |
func main() { | |
filename := os.Args[1] | |
f, err := os.Open(filename) | |
if err != nil { | |
log.Fatal("open:", err) | |
} | |
p, err := profile.Parse(f) | |
if err != nil { | |
log.Fatal("could not parse profile: ", err) | |
} | |
p.SampleType = []*profile.ValueType{ | |
&profile.ValueType{ | |
Type: "fake", | |
Unit: "fake", | |
}, | |
p.SampleType[0], | |
} | |
for _, s := range p.Sample { | |
s.Value = []int64{0, s.Value[0]} | |
} | |
f, err = os.Create(filename + ".out") | |
if err != nil { | |
log.Fatal("could not create CPU profile: ", err) | |
} | |
defer f.Close() | |
if err := p.Write(f); err != nil { | |
log.Fatal("could not write profile: ", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment