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