Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #39 from stealthrocket/bump-wzprof
Browse files Browse the repository at this point in the history
Bump wzprof to 0.1.5
  • Loading branch information
pelletier committed Jun 1, 2023
2 parents 418fdf3 + b3f92e2 commit b1f3e92
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ go 1.20
require (
github.com/google/flatbuffers v23.5.9+incompatible
github.com/google/go-cmp v0.5.9
github.com/google/pprof v0.0.0-20230406165453-00490a63f317
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3
github.com/google/uuid v1.3.0
github.com/klauspost/compress v1.16.5
github.com/stealthrocket/wasi-go v0.1.1
github.com/stealthrocket/wazergo v0.19.0
github.com/stealthrocket/wzprof v0.1.5-0.20230526193557-ec6e2ad60848
github.com/stealthrocket/wzprof v0.1.5
github.com/tetratelabs/wazero v1.1.1-0.20230522055633-256b7a4bf970
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
gopkg.in/yaml.v3 v3.0.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/google/flatbuffers v23.5.9+incompatible h1:mTPHyMn3/qO7lvBcm5S9p0olWU
github.com/google/flatbuffers v23.5.9+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R19ydQFtofxT0Sv3QsKNMVQYTMQ=
github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3 h1:2XF1Vzq06X+inNqgJ9tRnGuw+ZVCB3FazXODD6JE1R8=
github.com/google/pprof v0.0.0-20230510103437-eeec1cb781c3/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
Expand All @@ -12,8 +12,8 @@ github.com/stealthrocket/wasi-go v0.1.1 h1:9Q9zpKWItoObGjNG5kkllzHx1sksiq/MKfuYd
github.com/stealthrocket/wasi-go v0.1.1/go.mod h1:LBhZHvAroNNQTejkVTMJZ01ssj3jXF+3Lkbru4cTzGQ=
github.com/stealthrocket/wazergo v0.19.0 h1:0ZBya2fBURvV+I2hGl0vcuQ8dgoUvllxQ7aYlZSA5nI=
github.com/stealthrocket/wazergo v0.19.0/go.mod h1:riI0hxw4ndZA5e6z7PesHg2BtTftcZaMxRcoiGGipTs=
github.com/stealthrocket/wzprof v0.1.5-0.20230526193557-ec6e2ad60848 h1:gNZnxEbv7OgKkGvRU4PtGDZpzls81FV0IYoUW3I46l0=
github.com/stealthrocket/wzprof v0.1.5-0.20230526193557-ec6e2ad60848/go.mod h1:hqLzj5iDSncc6rlPMhC51O642AkaC+dWVPNNalZdlCY=
github.com/stealthrocket/wzprof v0.1.5 h1:Y3jQHvdGFQMySV2VIjJhBu08OdcqcflfTz7CvrH5MGM=
github.com/stealthrocket/wzprof v0.1.5/go.mod h1:hqLzj5iDSncc6rlPMhC51O642AkaC+dWVPNNalZdlCY=
github.com/tetratelabs/wazero v1.1.1-0.20230522055633-256b7a4bf970 h1:X5OOeHRjoLA8XhVc7biEbh1/hnTzpYpPn7HuyarMslQ=
github.com/tetratelabs/wazero v1.1.1-0.20230522055633-256b7a4bf970/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
Expand Down
15 changes: 9 additions & 6 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ func profile(ctx context.Context, args []string) error {
endTime: timeRange.End,
sampleRate: 1.0,
}
records.cpu = wzprof.NewCPUProfiler(wzprof.TimeFunc(records.now))
records.mem = wzprof.NewMemoryProfiler()
p := wzprof.ProfilingFor(module.Code)
records.cpu = p.CPUProfiler(wzprof.TimeFunc(records.now))
records.mem = p.MemoryProfiler()

ctx = context.WithValue(ctx,
experimental.FunctionListenerFactoryKey{},
Expand All @@ -162,6 +163,9 @@ func profile(ctx context.Context, args []string) error {
return err
}
defer compiledModule.Close(ctx)
if err := p.Prepare(compiledModule); err != nil {
return err
}

replay := wasicall.NewReplay(records)
defer replay.Close(ctx)
Expand Down Expand Up @@ -233,7 +237,6 @@ type recordProfiler struct {
started bool
stopped bool
sampleRate float64
symbols wzprof.Symbolizer
}

func (r *recordProfiler) Read(records []timemachine.Record) (int, error) {
Expand Down Expand Up @@ -271,8 +274,8 @@ func (r *recordProfiler) start() {
func (r *recordProfiler) stop() {
if !r.stopped {
r.stopped = true
r.cpuProfile = r.cpu.StopProfile(r.sampleRate, r.symbols)
r.memProfile = r.mem.NewProfile(r.sampleRate, r.symbols)
r.cpuProfile = r.cpu.StopProfile(r.sampleRate)
r.memProfile = r.mem.NewProfile(r.sampleRate)
r.cpuProfile.TimeNanos = r.startTime.UnixNano()
r.memProfile.TimeNanos = r.startTime.UnixNano()
duration := r.lastTimestamp - r.firstTimestamp
Expand Down Expand Up @@ -304,7 +307,7 @@ func createProfiles(reg *timemachine.Registry, processID format.UUID, profiles .
}(p)
}

var descriptors = make([]*format.Descriptor, 0, len(profiles))
descriptors := make([]*format.Descriptor, 0, len(profiles))
var lastErr error
for range profiles {
d, err := (<-ch).Value()
Expand Down

0 comments on commit b1f3e92

Please sign in to comment.