Skip to content

Commit 19dc879

Browse files
committed
perf(ebpf): improve decodeEvents (HashTaskID)
Metrics from local benchmarking on a AMD Ryzen 9 7950X 16-Core Processor with 64GB RAM running 6.12.25-1-MANJARO. The stress test was run with 8mi events triggered in 8 threads. - CPU time | Function | Before | After | Change | Improvement (%) | |--------------|-----------|-----------|-----------|-----------------| | decodeEvents | 26.87 sec | 25.22 sec | -1.65 sec | 6.14% | | HashTaskID | 0.38 sec | 0.34 sec | -0.04 sec | 10.53% | - Memory | Metric | Function | Before | After | Change | Improv. (%) | |---------------|--------------|---------|---------|----------|-------------| | alloc_space | decodeEvents | 8.52 GB | 8.48 GB | -0.04 GB | 0.47% | | inuse_objects | decodeEvents | 1.17 K | 0.85 K | -0.32 K | 27.35% | | alloc_objects | decodeEvents | 91.96 M | 89.31 M | -2.65 M | 2.88% |
1 parent 10100a2 commit 19dc879

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/ebpf/events_pipeline.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@ func (t *Tracee) decodeEvents(ctx context.Context, sourceChan chan []byte) (<-ch
275275
evt.Metadata = nil
276276
// compute hashes using normalized times
277277
evt.ThreadEntityId = utils.HashTaskID(eCtx.HostTid, uint64(evt.ThreadStartTime))
278-
evt.ProcessEntityId = utils.HashTaskID(eCtx.HostPid, traceetime.BootToEpochNS(eCtx.LeaderStartTime))
278+
if eCtx.HostTid == eCtx.HostPid && eCtx.StartTime == eCtx.LeaderStartTime {
279+
evt.ProcessEntityId = evt.ThreadEntityId // leader thread - same as thread entity id
280+
} else {
281+
evt.ProcessEntityId = utils.HashTaskID(eCtx.HostPid, traceetime.BootToEpochNS(eCtx.LeaderStartTime))
282+
}
279283
evt.ParentEntityId = utils.HashTaskID(eCtx.HostPpid, traceetime.BootToEpochNS(eCtx.ParentStartTime))
280284

281285
// If there aren't any policies that need filtering in userland, tracee **may** skip

0 commit comments

Comments
 (0)