Update perf.events and add new charts (#11392)
thiagoftsm committed
Aug 4, 2021 at 14:44 UTC
2d65230fb4d30a04929ce46ab18abc16aec306db
2 files changed
+61
-20
collectors/perf.plugin/perf_plugin.c
+54
-20
@@ -9,10 +9,11 @@
9
// Hardware counters
10
#define NETDATA_CHART_PRIO_PERF_CPU_CYCLES 8800
11
#define NETDATA_CHART_PRIO_PERF_INSTRUCTIONS 8801
12
-#define NETDATA_CHART_PRIO_PERF_BRANCH_INSTRUCTIONS 8802
13
-#define NETDATA_CHART_PRIO_PERF_CACHE 8803
14
-#define NETDATA_CHART_PRIO_PERF_BUS_CYCLES 8804
15
-#define NETDATA_CHART_PRIO_PERF_FRONT_BACK_CYCLES 8805
12
+#define NETDATA_CHART_PRIO_PERF_IPC 8802
13
+#define NETDATA_CHART_PRIO_PERF_BRANCH_INSTRUCTIONS 8803
14
+#define NETDATA_CHART_PRIO_PERF_CACHE 8804
15
+#define NETDATA_CHART_PRIO_PERF_BUS_CYCLES 8805
16
+#define NETDATA_CHART_PRIO_PERF_FRONT_BACK_CYCLES 8806
17
18
// Software counters
19
#define NETDATA_CHART_PRIO_PERF_MIGRATIONS 8810
@@ -436,6 +437,7 @@ static void perf_send_metrics() {
437
static int // Hardware counters
438
cpu_cycles_chart_generated = 0,
439
instructions_chart_generated = 0,
440
+ ipc_chart_generated = 0,
441
branch_chart_generated = 0,
442
cache_chart_generated = 0,
443
bus_cycles_chart_generated = 0,
@@ -461,7 +463,7 @@ static void perf_send_metrics() {
463
if(unlikely(!cpu_cycles_chart_generated)) {
464
cpu_cycles_chart_generated = 1;
465
464
- printf("CHART %s.%s '' 'CPU cycles' 'cycles/s' %s '' line %d %d %s\n"
466
+ printf("CHART %s.%s '' 'CPU cycles' 'cycles/s' %s '' line %d %d '' %s\n"
467
, RRD_TYPE_PERF
468
, "cpu_cycles"
469
, RRD_FAMILY_HW
@@ -501,7 +503,7 @@ static void perf_send_metrics() {
503
if(unlikely(!instructions_chart_generated)) {
504
instructions_chart_generated = 1;
505
504
- printf("CHART %s.%s '' 'Instructions' 'instructions/s' %s '' line %d %d %s\n"
506
+ printf("CHART %s.%s '' 'Instructions' 'instructions/s' %s '' line %d %d '' %s\n"
507
, RRD_TYPE_PERF
508
, "instructions"
509
, RRD_FAMILY_HW
@@ -527,11 +529,43 @@ static void perf_send_metrics() {
529
530
// ------------------------------------------------------------------------
531
532
+ if(likely(perf_events[EV_ID_INSTRUCTIONS].updated) && likely(perf_events[EV_ID_CPU_CYCLES].updated)) {
533
+ if(unlikely(!ipc_chart_generated)) {
534
+ ipc_chart_generated = 1;
535
+
536
+ printf("CHART %s.%s '' '%s' 'instructions/cycle' %s '' line %d %d '' %s\n"
537
+ , RRD_TYPE_PERF
538
+ , "instructions_per_cycle"
539
+ , "Instructions per Cycle(IPC)"
540
+ , RRD_FAMILY_HW
541
+ , NETDATA_CHART_PRIO_PERF_IPC
542
+ , update_every
543
+ , PLUGIN_PERF_NAME
544
+ );
545
+ printf("DIMENSION %s '' absolute 1 100\n", "ipc");
546
+ }
547
+
548
+ printf("BEGIN %s.%s\n"
549
+ , RRD_TYPE_PERF
550
+ , "instructions_per_cycle"
551
+ );
552
+
553
+ calculated_number result = ((calculated_number)perf_events[EV_ID_INSTRUCTIONS].value /
554
+ (calculated_number)perf_events[EV_ID_CPU_CYCLES].value) * 100.0;
555
+ printf("SET %s = %lld\n"
556
+ , "ipc"
557
+ , (collected_number) result
558
+ );
559
+ printf("END\n");
560
+ }
561
+
562
+ // ------------------------------------------------------------------------
563
+
564
if(likely(perf_events[EV_ID_BRANCH_INSTRUCTIONS].updated || perf_events[EV_ID_BRANCH_MISSES].updated)) {
565
if(unlikely(!branch_chart_generated)) {
566
branch_chart_generated = 1;
567
534
- printf("CHART %s.%s '' 'Branch instructions' 'instructions/s' %s '' line %d %d %s\n"
568
+ printf("CHART %s.%s '' 'Branch instructions' 'instructions/s' %s '' line %d %d '' %s\n"
569
, RRD_TYPE_PERF
570
, "branch_instructions"
571
, RRD_FAMILY_HW
@@ -571,7 +605,7 @@ static void perf_send_metrics() {
605
if(unlikely(!cache_chart_generated)) {
606
cache_chart_generated = 1;
607
574
- printf("CHART %s.%s '' 'Cache operations' 'operations/s' %s '' line %d %d %s\n"
608
+ printf("CHART %s.%s '' 'Cache operations' 'operations/s' %s '' line %d %d '' %s\n"
609
, RRD_TYPE_PERF
610
, "cache"
611
, RRD_FAMILY_HW
@@ -611,7 +645,7 @@ static void perf_send_metrics() {
645
if(unlikely(!bus_cycles_chart_generated)) {
646
bus_cycles_chart_generated = 1;
647
614
- printf("CHART %s.%s '' 'Bus cycles' 'cycles/s' %s '' line %d %d %s\n"
648
+ printf("CHART %s.%s '' 'Bus cycles' 'cycles/s' %s '' line %d %d '' %s\n"
649
, RRD_TYPE_PERF
650
, "bus_cycles"
651
, RRD_FAMILY_HW
@@ -641,7 +675,7 @@ static void perf_send_metrics() {
675
if(unlikely(!stalled_cycles_chart_generated)) {
676
stalled_cycles_chart_generated = 1;
677
644
- printf("CHART %s.%s '' 'Stalled frontend and backend cycles' 'cycles/s' %s '' line %d %d %s\n"
678
+ printf("CHART %s.%s '' 'Stalled frontend and backend cycles' 'cycles/s' %s '' line %d %d '' %s\n"
679
, RRD_TYPE_PERF
680
, "stalled_cycles"
681
, RRD_FAMILY_HW
@@ -681,7 +715,7 @@ static void perf_send_metrics() {
715
if(unlikely(!migrations_chart_generated)) {
716
migrations_chart_generated = 1;
717
684
- printf("CHART %s.%s '' 'CPU migrations' 'migrations' %s '' line %d %d %s\n"
718
+ printf("CHART %s.%s '' 'CPU migrations' 'migrations' %s '' line %d %d '' %s\n"
719
, RRD_TYPE_PERF
720
, "migrations"
721
, RRD_FAMILY_SW
@@ -711,7 +745,7 @@ static void perf_send_metrics() {
745
if(unlikely(!alignment_chart_generated)) {
746
alignment_chart_generated = 1;
747
714
- printf("CHART %s.%s '' 'Alignment faults' 'faults' %s '' line %d %d %s\n"
748
+ printf("CHART %s.%s '' 'Alignment faults' 'faults' %s '' line %d %d '' %s\n"
749
, RRD_TYPE_PERF
750
, "alignment_faults"
751
, RRD_FAMILY_SW
@@ -741,7 +775,7 @@ static void perf_send_metrics() {
775
if(unlikely(!emulation_chart_generated)) {
776
emulation_chart_generated = 1;
777
744
- printf("CHART %s.%s '' 'Emulation faults' 'faults' %s '' line %d %d %s\n"
778
+ printf("CHART %s.%s '' 'Emulation faults' 'faults' %s '' line %d %d '' %s\n"
779
, RRD_TYPE_PERF
780
, "emulation_faults"
781
, RRD_FAMILY_SW
@@ -772,7 +806,7 @@ static void perf_send_metrics() {
806
if(unlikely(!L1D_chart_generated)) {
807
L1D_chart_generated = 1;
808
775
- printf("CHART %s.%s '' 'L1D cache operations' 'events/s' %s '' line %d %d %s\n"
809
+ printf("CHART %s.%s '' 'L1D cache operations' 'events/s' %s '' line %d %d '' %s\n"
810
, RRD_TYPE_PERF
811
, "l1d_cache"
812
, RRD_FAMILY_CACHE
@@ -828,7 +862,7 @@ static void perf_send_metrics() {
862
if(unlikely(!L1D_prefetch_chart_generated)) {
863
L1D_prefetch_chart_generated = 1;
864
831
- printf("CHART %s.%s '' 'L1D prefetch cache operations' 'prefetches/s' %s '' line %d %d %s\n"
865
+ printf("CHART %s.%s '' 'L1D prefetch cache operations' 'prefetches/s' %s '' line %d %d '' %s\n"
866
, RRD_TYPE_PERF
867
, "l1d_cache_prefetch"
868
, RRD_FAMILY_CACHE
@@ -858,7 +892,7 @@ static void perf_send_metrics() {
892
if(unlikely(!L1I_chart_generated)) {
893
L1I_chart_generated = 1;
894
861
- printf("CHART %s.%s '' 'L1I cache operations' 'events/s' %s '' line %d %d %s\n"
895
+ printf("CHART %s.%s '' 'L1I cache operations' 'events/s' %s '' line %d %d '' %s\n"
896
, RRD_TYPE_PERF
897
, "l1i_cache"
898
, RRD_FAMILY_CACHE
@@ -899,7 +933,7 @@ static void perf_send_metrics() {
933
if(unlikely(!LL_chart_generated)) {
934
LL_chart_generated = 1;
935
902
- printf("CHART %s.%s '' 'LL cache operations' 'events/s' %s '' line %d %d %s\n"
936
+ printf("CHART %s.%s '' 'LL cache operations' 'events/s' %s '' line %d %d '' %s\n"
937
, RRD_TYPE_PERF
938
, "ll_cache"
939
, RRD_FAMILY_CACHE
@@ -956,7 +990,7 @@ static void perf_send_metrics() {
990
if(unlikely(!DTLB_chart_generated)) {
991
DTLB_chart_generated = 1;
992
959
- printf("CHART %s.%s '' 'DTLB cache operations' 'events/s' %s '' line %d %d %s\n"
993
+ printf("CHART %s.%s '' 'DTLB cache operations' 'events/s' %s '' line %d %d '' %s\n"
994
, RRD_TYPE_PERF
995
, "dtlb_cache"
996
, RRD_FAMILY_CACHE
@@ -1012,7 +1046,7 @@ static void perf_send_metrics() {
1046
if(unlikely(!ITLB_chart_generated)) {
1047
ITLB_chart_generated = 1;
1048
1015
- printf("CHART %s.%s '' 'ITLB cache operations' 'events/s' %s '' line %d %d %s\n"
1049
+ printf("CHART %s.%s '' 'ITLB cache operations' 'events/s' %s '' line %d %d '' %s\n"
1050
, RRD_TYPE_PERF
1051
, "itlb_cache"
1052
, RRD_FAMILY_CACHE
@@ -1052,7 +1086,7 @@ static void perf_send_metrics() {
1086
if(unlikely(!PBU_chart_generated)) {
1087
PBU_chart_generated = 1;
1088
1055
- printf("CHART %s.%s '' 'PBU cache operations' 'events/s' %s '' line %d %d %s\n"
1089
+ printf("CHART %s.%s '' 'PBU cache operations' 'events/s' %s '' line %d %d '' %s\n"
1090
, RRD_TYPE_PERF
1091
, "pbu_cache"
1092
, RRD_FAMILY_CACHE
web/gui/dashboard_info.js
+7
@@ -3467,6 +3467,13 @@ netdataDashboard.context = {
3467
info: 'Size of metric samples written to disk.'
3468
},
3469
3470
+ // ------------------------------------------------------------------------
3471
+ // Perf
3472
+
3473
+ 'perf.instructions_per_cycle': {
3474
+ info: 'An IPC < 1.0 likely means memory bound, and an IPC > 1.0 likely means instruction bound. For more details about the metric take a look at this <a href="https://www.brendangregg.com/blog/2017-05-09/cpu-utilization-is-wrong.html" target="_blank">blog post</a>.'
3475
+ },
3476
+
3477
// ------------------------------------------------------------------------
3478
// Filesystem
3479