Skip to content

Commit

Permalink
chore: add Benchmark_procTreeExitProcessor
Browse files Browse the repository at this point in the history
For both Tracee and Controller.

-

Tracee

Running tool: /home/gg/.goenv/versions/1.22.4/bin/go test -benchmem
-run=^$ -tags ebpf -bench ^Benchmark_procTreeExitProcessor$
github.com/aquasecurity/tracee/pkg/ebpf -benchtime=100000000x

goos: linux
goarch: amd64
pkg: github.com/aquasecurity/tracee/pkg/ebpf
cpu: AMD Ryzen 9 7950X 16-Core Processor
Benchmark_procTreeExitProcessor-32  100000000  159.9 ns/op  48 B/op  2 allocs/op
PASS
ok  github.com/aquasecurity/tracee/pkg/ebpf  16.001s

---

Controller

Running tool: /home/gg/.goenv/versions/1.22.4/bin/go test -benchmem
-run=^$ -tags ebpf -bench ^Benchmark_procTreeExitProcessor$
github.com/aquasecurity/tracee/pkg/ebpf/controlplane -benchtime=100000000x

goos: linux
goarch: amd64
pkg: github.com/aquasecurity/tracee/pkg/ebpf/controlplane
cpu: AMD Ryzen 9 7950X 16-Core Processor
Benchmark_procTreeExitProcessor-32  100000000 335.5 ns/op  240 B/op  4 allocs/op
PASS
ok  github.com/aquasecurity/tracee/pkg/ebpf/controlplane  33.558s
  • Loading branch information
geyslan committed Jan 22, 2025
1 parent adad405 commit 56e011d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/ebpf/controlplane/processes_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,29 @@ func Benchmark_procTreeExecProcessor(b *testing.B) {
_ = ctrl.procTreeExecProcessor(args)
}
}

func Benchmark_procTreeExitProcessor(b *testing.B) {
ctrl := &Controller{}
ctrl.processTree, _ = proctree.NewProcessTree(
context.Background(),
proctree.ProcTreeConfig{
Source: proctree.SourceBoth,
ProcessCacheSize: proctree.DefaultProcessCacheSize,
ThreadCacheSize: proctree.DefaultThreadCacheSize,
},
)

args := []trace.Argument{
{ArgMeta: trace.ArgMeta{Name: "timestamp"}, Value: uint64(1)},
{ArgMeta: trace.ArgMeta{Name: "task_hash"}, Value: uint32(1)},
{ArgMeta: trace.ArgMeta{Name: "parent_hash"}, Value: uint32(1)},
{ArgMeta: trace.ArgMeta{Name: "leader_hash"}, Value: uint32(1)},
{ArgMeta: trace.ArgMeta{Name: "exit_code"}, Value: int64(1)},
{ArgMeta: trace.ArgMeta{Name: "process_group_exit"}, Value: true},
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = ctrl.procTreeExitProcessor(args)
}
}
24 changes: 24 additions & 0 deletions pkg/ebpf/processor_proctree_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,27 @@ func Benchmark_procTreeExecProcessor(b *testing.B) {
_ = t.procTreeExecProcessor(event)
}
}

func Benchmark_procTreeExitProcessor(b *testing.B) {
t := &Tracee{}
t.processTree, _ = proctree.NewProcessTree(
context.Background(),
proctree.ProcTreeConfig{
Source: proctree.SourceBoth,
ProcessCacheSize: proctree.DefaultProcessCacheSize,
ThreadCacheSize: proctree.DefaultThreadCacheSize,
},
)

event := &trace.Event{
Args: []trace.Argument{
{ArgMeta: trace.ArgMeta{Name: "exit_code"}, Value: int64(1)},
{ArgMeta: trace.ArgMeta{Name: "process_group_exit"}, Value: true},
},
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = t.procTreeExitProcessor(event)
}
}

0 comments on commit 56e011d

Please sign in to comment.