From 092ba747e516620054852f012dbc7d00031683dd Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 14 Mar 2025 20:26:31 +0200 Subject: add sycall on bottom --- Makefile | 14 ++++++++++---- internal/flamegraph/flamegraph.go | 19 +++++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 26c74a7..668a877 100644 --- a/Makefile +++ b/Makefile @@ -35,9 +35,15 @@ world: clean generate all .PHONY: flames flames: - perl ~/git/FlameGraph/flamegraph.pl ior-by-count-flamegraph.collapsed \ + perl ~/git/FlameGraph/flamegraph.pl ior-by-path-count-flamegraph.collapsed \ --title "I/O Syscall Count" --nametype Path --hash \ - > ior-by-count-flamegraph.svg - perl ~/git/FlameGraph/flamegraph.pl ior-by-duration-flamegraph.collapsed \ + > ior-by-path-count-flamegraph.svg; \ + perl ~/git/FlameGraph/flamegraph.pl ior-by-path-duration-flamegraph.collapsed \ --title "I/O Syscall Durations" --nametype Path --hash --countname Nanoseconds \ - > ior-by-duration-flamegraph.svg + > ior-by-path-duration-flamegraph.svg; \ + perl ~/git/FlameGraph/flamegraph.pl ior-by-syscall-count-flamegraph.collapsed \ + --title "I/O Syscall Count" --nametype Path --hash \ + > ior-by-syscall-count-flamegraph.svg; \ + 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; \ diff --git a/internal/flamegraph/flamegraph.go b/internal/flamegraph/flamegraph.go index 85b6a5c..cf1284e 100644 --- a/internal/flamegraph/flamegraph.go +++ b/internal/flamegraph/flamegraph.go @@ -71,15 +71,21 @@ func (f Flamegraph) Add(ev *event.Pair) { } func (f Flamegraph) dump() { - f.dumpBy("ior-by-count-flamegraph.collapsed", func(cnt counter) uint64 { + f.dumpBy("ior-by-path-count-flamegraph.collapsed", true, func(cnt counter) uint64 { return cnt.count }) - f.dumpBy("ior-by-duration-flamegraph.collapsed", func(cnt counter) uint64 { + f.dumpBy("ior-by-path-duration-flamegraph.collapsed", true, func(cnt counter) uint64 { + return cnt.duration + }) + f.dumpBy("ior-by-syscall-count-flamegraph.collapsed", false, func(cnt counter) uint64 { + return cnt.count + }) + f.dumpBy("ior-by-syscall-duration-flamegraph.collapsed", false, func(cnt counter) uint64 { return cnt.duration }) } -func (f Flamegraph) dumpBy(outfile string, by func(counter) uint64) { +func (f Flamegraph) dumpBy(outfile string, syscallAtTop bool, by func(counter) uint64) { fmt.Println("Dumping", outfile) file, err := os.Create(outfile) if err != nil { @@ -99,7 +105,12 @@ func (f Flamegraph) dumpBy(outfile string, by func(counter) uint64) { } for traceId, cnt := range value { - _, err := fmt.Fprintf(file, "%s;syscall`%s %v\n", sb.String(), traceId.Name(), by(cnt)) + var err error + if syscallAtTop { + _, err = fmt.Fprintf(file, "%s;syscall`%s %v\n", sb.String(), traceId.Name(), by(cnt)) + } else { + _, err = fmt.Fprintf(file, "syscall`%s;%s %v\n", traceId.Name(), sb.String(), by(cnt)) + } if err != nil { panic(err) } -- cgit v1.2.3