source: libcfa/src/concurrency/stats.hfa@ c4072d8e

ADT ast-experimental pthread-emulation qualifiedEnum
Last change on this file since c4072d8e was 54c1196, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Added io helping stats

  • Property mode set to 100644
File size: 3.8 KB
Line 
1#pragma once
2
3// #define CFA_STATS_ARRAY 10000
4// #define __CFA_NO_STATISTICS__
5
6#include <stdint.h>
7
8enum {
9 CFA_STATS_READY_Q = 0x01,
10 CFA_STATS_IO = 0x02,
11};
12
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 * ) {}
17 static inline void __print_stats( struct __stats_t *, int, const char *, const char *, void * ) {}
18#else
19 struct __stats_readyQ_pop_t {
20 // number of attemps at poping something
21 volatile uint64_t attempt;
22
23 // number of successes at poping
24 volatile uint64_t success;
25 };
26
27 struct __attribute__((aligned(64))) __stats_readyQ_t {
28 // Push statistic
29 struct {
30 struct {
31 // number of attemps at pushing something to preferred queues
32 volatile uint64_t attempt;
33
34 // number of successes at pushing to preferred queues
35 volatile uint64_t success;
36 }
37 // Stats for local queue within cluster
38 local,
39
40 // Stats for non-local queues within cluster
41 share,
42
43 // Stats from outside cluster
44 extrn;
45 } push;
46
47 // Pop statistic
48 struct {
49 // pop from local queue
50 __stats_readyQ_pop_t local;
51
52 // pop before looking at local queue
53 __stats_readyQ_pop_t help;
54
55 // pop from some other queue
56 __stats_readyQ_pop_t steal;
57
58 // pop when searching queues sequentially
59 __stats_readyQ_pop_t search;
60 } pop;
61
62 struct {
63 volatile uint64_t migration;
64 volatile uint64_t extunpark;
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
67 struct {
68 volatile uint64_t yield;
69 volatile uint64_t rllfwd;
70 } preempt;
71 } threads;
72 struct {
73 volatile uint64_t halts;
74 volatile uint64_t cancels;
75 volatile uint64_t early;
76 volatile uint64_t wakes;
77 volatile uint64_t seen;
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 volatile uint64_t dirty;
98 volatile uint64_t full;
99 volatile uint64_t idle;
100 volatile uint64_t eager;
101 } flush;
102 struct {
103 volatile uint64_t drain;
104 volatile uint64_t completed;
105 volatile uint64_t locked;
106 volatile uint64_t helped;
107 volatile uint64_t flush;
108 volatile uint64_t submitted;
109 struct {
110 volatile uint64_t busy;
111 } errors;
112 } calls;
113 struct {
114 volatile uint64_t sleeps;
115 } poller;
116 struct {
117 volatile uint64_t sockread;
118 volatile uint64_t epllread;
119 volatile uint64_t sockwrite;
120 volatile uint64_t epllwrite;
121 } ops;
122 };
123 #endif
124
125 #if defined(CFA_STATS_ARRAY)
126 struct __stats_elem_t {
127 long long int ts;
128 int64_t value;
129 };
130 #endif
131
132 struct __attribute__((aligned(128))) __stats_t {
133 __stats_readyQ_t ready;
134 #if defined(CFA_HAVE_LINUX_IO_URING_H)
135 __stats_io_t io;
136 #endif
137
138 #if defined(CFA_STATS_ARRAY)
139 struct {
140 __stats_elem_t * values;
141 volatile size_t cnt;
142 } array;
143 #endif
144
145 };
146
147 void __init_stats ( struct __stats_t * );
148 void __tally_stats( struct __stats_t *, struct __stats_t * );
149 void __print_stats( struct __stats_t *, int, const char *, const char *, void * );
150 #if defined(CFA_STATS_ARRAY)
151 void __push_stat ( struct __stats_t *, int64_t value, bool external, const char * name, void * handle);
152 void __flush_stat( struct __stats_t *, const char *, void * );
153 #else
154 static inline void __push_stat ( struct __stats_t *, int64_t, bool, const char *, void * ) {}
155 static inline void __flush_stat( struct __stats_t *, const char *, void * ) {}
156 #endif
157#endif
158
Note: See TracBrowser for help on using the repository browser.