source: libcfa/src/concurrency/stats.hfa@ 34b2796

ADT arm-eh ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 34b2796 was 3bd4293, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Added stat for unparks that can migrate

  • 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 uint64_t extunpark;
73 volatile int64_t threads; // number of threads in the system, includes only local change
74 } threads;
75 struct {
76 volatile uint64_t halts;
77 volatile uint64_t cancels;
78 volatile uint64_t wakes;
79 volatile uint64_t exits;
80 } sleep;
81 };
82
83 #if defined(CFA_HAVE_LINUX_IO_URING_H)
84 struct __attribute__((aligned(64))) __stats_io_t{
85 struct {
86 volatile uint64_t fast;
87 volatile uint64_t slow;
88 volatile uint64_t fail;
89 volatile uint64_t revoke;
90 volatile uint64_t block;
91 } alloc;
92 struct {
93 volatile uint64_t fast;
94 volatile uint64_t slow;
95 } submit;
96 struct {
97 volatile uint64_t external;
98 } flush;
99 struct {
100 volatile uint64_t drain;
101 volatile uint64_t completed;
102 volatile uint64_t flush;
103 volatile uint64_t submitted;
104 struct {
105 volatile uint64_t busy;
106 } errors;
107 } calls;
108 struct {
109 volatile uint64_t sleeps;
110 } poller;
111 };
112 #endif
113
114 #if defined(CFA_STATS_ARRAY)
115 struct __stats_elem_t {
116 long long int ts;
117 int64_t value;
118 };
119 #endif
120
121 struct __attribute__((aligned(128))) __stats_t {
122 __stats_readyQ_t ready;
123 #if defined(CFA_HAVE_LINUX_IO_URING_H)
124 __stats_io_t io;
125 #endif
126
127 #if defined(CFA_STATS_ARRAY)
128 struct {
129 __stats_elem_t * values;
130 volatile size_t cnt;
131 } array;
132 #endif
133
134 };
135
136 void __init_stats ( struct __stats_t * );
137 void __tally_stats( struct __stats_t *, struct __stats_t * );
138 void __print_stats( struct __stats_t *, int, const char *, const char *, void * );
139 #if defined(CFA_STATS_ARRAY)
140 void __push_stat ( struct __stats_t *, int64_t value, bool external, const char * name, void * handle);
141 void __flush_stat( struct __stats_t *, const char *, void * );
142 #else
143 static inline void __push_stat ( struct __stats_t *, int64_t, bool, const char *, void * ) {}
144 static inline void __flush_stat( struct __stats_t *, const char *, void * ) {}
145 #endif
146#endif
147
Note: See TracBrowser for help on using the repository browser.