parca-dev / parca-agent

eBPF based always-on profiler auto-discovering targets in Kubernetes and systemd, zero code changes or restarts needed!
https://parca.dev/
Apache License 2.0
558 stars 68 forks source link

Allocation Profiling Support #5

Open brancz opened 3 years ago

brancz commented 3 years ago

Aside from CPU profiling, allocation profiling is very useful as well, especially because a lot of CPU is spent on poor allocation practices. Allocation profiling can also be useful for troubleshooting memory leaks.

This can be done using USDT (Userland Statically Defined Tracing) using uprobe. It's likely that this will require language/runtime specific implementations (see bcc's uobjnew).

zecke commented 3 years ago

That's neat. How far do you want to take this? Some part of this screams plain prometheus "exporter" for USDT or any uprobe. But the combination of counter + backtrace for anything (sent UDP packets, bytes, number of CPU migrations, ...) is really interesting.

brancz commented 3 years ago

I think I'd like to see us building full profiles with the stack traces that call the allocation causing functions. I think it would be neat to build two separate profiles

1) the number of allocations 2) the amount of memory allocated

The differentiation can be interesting because often CPU can be improved not by allocating less memory in total, but just more contiguous memory at once.