[8834751] | 1 | #include <stdint.h> |
---|
| 2 | #include <stdlib.hfa> |
---|
| 3 | |
---|
| 4 | #include <unistd.h> // STDERR_FILENO |
---|
| 5 | #include "bits/debug.hfa" |
---|
| 6 | #include "stats.hfa" |
---|
| 7 | |
---|
| 8 | #if !defined(__CFA_NO_STATISTICS__) |
---|
| 9 | void __init_stats( struct __stats_t * stats ) { |
---|
[52769ba] | 10 | stats->ready.pick.push.attempt = 0; |
---|
| 11 | stats->ready.pick.push.success = 0; |
---|
| 12 | stats->ready.pick.push.local = 0; |
---|
| 13 | stats->ready.pick.push.lsuccess = 0; |
---|
| 14 | stats->ready.pick.pop .probe = 0; |
---|
| 15 | stats->ready.pick.pop .attempt = 0; |
---|
| 16 | stats->ready.pick.pop .success = 0; |
---|
| 17 | stats->ready.pick.pop .local = 0; |
---|
| 18 | stats->ready.pick.pop .lsuccess = 0; |
---|
[29cb302] | 19 | stats->ready.threads.migration = 0; |
---|
[68f36f4] | 20 | stats->ready.sleep.halts = 0; |
---|
| 21 | stats->ready.sleep.cancels = 0; |
---|
| 22 | stats->ready.sleep.wakes = 0; |
---|
| 23 | stats->ready.sleep.exits = 0; |
---|
[8834751] | 24 | |
---|
| 25 | #if defined(HAVE_LINUX_IO_URING_H) |
---|
| 26 | stats->io.submit_q.submit_avg.rdy = 0; |
---|
| 27 | stats->io.submit_q.submit_avg.csm = 0; |
---|
| 28 | stats->io.submit_q.submit_avg.avl = 0; |
---|
| 29 | stats->io.submit_q.submit_avg.cnt = 0; |
---|
| 30 | stats->io.submit_q.look_avg.val = 0; |
---|
| 31 | stats->io.submit_q.look_avg.cnt = 0; |
---|
| 32 | stats->io.submit_q.look_avg.block = 0; |
---|
| 33 | stats->io.submit_q.alloc_avg.val = 0; |
---|
| 34 | stats->io.submit_q.alloc_avg.cnt = 0; |
---|
| 35 | stats->io.submit_q.alloc_avg.block = 0; |
---|
| 36 | stats->io.complete_q.completed_avg.val = 0; |
---|
| 37 | stats->io.complete_q.completed_avg.slow_cnt = 0; |
---|
| 38 | stats->io.complete_q.completed_avg.fast_cnt = 0; |
---|
| 39 | #endif |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | void __tally_stats( struct __stats_t * cltr, struct __stats_t * proc ) { |
---|
[52769ba] | 43 | __atomic_fetch_add( &cltr->ready.pick.push.attempt , proc->ready.pick.push.attempt , __ATOMIC_SEQ_CST ); |
---|
| 44 | __atomic_fetch_add( &cltr->ready.pick.push.success , proc->ready.pick.push.success , __ATOMIC_SEQ_CST ); |
---|
| 45 | __atomic_fetch_add( &cltr->ready.pick.push.local , proc->ready.pick.push.local , __ATOMIC_SEQ_CST ); |
---|
| 46 | __atomic_fetch_add( &cltr->ready.pick.push.lsuccess, proc->ready.pick.push.lsuccess, __ATOMIC_SEQ_CST ); |
---|
| 47 | __atomic_fetch_add( &cltr->ready.pick.pop .probe , proc->ready.pick.pop .probe , __ATOMIC_SEQ_CST ); |
---|
| 48 | __atomic_fetch_add( &cltr->ready.pick.pop .attempt , proc->ready.pick.pop .attempt , __ATOMIC_SEQ_CST ); |
---|
| 49 | __atomic_fetch_add( &cltr->ready.pick.pop .success , proc->ready.pick.pop .success , __ATOMIC_SEQ_CST ); |
---|
| 50 | __atomic_fetch_add( &cltr->ready.pick.pop .local , proc->ready.pick.pop .local , __ATOMIC_SEQ_CST ); |
---|
| 51 | __atomic_fetch_add( &cltr->ready.pick.pop .lsuccess, proc->ready.pick.pop .lsuccess, __ATOMIC_SEQ_CST ); |
---|
[29cb302] | 52 | __atomic_fetch_add( &cltr->ready.threads.migration, proc->ready.threads.migration, __ATOMIC_SEQ_CST ); |
---|
[68f36f4] | 53 | __atomic_fetch_add( &cltr->ready.sleep.halts , proc->ready.sleep.halts , __ATOMIC_SEQ_CST ); |
---|
| 54 | __atomic_fetch_add( &cltr->ready.sleep.cancels, proc->ready.sleep.cancels, __ATOMIC_SEQ_CST ); |
---|
| 55 | __atomic_fetch_add( &cltr->ready.sleep.wakes , proc->ready.sleep.wakes , __ATOMIC_SEQ_CST ); |
---|
| 56 | __atomic_fetch_add( &cltr->ready.sleep.exits , proc->ready.sleep.exits , __ATOMIC_SEQ_CST ); |
---|
[8834751] | 57 | |
---|
| 58 | #if defined(HAVE_LINUX_IO_URING_H) |
---|
| 59 | __atomic_fetch_add( &cltr->io.submit_q.submit_avg.rdy , proc->io.submit_q.submit_avg.rdy , __ATOMIC_SEQ_CST ); |
---|
| 60 | __atomic_fetch_add( &cltr->io.submit_q.submit_avg.csm , proc->io.submit_q.submit_avg.csm , __ATOMIC_SEQ_CST ); |
---|
| 61 | __atomic_fetch_add( &cltr->io.submit_q.submit_avg.avl , proc->io.submit_q.submit_avg.avl , __ATOMIC_SEQ_CST ); |
---|
| 62 | __atomic_fetch_add( &cltr->io.submit_q.submit_avg.cnt , proc->io.submit_q.submit_avg.cnt , __ATOMIC_SEQ_CST ); |
---|
| 63 | __atomic_fetch_add( &cltr->io.submit_q.look_avg.val , proc->io.submit_q.look_avg.val , __ATOMIC_SEQ_CST ); |
---|
| 64 | __atomic_fetch_add( &cltr->io.submit_q.look_avg.cnt , proc->io.submit_q.look_avg.cnt , __ATOMIC_SEQ_CST ); |
---|
| 65 | __atomic_fetch_add( &cltr->io.submit_q.look_avg.block , proc->io.submit_q.look_avg.block , __ATOMIC_SEQ_CST ); |
---|
| 66 | __atomic_fetch_add( &cltr->io.submit_q.alloc_avg.val , proc->io.submit_q.alloc_avg.val , __ATOMIC_SEQ_CST ); |
---|
| 67 | __atomic_fetch_add( &cltr->io.submit_q.alloc_avg.cnt , proc->io.submit_q.alloc_avg.cnt , __ATOMIC_SEQ_CST ); |
---|
| 68 | __atomic_fetch_add( &cltr->io.submit_q.alloc_avg.block , proc->io.submit_q.alloc_avg.block , __ATOMIC_SEQ_CST ); |
---|
| 69 | __atomic_fetch_add( &cltr->io.complete_q.completed_avg.val , proc->io.complete_q.completed_avg.val , __ATOMIC_SEQ_CST ); |
---|
| 70 | __atomic_fetch_add( &cltr->io.complete_q.completed_avg.slow_cnt, proc->io.complete_q.completed_avg.slow_cnt, __ATOMIC_SEQ_CST ); |
---|
| 71 | __atomic_fetch_add( &cltr->io.complete_q.completed_avg.fast_cnt, proc->io.complete_q.completed_avg.fast_cnt, __ATOMIC_SEQ_CST ); |
---|
| 72 | #endif |
---|
| 73 | } |
---|
| 74 | |
---|
[c34ebf2] | 75 | void __print_stats( struct __stats_t * stats, bool cluster, const char * name, void * id ) with( *stats ) { |
---|
[8834751] | 76 | |
---|
[13c5e19] | 77 | double push_sur = (100.0 * ((double)ready.pick.push.success) / ready.pick.push.attempt); |
---|
| 78 | double pop_sur = (100.0 * ((double)ready.pick.pop .success) / ready.pick.pop .attempt); |
---|
[8834751] | 79 | |
---|
[13c5e19] | 80 | double push_len = ((double)ready.pick.push.attempt) / ready.pick.push.success; |
---|
| 81 | double pop_len = ((double)ready.pick.pop .attempt) / ready.pick.pop .success; |
---|
[8834751] | 82 | |
---|
[52769ba] | 83 | double lpush_sur = (100.0 * ((double)ready.pick.push.lsuccess) / ready.pick.push.local); |
---|
| 84 | double lpop_sur = (100.0 * ((double)ready.pick.pop .lsuccess) / ready.pick.pop .local); |
---|
| 85 | |
---|
| 86 | double lpush_len = ((double)ready.pick.push.local) / ready.pick.push.lsuccess; |
---|
| 87 | double lpop_len = ((double)ready.pick.pop .local) / ready.pick.pop .lsuccess; |
---|
| 88 | |
---|
[8834751] | 89 | #if defined(HAVE_LINUX_IO_URING_H) |
---|
[13c5e19] | 90 | double avgrdy = ((double)io.submit_q.submit_avg.rdy) / io.submit_q.submit_avg.cnt; |
---|
| 91 | double avgcsm = ((double)io.submit_q.submit_avg.csm) / io.submit_q.submit_avg.cnt; |
---|
| 92 | double avgavl = ((double)io.submit_q.submit_avg.avl) / io.submit_q.submit_avg.cnt; |
---|
[8834751] | 93 | |
---|
| 94 | double lavgv = 0; |
---|
| 95 | double lavgb = 0; |
---|
[13c5e19] | 96 | if(io.submit_q.look_avg.cnt != 0) { |
---|
| 97 | lavgv = ((double)io.submit_q.look_avg.val ) / io.submit_q.look_avg.cnt; |
---|
| 98 | lavgb = ((double)io.submit_q.look_avg.block) / io.submit_q.look_avg.cnt; |
---|
[8834751] | 99 | } |
---|
| 100 | |
---|
| 101 | double aavgv = 0; |
---|
| 102 | double aavgb = 0; |
---|
[13c5e19] | 103 | if(io.submit_q.alloc_avg.cnt != 0) { |
---|
| 104 | aavgv = ((double)io.submit_q.alloc_avg.val ) / io.submit_q.alloc_avg.cnt; |
---|
| 105 | aavgb = ((double)io.submit_q.alloc_avg.block) / io.submit_q.alloc_avg.cnt; |
---|
[8834751] | 106 | } |
---|
| 107 | #endif |
---|
| 108 | |
---|
| 109 | __cfaabi_bits_print_safe( STDOUT_FILENO, |
---|
[c34ebf2] | 110 | "----- %s \"%s\" (%p) - Ready Q Stats -----\n" |
---|
[8834751] | 111 | "- total threads run : %'15lu\n" |
---|
| 112 | "- total threads scheduled: %'15lu\n" |
---|
[52769ba] | 113 | "- push average probe len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n" |
---|
| 114 | "- pop average probe len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n" |
---|
| 115 | "- local push avg prb len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n" |
---|
| 116 | "- local pop avg prb len : %'18.2lf, %'18.2lf%% (%'15lu attempts)\n" |
---|
[29cb302] | 117 | "- thread migrations : %'15lu\n" |
---|
[68f36f4] | 118 | "- Idle Sleep -\n" |
---|
| 119 | "-- halts : %'15lu\n" |
---|
| 120 | "-- cancelled halts : %'15lu\n" |
---|
| 121 | "-- schedule wake : %'15lu\n" |
---|
| 122 | "-- wake on exit : %'15lu\n" |
---|
[c34ebf2] | 123 | "\n" |
---|
| 124 | , cluster ? "Cluster" : "Processor", name, id |
---|
| 125 | , ready.pick.pop.success |
---|
| 126 | , ready.pick.push.success |
---|
| 127 | , push_len, push_sur, ready.pick.push.attempt |
---|
| 128 | , pop_len , pop_sur , ready.pick.pop .attempt |
---|
| 129 | , lpush_len, lpush_sur, ready.pick.push.local |
---|
| 130 | , lpop_len , lpop_sur , ready.pick.pop .local |
---|
| 131 | , ready.threads.migration |
---|
| 132 | , ready.sleep.halts, ready.sleep.cancels, ready.sleep.wakes, ready.sleep.exits |
---|
| 133 | ); |
---|
| 134 | #if defined(HAVE_LINUX_IO_URING_H) |
---|
| 135 | __cfaabi_bits_print_safe( STDOUT_FILENO, |
---|
| 136 | "----- %s \"%s\" (%p) - I/O Stats -----\n" |
---|
[13c5e19] | 137 | "- total submit calls : %'15lu\n" |
---|
[8834751] | 138 | "- avg ready entries : %'18.2lf\n" |
---|
| 139 | "- avg submitted entries : %'18.2lf\n" |
---|
| 140 | "- avg available entries : %'18.2lf\n" |
---|
[13c5e19] | 141 | "- total ready search : %'15lu\n" |
---|
[8834751] | 142 | "- avg ready search len : %'18.2lf\n" |
---|
| 143 | "- avg ready search block : %'18.2lf\n" |
---|
[13c5e19] | 144 | "- total alloc search : %'15lu\n" |
---|
[8834751] | 145 | "- avg alloc search len : %'18.2lf\n" |
---|
| 146 | "- avg alloc search block : %'18.2lf\n" |
---|
[13c5e19] | 147 | "- total wait calls : %'15lu (%'lu slow, %'lu fast)\n" |
---|
[8834751] | 148 | "- avg completion/wait : %'18.2lf\n" |
---|
[c34ebf2] | 149 | "\n" |
---|
| 150 | , cluster ? "Cluster" : "Processor", name, id |
---|
[13c5e19] | 151 | , io.submit_q.submit_avg.cnt |
---|
[c34ebf2] | 152 | , avgrdy, avgcsm, avgavl |
---|
[13c5e19] | 153 | , io.submit_q.look_avg.cnt |
---|
[c34ebf2] | 154 | , lavgv, lavgb |
---|
[13c5e19] | 155 | , io.submit_q.alloc_avg.cnt |
---|
[c34ebf2] | 156 | , aavgv, aavgb |
---|
[13c5e19] | 157 | , io.complete_q.completed_avg.slow_cnt + io.complete_q.completed_avg.fast_cnt |
---|
| 158 | , io.complete_q.completed_avg.slow_cnt, io.complete_q.completed_avg.fast_cnt |
---|
| 159 | , ((double)io.complete_q.completed_avg.val) / (io.complete_q.completed_avg.slow_cnt + io.complete_q.completed_avg.fast_cnt) |
---|
[c34ebf2] | 160 | ); |
---|
| 161 | #endif |
---|
[8834751] | 162 | } |
---|
| 163 | #endif |
---|