blob: 2cf13190adcac4c6c184ef761dc917dec744cf43 [file] [log] [blame]
Craig Tiller28086682017-07-18 14:22:19 -07001/*
2 * Copyright 2017 gRPC authors.
Craig Tiller640dfe42017-08-30 13:34:49 -07003 *
Craig Tiller28086682017-07-18 14:22:19 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Craig Tiller640dfe42017-08-30 13:34:49 -07007 *
Craig Tiller28086682017-07-18 14:22:19 -07008 * http://www.apache.org/licenses/LICENSE-2.0
Craig Tiller640dfe42017-08-30 13:34:49 -07009 *
Craig Tiller28086682017-07-18 14:22:19 -070010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * Automatically generated by tools/codegen/core/gen_stats_data.py
19 */
20
21#ifndef GRPC_CORE_LIB_DEBUG_STATS_DATA_H
22#define GRPC_CORE_LIB_DEBUG_STATS_DATA_H
23
Craig Tiller640dfe42017-08-30 13:34:49 -070024#include <inttypes.h>
25
Craig Tiller28086682017-07-18 14:22:19 -070026typedef enum {
27 GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED,
28 GRPC_STATS_COUNTER_SERVER_CALLS_CREATED,
Craig Tillerb4bb1cd2017-07-20 14:18:17 -070029 GRPC_STATS_COUNTER_SYSCALL_WRITE,
30 GRPC_STATS_COUNTER_SYSCALL_READ,
31 GRPC_STATS_COUNTER_SYSCALL_POLL,
32 GRPC_STATS_COUNTER_SYSCALL_WAIT,
Craig Tiller640dfe42017-08-30 13:34:49 -070033 GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS,
Craig Tiller28086682017-07-18 14:22:19 -070034 GRPC_STATS_COUNTER_COUNT
35} grpc_stats_counters;
Craig Tiller640dfe42017-08-30 13:34:49 -070036extern const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT];
Craig Tiller33aeaba2017-07-20 16:02:24 -070037typedef enum {
38 GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
Craig Tiller640dfe42017-08-30 13:34:49 -070039 GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,
Craig Tiller33aeaba2017-07-20 16:02:24 -070040 GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
41 GRPC_STATS_HISTOGRAM_CLIENT_LATENCY,
42 GRPC_STATS_HISTOGRAM_COUNT
43} grpc_stats_histograms;
Craig Tiller640dfe42017-08-30 13:34:49 -070044extern const char *grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT];
45typedef enum {
46 GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE_FIRST_SLOT = 0,
47 GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE_BUCKETS = 64,
48 GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE_FIRST_SLOT = 64,
49 GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE_BUCKETS = 64,
50 GRPC_STATS_HISTOGRAM_TCP_READ_SIZE_FIRST_SLOT = 128,
51 GRPC_STATS_HISTOGRAM_TCP_READ_SIZE_BUCKETS = 64,
52 GRPC_STATS_HISTOGRAM_CLIENT_LATENCY_FIRST_SLOT = 192,
53 GRPC_STATS_HISTOGRAM_CLIENT_LATENCY_BUCKETS = 128,
54 GRPC_STATS_HISTOGRAM_BUCKETS = 320
55} grpc_stats_histogram_constants;
56#define GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx) \
57 GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED)
58#define GRPC_STATS_INC_SERVER_CALLS_CREATED(exec_ctx) \
59 GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_CALLS_CREATED)
60#define GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx) \
61 GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WRITE)
62#define GRPC_STATS_INC_SYSCALL_READ(exec_ctx) \
63 GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_READ)
64#define GRPC_STATS_INC_SYSCALL_POLL(exec_ctx) \
65 GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_POLL)
66#define GRPC_STATS_INC_SYSCALL_WAIT(exec_ctx) \
67 GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WAIT)
68#define GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS(exec_ctx) \
69 GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS)
70#define GRPC_STATS_INC_TCP_WRITE_SIZE(exec_ctx, value) \
71 do { \
72 double _hist_val = (double)(value); \
73 if (_hist_val < 0) _hist_val = 0; \
74 uint64_t _hist_idx = *(uint64_t *)&_hist_val; \
75 gpr_log(GPR_DEBUG, "tcp_write_size %lf %" PRId64 " %" PRId64, _hist_val, \
76 _hist_idx, 4715268809856909312ull); \
77 if (_hist_val < 5.000000) { \
78 GRPC_STATS_INC_HISTOGRAM( \
79 (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, (int)_hist_val); \
80 } else { \
81 if (_hist_idx < 4715268809856909312ull) { \
82 GRPC_STATS_INC_HISTOGRAM( \
83 (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, \
84 grpc_stats_table_1[((_hist_idx - 4617315517961601024ull) >> 50)]); \
85 } else { \
86 GRPC_STATS_INC_HISTOGRAM( \
87 (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, \
88 grpc_stats_histo_find_bucket_slow((exec_ctx), (value), \
89 grpc_stats_table_0, 64)); \
90 } \
91 } \
92 } while (false)
93#define GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(exec_ctx, value) \
94 do { \
95 double _hist_val = (double)(value); \
96 if (_hist_val < 0) _hist_val = 0; \
97 uint64_t _hist_idx = *(uint64_t *)&_hist_val; \
98 gpr_log(GPR_DEBUG, "tcp_write_iov_size %lf %" PRId64 " %" PRId64, \
99 _hist_val, _hist_idx, 4652218415073722368ull); \
100 if (_hist_val < 12.000000) { \
101 GRPC_STATS_INC_HISTOGRAM((exec_ctx), \
102 GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, \
103 (int)_hist_val); \
104 } else { \
105 if (_hist_idx < 4652218415073722368ull) { \
106 GRPC_STATS_INC_HISTOGRAM( \
107 (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, \
108 grpc_stats_table_3[((_hist_idx - 4622945017495814144ull) >> 49)]); \
109 } else { \
110 GRPC_STATS_INC_HISTOGRAM( \
111 (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, \
112 grpc_stats_histo_find_bucket_slow((exec_ctx), (value), \
113 grpc_stats_table_2, 64)); \
114 } \
115 } \
116 } while (false)
117#define GRPC_STATS_INC_TCP_READ_SIZE(exec_ctx, value) \
118 do { \
119 double _hist_val = (double)(value); \
120 if (_hist_val < 0) _hist_val = 0; \
121 uint64_t _hist_idx = *(uint64_t *)&_hist_val; \
122 gpr_log(GPR_DEBUG, "tcp_read_size %lf %" PRId64 " %" PRId64, _hist_val, \
123 _hist_idx, 4715268809856909312ull); \
124 if (_hist_val < 5.000000) { \
125 GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, \
126 (int)_hist_val); \
127 } else { \
128 if (_hist_idx < 4715268809856909312ull) { \
129 GRPC_STATS_INC_HISTOGRAM( \
130 (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, \
131 grpc_stats_table_1[((_hist_idx - 4617315517961601024ull) >> 50)]); \
132 } else { \
133 GRPC_STATS_INC_HISTOGRAM( \
134 (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, \
135 grpc_stats_histo_find_bucket_slow((exec_ctx), (value), \
136 grpc_stats_table_0, 64)); \
137 } \
138 } \
139 } while (false)
140#define GRPC_STATS_INC_CLIENT_LATENCY(exec_ctx, value) \
141 do { \
142 double _hist_val = (double)(value); \
143 if (_hist_val < 0) _hist_val = 0; \
144 uint64_t _hist_idx = *(uint64_t *)&_hist_val; \
145 gpr_log(GPR_DEBUG, "client_latency %lf %" PRId64 " %" PRId64, _hist_val, \
146 _hist_idx, 4767623155525091328ull); \
147 if (_hist_val < 6.000000) { \
148 GRPC_STATS_INC_HISTOGRAM( \
149 (exec_ctx), GRPC_STATS_HISTOGRAM_CLIENT_LATENCY, (int)_hist_val); \
150 } else { \
151 if (_hist_idx < 4767623155525091328ull) { \
152 GRPC_STATS_INC_HISTOGRAM( \
153 (exec_ctx), GRPC_STATS_HISTOGRAM_CLIENT_LATENCY, \
154 grpc_stats_table_5[((_hist_idx - 4618441417868443648ull) >> 49)]); \
155 } else { \
156 GRPC_STATS_INC_HISTOGRAM( \
157 (exec_ctx), GRPC_STATS_HISTOGRAM_CLIENT_LATENCY, \
158 grpc_stats_histo_find_bucket_slow((exec_ctx), (value), \
159 grpc_stats_table_4, 128)); \
160 } \
161 } \
162 } while (false)
163extern const double grpc_stats_table_0[64];
164extern const uint8_t grpc_stats_table_1[87];
165extern const double grpc_stats_table_2[64];
166extern const uint8_t grpc_stats_table_3[52];
167extern const double grpc_stats_table_4[128];
168extern const uint16_t grpc_stats_table_5[265];
169extern const int grpc_stats_histo_buckets[4];
170extern const int grpc_stats_histo_start[4];
171extern const double *const grpc_stats_histo_bucket_boundaries[4];
Craig Tiller28086682017-07-18 14:22:19 -0700172
173#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */