source: libcfa/src/concurrency/stats.hfa @ 7cf3b1d

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since 7cf3b1d was 7cf3b1d, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Added level of indirection to idle sleeps which helps statistics.

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