namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.03k stars 444 forks source link

report: graph: add new fields for pmu-cycle data from read trigger #1596

Open honggyukim opened 1 year ago

honggyukim commented 1 year ago

We can read pmu cycle and number of instructions executed with read trigger as follows.

$ gcc -pg -o t-abc tests/s-abc.c
$ uftrace -T main@read=pmu-cycle t-abc 
# DURATION     TID     FUNCTION
   1.516 us [ 50294] | __monstartup();
   0.778 us [ 50294] | __cxa_atexit();
            [ 50294] | main() {
            [ 50294] |   /* read:pmu-cycle (cycles=521 instructions=31) */
            [ 50294] |   a() {
            [ 50294] |     b() {
            [ 50294] |       c() {
   1.515 us [ 50294] |         getpid();
   2.740 us [ 50294] |       } /* c */
   3.162 us [ 50294] |     } /* b */
   3.537 us [ 50294] |   } /* a */
            [ 50294] |   /* diff:pmu-cycle (cycles=+5389 instructions=+5504 IPC=1.02) */
  62.849 us [ 50294] | } /* main */

However, there is no way to show these data in report and graph so it would be useful to add new fields for Cycles and Instrs to report and graph commands. They can be displayed only when data is available.

namhyung commented 1 year ago

I doubt we can add something in a general way.. but maybe someone has different ideas.