[8834751] | 1 | #pragma once
|
---|
| 2 |
|
---|
[73f4d08] | 3 | // #define CFA_STATS_ARRAY 10000
|
---|
| 4 |
|
---|
[8834751] | 5 | #include <stdint.h>
|
---|
| 6 |
|
---|
[b7664a03] | 7 | enum {
|
---|
| 8 | CFA_STATS_READY_Q = 0x01,
|
---|
| 9 | CFA_STATS_IO = 0x02,
|
---|
| 10 | };
|
---|
| 11 |
|
---|
[8834751] | 12 | #if defined(__CFA_NO_STATISTICS__)
|
---|
| 13 | struct __stats_t;
|
---|
| 14 | static inline void __init_stats( struct __stats_t * ) {}
|
---|
| 15 | static inline void __tally_stats( struct __stats_t *, struct __stats_t * ) {}
|
---|
[1b033b8] | 16 | static inline void __print_stats( struct __stats_t *, int, const char *, const char *, void * ) {}
|
---|
[8834751] | 17 | #else
|
---|
[d2fadeb] | 18 | struct __stats_readyQ_pop_t {
|
---|
| 19 | // number of attemps at poping something
|
---|
| 20 | volatile uint64_t attempt;
|
---|
[69fbc61] | 21 |
|
---|
[d2fadeb] | 22 | // number of successes at poping
|
---|
| 23 | volatile uint64_t success;
|
---|
[8834751] | 24 |
|
---|
[d2fadeb] | 25 | // number of attempts failed due to the lock being held
|
---|
| 26 | volatile uint64_t elock;
|
---|
[52769ba] | 27 |
|
---|
[d2fadeb] | 28 | // number of attempts failed due to the queue being empty (lock held)
|
---|
| 29 | volatile uint64_t eempty;
|
---|
[52769ba] | 30 |
|
---|
[d2fadeb] | 31 | // number of attempts failed due to the queue looking empty (lock not held)
|
---|
| 32 | volatile uint64_t espec;
|
---|
| 33 | };
|
---|
[8834751] | 34 |
|
---|
[d2fadeb] | 35 | struct __attribute__((aligned(64))) __stats_readyQ_t {
|
---|
| 36 | // Push statistic
|
---|
| 37 | struct {
|
---|
[fd1f65e] | 38 | struct {
|
---|
[d2fadeb] | 39 | // number of attemps at pushing something to preferred queues
|
---|
[fd1f65e] | 40 | volatile uint64_t attempt;
|
---|
| 41 |
|
---|
[d2fadeb] | 42 | // number of successes at pushing to preferred queues
|
---|
[fd1f65e] | 43 | volatile uint64_t success;
|
---|
[d2fadeb] | 44 | }
|
---|
| 45 | // Stats for local queue within cluster
|
---|
| 46 | local,
|
---|
[fd1f65e] | 47 |
|
---|
[d2fadeb] | 48 | // Stats for non-local queues within cluster
|
---|
| 49 | share,
|
---|
[fd1f65e] | 50 |
|
---|
[d2fadeb] | 51 | // Stats from outside cluster
|
---|
| 52 | extrn;
|
---|
| 53 | } push;
|
---|
[fd1f65e] | 54 |
|
---|
[d2fadeb] | 55 | // Pop statistic
|
---|
| 56 | struct {
|
---|
| 57 | // pop from local queue
|
---|
| 58 | __stats_readyQ_pop_t local;
|
---|
[8834751] | 59 |
|
---|
[d2fadeb] | 60 | // pop before looking at local queue
|
---|
| 61 | __stats_readyQ_pop_t help;
|
---|
[8834751] | 62 |
|
---|
[d2fadeb] | 63 | // pop from some other queue
|
---|
| 64 | __stats_readyQ_pop_t steal;
|
---|
[52769ba] | 65 |
|
---|
[d2fadeb] | 66 | // pop when searching queues sequentially
|
---|
| 67 | __stats_readyQ_pop_t search;
|
---|
| 68 | } pop;
|
---|
[52769ba] | 69 |
|
---|
[29cb302] | 70 | struct {
|
---|
| 71 | volatile uint64_t migration;
|
---|
[ec43cf9] | 72 | volatile int64_t threads; // number of threads in the system, includes only local change
|
---|
[29cb302] | 73 | } threads;
|
---|
[68f36f4] | 74 | struct {
|
---|
| 75 | volatile uint64_t halts;
|
---|
| 76 | volatile uint64_t cancels;
|
---|
| 77 | volatile uint64_t wakes;
|
---|
| 78 | volatile uint64_t exits;
|
---|
| 79 | } sleep;
|
---|
[8834751] | 80 | };
|
---|
| 81 |
|
---|
[5751a56] | 82 | #if defined(CFA_HAVE_LINUX_IO_URING_H)
|
---|
[8834751] | 83 | struct __attribute__((aligned(64))) __stats_io_t{
|
---|
| 84 | struct {
|
---|
[d60d30e] | 85 | volatile uint64_t fast;
|
---|
| 86 | volatile uint64_t slow;
|
---|
| 87 | volatile uint64_t fail;
|
---|
| 88 | volatile uint64_t revoke;
|
---|
| 89 | volatile uint64_t block;
|
---|
| 90 | } alloc;
|
---|
[8834751] | 91 | struct {
|
---|
[d60d30e] | 92 | volatile uint64_t fast;
|
---|
| 93 | volatile uint64_t slow;
|
---|
| 94 | } submit;
|
---|
| 95 | struct {
|
---|
| 96 | volatile uint64_t external;
|
---|
| 97 | } flush;
|
---|
| 98 | struct {
|
---|
[dddb3dd0] | 99 | volatile uint64_t drain;
|
---|
[d60d30e] | 100 | volatile uint64_t completed;
|
---|
[dddb3dd0] | 101 | volatile uint64_t flush;
|
---|
| 102 | volatile uint64_t submitted;
|
---|
[d60d30e] | 103 | struct {
|
---|
| 104 | volatile uint64_t busy;
|
---|
| 105 | } errors;
|
---|
| 106 | } calls;
|
---|
[150d21a] | 107 | struct {
|
---|
| 108 | volatile uint64_t sleeps;
|
---|
| 109 | } poller;
|
---|
[8834751] | 110 | };
|
---|
| 111 | #endif
|
---|
| 112 |
|
---|
[73f4d08] | 113 | #if defined(CFA_STATS_ARRAY)
|
---|
| 114 | struct __stats_elem_t {
|
---|
| 115 | long long int ts;
|
---|
| 116 | int64_t value;
|
---|
| 117 | };
|
---|
| 118 | #endif
|
---|
| 119 |
|
---|
[37ba662] | 120 | struct __attribute__((aligned(128))) __stats_t {
|
---|
[d2fadeb] | 121 | __stats_readyQ_t ready;
|
---|
[5751a56] | 122 | #if defined(CFA_HAVE_LINUX_IO_URING_H)
|
---|
[8834751] | 123 | __stats_io_t io;
|
---|
| 124 | #endif
|
---|
[73f4d08] | 125 |
|
---|
| 126 | #if defined(CFA_STATS_ARRAY)
|
---|
| 127 | struct {
|
---|
| 128 | __stats_elem_t * values;
|
---|
| 129 | volatile size_t cnt;
|
---|
| 130 | } array;
|
---|
| 131 | #endif
|
---|
| 132 |
|
---|
[8834751] | 133 | };
|
---|
| 134 |
|
---|
| 135 | void __init_stats ( struct __stats_t * );
|
---|
| 136 | void __tally_stats( struct __stats_t *, struct __stats_t * );
|
---|
[1b033b8] | 137 | void __print_stats( struct __stats_t *, int, const char *, const char *, void * );
|
---|
[73f4d08] | 138 | #if defined(CFA_STATS_ARRAY)
|
---|
| 139 | void __push_stat ( struct __stats_t *, int64_t value, bool external, const char * name, void * handle);
|
---|
| 140 | void __flush_stat( struct __stats_t *, const char *, void * );
|
---|
| 141 | #else
|
---|
| 142 | static inline void __push_stat ( struct __stats_t *, int64_t, bool, const char *, void * ) {}
|
---|
| 143 | static inline void __flush_stat( struct __stats_t *, const char *, void * ) {}
|
---|
| 144 | #endif
|
---|
[8834751] | 145 | #endif
|
---|
| 146 |
|
---|