As noted in #1019, there's a problem with elevated CPU usage when parsing kallsyms for heavy bpf users.
There's some more context in that PR from #1019 (comment) and down.
The problem seems two-fold:
- If there are many bpf symbols, the parsing is slowed down. There's a patch to fix this upstream from me here and an alternative from @florianl here. This takes care of slowness when reading bpf symbols, but it doesn't address the fact that the baseline is bad too:
- If there's a significant churn in bpf symbols due to frequent loading in unloading (from
bpftool prog show or anything else), just happens all the time with a 100ms pause:
|
case <-s.reloadSymbols: |
|
// Just trigger reloading of symbols with small delay to batch |
|
// potentially multiple module loads. |
|
if nextKallsymsReload == noTimeout { |
|
nextKallsymsReload = time.After(100 * time.Millisecond) |
|
} |
The pause helps with update coalescing, but it's still 100% of on-CPU time for ~100ms with a 100ms pause, which is a non-trivial amount.
Given that we already subscribe to bpf_ksym_add and it receives the following struct as an argument, we should have all the information to add symbols without full /proc/kallsyms re-parsing:
struct bpf_ksym {
unsigned long start;
unsigned long end;
char name[KSYM_NAME_LEN];
// ...
};
As noted in #1019, there's a problem with elevated CPU usage when parsing kallsyms for heavy bpf users.
There's some more context in that PR from #1019 (comment) and down.
The problem seems two-fold:
bpftool prog showor anything else), just happens all the time with a 100ms pause:opentelemetry-ebpf-profiler/kallsyms/kallsyms.go
Lines 578 to 583 in db2fc46
The pause helps with update coalescing, but it's still 100% of on-CPU time for ~100ms with a 100ms pause, which is a non-trivial amount.
Given that we already subscribe to
bpf_ksym_addand it receives the following struct as an argument, we should have all the information to add symbols without full/proc/kallsymsre-parsing: