1 | #pragma once |
---|
2 | |
---|
3 | // #define CFA_STATS_ARRAY 10000 |
---|
4 | |
---|
5 | #include <stdint.h> |
---|
6 | |
---|
7 | enum { |
---|
8 | CFA_STATS_READY_Q = 0x01, |
---|
9 | CFA_STATS_IO = 0x02, |
---|
10 | }; |
---|
11 | |
---|
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 * ) {} |
---|
16 | static inline void __print_stats( struct __stats_t *, int, const char *, const char *, void * ) {} |
---|
17 | #else |
---|
18 | |
---|
19 | struct __attribute__((aligned(64))) __stats_readQ_t { |
---|
20 | struct { |
---|
21 | // Push statistic |
---|
22 | struct { |
---|
23 | // number of attemps at pushing something |
---|
24 | volatile uint64_t attempt; |
---|
25 | |
---|
26 | // number of successes at pushing |
---|
27 | volatile uint64_t success; |
---|
28 | |
---|
29 | // number of attemps at pushing something to preferred queues |
---|
30 | volatile uint64_t local; |
---|
31 | |
---|
32 | // number of successes at pushing to preferred queues |
---|
33 | volatile uint64_t lsuccess; |
---|
34 | } push; |
---|
35 | |
---|
36 | struct { |
---|
37 | // number of attemps at pushing something |
---|
38 | volatile uint64_t attempt; |
---|
39 | |
---|
40 | // number of successes at pushing |
---|
41 | volatile uint64_t success; |
---|
42 | |
---|
43 | // number of attemps at pushing something to preferred queues |
---|
44 | volatile uint64_t local; |
---|
45 | |
---|
46 | // number of successes at pushing to preferred queues |
---|
47 | volatile uint64_t lsuccess; |
---|
48 | } ext; |
---|
49 | |
---|
50 | // Pop statistic |
---|
51 | struct { |
---|
52 | // number of reads of the mask |
---|
53 | // picking an empty __cfa_readyQ_mask_t counts here |
---|
54 | // but not as an attempt |
---|
55 | volatile uint64_t probe; |
---|
56 | |
---|
57 | // number of attemps at poping something |
---|
58 | volatile uint64_t attempt; |
---|
59 | |
---|
60 | // number of successes at poping |
---|
61 | volatile uint64_t success; |
---|
62 | |
---|
63 | // number of attemps at poping something to preferred queues |
---|
64 | volatile uint64_t local; |
---|
65 | |
---|
66 | // number of successes at poping to preferred queues |
---|
67 | volatile uint64_t lsuccess; |
---|
68 | } pop; |
---|
69 | } pick; |
---|
70 | struct { |
---|
71 | volatile uint64_t migration; |
---|
72 | volatile int64_t threads; // number of threads in the system, includes only local change |
---|
73 | } threads; |
---|
74 | struct { |
---|
75 | volatile uint64_t halts; |
---|
76 | volatile uint64_t cancels; |
---|
77 | volatile uint64_t wakes; |
---|
78 | volatile uint64_t exits; |
---|
79 | } sleep; |
---|
80 | }; |
---|
81 | |
---|
82 | #if defined(CFA_HAVE_LINUX_IO_URING_H) |
---|
83 | struct __attribute__((aligned(64))) __stats_io_t{ |
---|
84 | struct { |
---|
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; |
---|
91 | struct { |
---|
92 | volatile uint64_t fast; |
---|
93 | volatile uint64_t slow; |
---|
94 | } submit; |
---|
95 | struct { |
---|
96 | volatile uint64_t external; |
---|
97 | } flush; |
---|
98 | struct { |
---|
99 | volatile uint64_t drain; |
---|
100 | volatile uint64_t completed; |
---|
101 | volatile uint64_t flush; |
---|
102 | volatile uint64_t submitted; |
---|
103 | struct { |
---|
104 | volatile uint64_t busy; |
---|
105 | } errors; |
---|
106 | } calls; |
---|
107 | struct { |
---|
108 | volatile uint64_t sleeps; |
---|
109 | } poller; |
---|
110 | }; |
---|
111 | #endif |
---|
112 | |
---|
113 | #if defined(CFA_STATS_ARRAY) |
---|
114 | struct __stats_elem_t { |
---|
115 | long long int ts; |
---|
116 | int64_t value; |
---|
117 | }; |
---|
118 | #endif |
---|
119 | |
---|
120 | struct __attribute__((aligned(128))) __stats_t { |
---|
121 | __stats_readQ_t ready; |
---|
122 | #if defined(CFA_HAVE_LINUX_IO_URING_H) |
---|
123 | __stats_io_t io; |
---|
124 | #endif |
---|
125 | |
---|
126 | #if defined(CFA_STATS_ARRAY) |
---|
127 | struct { |
---|
128 | __stats_elem_t * values; |
---|
129 | volatile size_t cnt; |
---|
130 | } array; |
---|
131 | #endif |
---|
132 | |
---|
133 | }; |
---|
134 | |
---|
135 | void __init_stats ( struct __stats_t * ); |
---|
136 | void __tally_stats( struct __stats_t *, struct __stats_t * ); |
---|
137 | void __print_stats( struct __stats_t *, int, const char *, const char *, void * ); |
---|
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 |
---|
145 | #endif |
---|
146 | |
---|