summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-03-14 20:12:53 +0200
committerPaul Buetow <paul@buetow.org>2025-03-14 20:12:53 +0200
commita4948d9fb1aded11e3111f3730b4e3e4e5bd540c (patch)
treea769be7265ea956033380919eaf1d8d56e395892
parent5373526439ef4f7554da365bff7817e8c621a9b4 (diff)
use syscall name without enter_ prefix
-rw-r--r--internal/eventloop.go10
-rw-r--r--internal/flags/flags.go1
-rw-r--r--internal/flamegraph/flamegraph.go8
-rw-r--r--internal/ior.go1
4 files changed, 10 insertions, 10 deletions
diff --git a/internal/eventloop.go b/internal/eventloop.go
index 26718b5..0fc7387 100644
--- a/internal/eventloop.go
+++ b/internal/eventloop.go
@@ -60,13 +60,13 @@ func (e *eventLoop) stats() string {
}
func (e *eventLoop) run(ctx context.Context, rawCh <-chan []byte) {
- var recycle bool
-
if e.flags.FlamegraphEnable {
e.flamegraph.Start(ctx)
}
if e.flags.PprofEnable {
fmt.Println("Profiling, press Ctrl+C to stop")
+ }
+ if !e.flags.FlamegraphEnable && !e.flags.PprofEnable {
fmt.Println(event.EventStreamHeader)
}
@@ -75,14 +75,10 @@ func (e *eventLoop) run(ctx context.Context, rawCh <-chan []byte) {
switch {
case e.flags.FlamegraphEnable:
e.flamegraph.Add(ev)
- recycle = false // Flamegraph needs to recycle by itself
case e.flags.PprofEnable:
- recycle = true
+ ev.RecyclePrev()
default:
- recycle = true
fmt.Println(ev.String())
- }
- if recycle {
ev.RecyclePrev()
}
e.numSyscallsAfterFilter++
diff --git a/internal/flags/flags.go b/internal/flags/flags.go
index 236c7ae..da62f34 100644
--- a/internal/flags/flags.go
+++ b/internal/flags/flags.go
@@ -7,6 +7,7 @@ import (
bpf "github.com/aquasecurity/libbpfgo"
)
+// TODO: Filter by syscall (tracepoint names)
type Flags struct {
PidFilter int
TidFilter int
diff --git a/internal/flamegraph/flamegraph.go b/internal/flamegraph/flamegraph.go
index 1bfd82e..85b6a5c 100644
--- a/internal/flamegraph/flamegraph.go
+++ b/internal/flamegraph/flamegraph.go
@@ -15,9 +15,11 @@ type counter struct {
duration uint64
}
-// TODO: Profile for CPU usage
+// TODO: Profile for CPU usage. If too slow, can fan out into multiple maps and
+// then merge at the end the maps.
type Flamegraph struct {
- // Collapsed flamegraph stats collector
+ // TODO: Keep al lthe individual files at the leaf in a map as well.
+ // And when dumped, only dump the N "highest" and summarize the other ones.
collapsed map[string]map[types.TraceId]counter
inCh chan *event.Pair
Done chan struct{}
@@ -97,7 +99,7 @@ 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, by(cnt))
+ _, err := fmt.Fprintf(file, "%s;syscall`%s %v\n", sb.String(), traceId.Name(), by(cnt))
if err != nil {
panic(err)
}
diff --git a/internal/ior.go b/internal/ior.go
index 62e25ef..3aa4679 100644
--- a/internal/ior.go
+++ b/internal/ior.go
@@ -82,6 +82,7 @@ func Run(flags flags.Flags) {
ctx, cancel := context.WithCancel(context.Background())
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
+
go func() {
defer cancel()
<-c