tikv / pprof-rs

A Rust CPU profiler implemented with the help of backtrace-rs
Apache License 2.0
1.3k stars 99 forks source link

Detect child processes and external profiling #112

Open omarabid opened 2 years ago

omarabid commented 2 years ago

It does not seem that pprof-rs is detecting child-processes started by the main program. How hard do you think it is to implement this? Also is it possible to externally profile a Rust application? (through its PID)?

YangKeao commented 2 years ago

I was trying to link with the nongnu-libunwind in https://github.com/tikv/pprof-rs/pull/102 . If this attempt succeed, I can try to use libunwind-ptrace to get the backtrace of an external process.

Another part of the profiling is the sampling timer, I have seen many different implementations (like loop and ptrace / watch the signal / ...), and I need to compare which one is better.

omarabid commented 2 years ago

@YangKeao That's exciting. For the timer, you can have a look here: https://github.com/pyroscope-io/pyroscope-rs/tree/main/src/timer. We use epoll/kqueue for a more precise timer. Granted, we are using this for 10s timeframes, so I'm not quite sure about the performance implication of using for 100 times a second; but you can give it a shot and let me know if you need help with that!