Early WIP: rr/sampling profiler hybrid#1754
Conversation
|
Looks very interesting! Thanks for exploring this. You forgot to mention an important benefit from this approach which is having the option to 'Jump to the debugger' when looking at a profile to analyze what causes a slow path. It looks like in the patch you're 'sampling' every 4k CPU cycles (for the current process?). AIUI this would effectively be a 'user/process' CPU time trigger rather than a wall clock trigger? |
|
Seems to me you could send a signal to the tracee, like the perf-event signal now, that interrupts the tracee and is treated like any other async signal by rr so you can easily replay to delivery of that signal using the existing logic. |
Yes, that's a little tricky of course with sampling. However, I do consider this essentially the same problem. In theory your sampling profiler could just walk the stack, record all variables, etc, but in practice nobody does because it would make sampling impractical.
Not quite, by setting the |
I was hoping to avoid the overhead of the extra context switch. |
|
@Keno Would you mind to rebase the changes on current master? |
This is an idea I've been kicking around. When doing sampling profiling, you really want to minimize the amount of work you do while sampling in order for it to a) be fast and b) not disrupt the program too much. Unfortunately this is of course in direct conflict with actually collecting anything useful. What I'm proposing here is to use rr to do the actual data collection as a post-processing step. The way this is done is to sample the current ip and the value of the retired branch counter, thus hopefully allowing us to find this position again during replay and do whatever we want to do (backtrace, collect values, more fancy things, etc...).
This is nowhere near done, but I figured people may have early feedback.