9 ms·
Perf is a great tool. I'm still amazed at the way it can trace the execution of a program right through the kernel layer to show where the process is really spe
by colonwqbang 5y ago
Perf is a great tool. I'm still amazed at the way it can trace the execution of a program right through the kernel layer to show where the process is really spending (wasting) its time.
- wyldfire 5y agoIt's not a trace in the ptrace sense. Last I checked it uses clock based samples or hardware-native performance counters, depending on what's useful. The results are incredibly useful but the process is somewhat 'simple' IMO. Imagine an ISR from a clock source that records the PC. Ok, it's not quite that simple but it's what is at the core. One thing that can be confusing is that programs that do some I/O and/or IPC -- it won't be counted, and sometimes perf will point to the 'wrong' bottleneck. That's why it's helpful to understand the tool's design. Intel's perf counter was called something like "CLK_UNHALTED" back in the day and that was helpful to remind you exactly what was being measured. If your program is slow because of the computation/memory access etc, it's perfect.
- R0b0t1 5y agoIt does two things (or three, but all of which use the same hardware). PC sampling, and counters that tick on specific events. The events can be processor instruction related, like cache misses, or kernel events.
- mhh__ 5y agoIf you're on an Intel CPU try vTune, it's like perf on crack. Everything perf does vTune does better and in a pretty GUI that draws diagrams and pipelines for you.