source: libcfa/src/concurrency/stats.hfa @ 6f6b844

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 6f6b844 was d2fadeb, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Changed stats to make sense with relaxed fifo and work stealing

  • Property mode set to 100644
File size: 3.5 KB
Line 
1#pragma once
2
3// #define CFA_STATS_ARRAY 10000
4
5#include <stdint.h>
6
7enum {
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        struct __stats_readyQ_pop_t {
19                // number of attemps at poping something
20                volatile uint64_t attempt;
21
22                // number of successes at poping
23                volatile uint64_t success;
24
25                // number of attempts failed due to the lock being held
26                volatile uint64_t elock;
27
28                // number of attempts failed due to the queue being empty (lock held)
29                volatile uint64_t eempty;
30
31                // number of attempts failed due to the queue looking empty (lock not held)
32                volatile uint64_t espec;
33        };
34
35        struct __attribute__((aligned(64))) __stats_readyQ_t {
36                // Push statistic
37                struct {
38                        struct {
39                                // number of attemps at pushing something to preferred queues
40                                volatile uint64_t attempt;
41
42                                // number of successes at pushing to preferred queues
43                                volatile uint64_t success;
44                        }
45                        // Stats for local queue within cluster
46                        local,
47
48                        // Stats for non-local queues within cluster
49                        share,
50
51                        // Stats from outside cluster
52                        extrn;
53                } push;
54
55                // Pop statistic
56                struct {
57                        // pop from local queue
58                        __stats_readyQ_pop_t local;
59
60                        // pop before looking at local queue
61                        __stats_readyQ_pop_t help;
62
63                        // pop from some other queue
64                        __stats_readyQ_pop_t steal;
65
66                        // pop when searching queues sequentially
67                        __stats_readyQ_pop_t search;
68                } pop;
69
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_readyQ_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
Note: See TracBrowser for help on using the repository browser.