diff options
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | internal/eventloop.go | 2 | ||||
| -rw-r--r-- | internal/flamegraph/flamegraph.go | 4 |
3 files changed, 11 insertions, 3 deletions
@@ -4,6 +4,7 @@ export GOOS = linux export GOARCH = amd64 export CGO_CFLAGS = -I$(LIBBPFGO)/output -I$(LIBBPFGO)/selftest/common export CGO_LDFLAGS = -lelf -lzstd $(LIBBPFGO)/output/libbpf/libbpf.a +export GO ?= go all: bpfbuild gobuild @@ -22,7 +23,7 @@ generated: .PHONY: gobuild gobuild: - go build -tags netgo -ldflags '-w -extldflags "-static"' -o ior ./cmd/ior/main.go + $(GO) build -tags netgo -ldflags '-w -extldflags "-static"' -o ior ./cmd/ior/main.go .PHONY: clean clean: @@ -47,3 +48,8 @@ flames: perl ~/git/FlameGraph/flamegraph.pl ior-by-syscall-duration-flamegraph.collapsed \ --title "I/O Syscall Durations" --nametype Path --hash --countname Nanoseconds \ > ior-by-syscall-duration-flamegraph.svg; \ + +.PHONY: prof +prof: + $(GO) tool pprof -pdf ./ior ior.cpuprofile > cpuprofile.pdf && evince cpuprofile.pdf & + $(GO) tool pprof -pdf ./ior ior.memprofile > memprofile.pdf && evince memprofile.pdf & diff --git a/internal/eventloop.go b/internal/eventloop.go index 08b53f6..fca5958 100644 --- a/internal/eventloop.go +++ b/internal/eventloop.go @@ -195,7 +195,7 @@ func (e *eventLoop) syscallExit(exitEv event.Event, ch chan<- *event.Pair) { case *PathEvent: nameEvent := ev.EnterEv.(*PathEvent) - ev.File = file.PathnameFile{string(nameEvent.Pathname[:])} + ev.File = file.PathnameFile{Pathname: string(nameEvent.Pathname[:])} ev.Comm = e.comm(ev.EnterEv.GetTid()) case *FdEvent: diff --git a/internal/flamegraph/flamegraph.go b/internal/flamegraph/flamegraph.go index cf1284e..9214f49 100644 --- a/internal/flamegraph/flamegraph.go +++ b/internal/flamegraph/flamegraph.go @@ -8,6 +8,7 @@ import ( "os" "path" "strings" + "time" ) type counter struct { @@ -55,11 +56,12 @@ func (f Flamegraph) Start(ctx context.Context) { default: select { case <-ctx.Done(): + defer close(f.Done) fmt.Println("Flamegraph processed last event") f.dump() - close(f.Done) return default: + time.Sleep(time.Millisecond * 10) } } } |
