Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Bolt's Journal

## 2024-05-24 - [Initial Setup]
**Learning:** Initialized Bolt's journal.
**Action:** Always check this file before starting.
13 changes: 8 additions & 5 deletions ebpftracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"os"
"unsafe"
"path"
"runtime"
"strconv"
Expand Down Expand Up @@ -432,13 +433,15 @@ func runEventsReader(name string, r *perf.Reader, ch chan<- Event, typ perfMapTy

switch typ {
case perfMapTypeL7Events:
v := &l7Event{}
data := rec.RawSample

if err := binary.Read(bytes.NewBuffer(data), binary.LittleEndian, v); err != nil {
klog.Warningln("failed to read l7 event:", err)
// OPTIMIZATION: Use unsafe pointer cast instead of binary.Read to avoid
// expensive reflection and memory allocation.
// The l7Event struct matches the C-struct layout (including padding).
// We verify the size to ensure memory safety.
if len(rec.RawSample) < int(unsafe.Sizeof(l7Event{})) {
klog.Warningln("l7 event too small:", len(rec.RawSample))
continue
}
v := (*l7Event)(unsafe.Pointer(&rec.RawSample[0]))

// Extract payload data directly from the struct arrays
payloadSize := min(int(v.PayloadSize), len(v.Payload))
Expand Down
Loading