extend ecapture to profile CPU usage? #137
Replies: 4 comments 8 replies
-
My idea is that keep eCapture as monolithic as possible. just TLS/SSL. Sometimes I want to remove bash/mysqld modules. But I think this idea of yours should be needed by a lot of people. So, I think :
which Option would you choose ? |
Beta Was this translation helpful? Give feedback.
-
hm, I found out that some BCC tools are actually ported to libbpf https://github.com/iovisor/bcc/tree/master/libbpf-tools that are completely written in C, the ported tool including offcputime that I compiled on Centos8, and can also run on Ubuntu 22.04, after I ran offcputime, I think it is not actually what I wanted, [RFC 0/6] perf record: Implement off-cpu profiling with BPF (v3) is closer to what I want. not sure if it is easy to implement based on ecapture framework though |
Beta Was this translation helpful? Give feedback.
-
fyi, I found this |
Beta Was this translation helpful? Give feedback.
-
yep, for _, s := range syms {
if elf.ST_TYPE(s.Info) != elf.STT_FUNC {
// Symbol not associated with a function or other executable code.
continue
}
address := s.Value
// Loop over ELF segments.
for _, prog := range f.Progs {
// Skip uninteresting segments.
if prog.Type != elf.PT_LOAD || (prog.Flags&elf.PF_X) == 0 {
continue
}
if prog.Vaddr <= s.Value && s.Value < (prog.Vaddr+prog.Memsz) {
// If the symbol value is contained in the segment, calculate
// the symbol offset.
//
// fn symbol offset = fn symbol VA - .text VA + .text offset
//
// stackoverflow.com/a/40249502
address = s.Value - prog.Vaddr + prog.Off
break
}
}
ex.addresses[s.Name] = address
} |
Beta Was this translation helpful? Give feedback.
-
Hi @cfc4n
I was searching if there is eBPF kprobe/uprobe tool to profile CPU usage like linux perf tool does
perf record
,perf report
, orperf top
. I found bcc tool https://github.com/iovisor/bcc/blob/master/tools/offcputime.py does exactly that, but bcc is heavy package and not installed for blackbox environment. I like the portability of ecapture, could ecapture be extended to have bcc offcputime like feature to collect cpu kernel/user stack for CPU usage profiling and the collected data could be used to create flame graph, I think this would extend ecapture to even bigger user space, I am new to eBPF kprobe/uprobe, but I am learning it everyday, if you don't have time to do it, I could learn to do it but need guidance :-)Vincent
Beta Was this translation helpful? Give feedback.
All reactions