aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/debug/stats_data.h
blob: 51e1c5a53364190224a377702b9c86320ef76238 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * Copyright 2017 gRPC authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Automatically generated by tools/codegen/core/gen_stats_data.py
 */

#ifndef GRPC_CORE_LIB_DEBUG_STATS_DATA_H
#define GRPC_CORE_LIB_DEBUG_STATS_DATA_H

#include <inttypes.h>

typedef enum {
  GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED,
  GRPC_STATS_COUNTER_SERVER_CALLS_CREATED,
  GRPC_STATS_COUNTER_SYSCALL_WRITE,
  GRPC_STATS_COUNTER_SYSCALL_READ,
  GRPC_STATS_COUNTER_SYSCALL_POLL,
  GRPC_STATS_COUNTER_SYSCALL_WAIT,
  GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS,
  GRPC_STATS_COUNTER_COUNT
} grpc_stats_counters;
extern const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT];
typedef enum {
  GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
  GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,
  GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
  GRPC_STATS_HISTOGRAM_COUNT
} grpc_stats_histograms;
extern const char *grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT];
typedef enum {
  GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE_FIRST_SLOT = 0,
  GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE_BUCKETS = 64,
  GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE_FIRST_SLOT = 64,
  GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE_BUCKETS = 64,
  GRPC_STATS_HISTOGRAM_TCP_READ_SIZE_FIRST_SLOT = 128,
  GRPC_STATS_HISTOGRAM_TCP_READ_SIZE_BUCKETS = 64,
  GRPC_STATS_HISTOGRAM_BUCKETS = 192
} grpc_stats_histogram_constants;
#define GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx) \
  GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_CLIENT_CALLS_CREATED)
#define GRPC_STATS_INC_SERVER_CALLS_CREATED(exec_ctx) \
  GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SERVER_CALLS_CREATED)
#define GRPC_STATS_INC_SYSCALL_WRITE(exec_ctx) \
  GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WRITE)
#define GRPC_STATS_INC_SYSCALL_READ(exec_ctx) \
  GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_READ)
#define GRPC_STATS_INC_SYSCALL_POLL(exec_ctx) \
  GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_POLL)
#define GRPC_STATS_INC_SYSCALL_WAIT(exec_ctx) \
  GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WAIT)
#define GRPC_STATS_INC_HISTOGRAM_SLOW_LOOKUPS(exec_ctx) \
  GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS)
#define GRPC_STATS_INC_TCP_WRITE_SIZE(exec_ctx, value)                         \
  do {                                                                         \
    double _hist_val = (double)(value);                                        \
    if (_hist_val < 0) _hist_val = 0;                                          \
    uint64_t _hist_idx = *(uint64_t *)&_hist_val;                              \
    gpr_log(GPR_DEBUG, "tcp_write_size %lf %" PRId64 " %" PRId64, _hist_val,   \
            _hist_idx, 4715268809856909312ull);                                \
    if (_hist_val < 5.000000) {                                                \
      GRPC_STATS_INC_HISTOGRAM(                                                \
          (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, (int)_hist_val);    \
    } else {                                                                   \
      if (_hist_idx < 4715268809856909312ull) {                                \
        GRPC_STATS_INC_HISTOGRAM(                                              \
            (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,                   \
            grpc_stats_table_1[((_hist_idx - 4617315517961601024ull) >> 50)]); \
      } else {                                                                 \
        GRPC_STATS_INC_HISTOGRAM(                                              \
            (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,                   \
            grpc_stats_histo_find_bucket_slow((exec_ctx), (value),             \
                                              grpc_stats_table_0, 64));        \
      }                                                                        \
    }                                                                          \
  } while (false)
#define GRPC_STATS_INC_TCP_WRITE_IOV_SIZE(exec_ctx, value)                     \
  do {                                                                         \
    double _hist_val = (double)(value);                                        \
    if (_hist_val < 0) _hist_val = 0;                                          \
    uint64_t _hist_idx = *(uint64_t *)&_hist_val;                              \
    gpr_log(GPR_DEBUG, "tcp_write_iov_size %lf %" PRId64 " %" PRId64,          \
            _hist_val, _hist_idx, 4652218415073722368ull);                     \
    if (_hist_val < 12.000000) {                                               \
      GRPC_STATS_INC_HISTOGRAM((exec_ctx),                                     \
                               GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,        \
                               (int)_hist_val);                                \
    } else {                                                                   \
      if (_hist_idx < 4652218415073722368ull) {                                \
        GRPC_STATS_INC_HISTOGRAM(                                              \
            (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,               \
            grpc_stats_table_3[((_hist_idx - 4622945017495814144ull) >> 49)]); \
      } else {                                                                 \
        GRPC_STATS_INC_HISTOGRAM(                                              \
            (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,               \
            grpc_stats_histo_find_bucket_slow((exec_ctx), (value),             \
                                              grpc_stats_table_2, 64));        \
      }                                                                        \
    }                                                                          \
  } while (false)
#define GRPC_STATS_INC_TCP_READ_SIZE(exec_ctx, value)                          \
  do {                                                                         \
    double _hist_val = (double)(value);                                        \
    if (_hist_val < 0) _hist_val = 0;                                          \
    uint64_t _hist_idx = *(uint64_t *)&_hist_val;                              \
    gpr_log(GPR_DEBUG, "tcp_read_size %lf %" PRId64 " %" PRId64, _hist_val,    \
            _hist_idx, 4715268809856909312ull);                                \
    if (_hist_val < 5.000000) {                                                \
      GRPC_STATS_INC_HISTOGRAM((exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, \
                               (int)_hist_val);                                \
    } else {                                                                   \
      if (_hist_idx < 4715268809856909312ull) {                                \
        GRPC_STATS_INC_HISTOGRAM(                                              \
            (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,                    \
            grpc_stats_table_1[((_hist_idx - 4617315517961601024ull) >> 50)]); \
      } else {                                                                 \
        GRPC_STATS_INC_HISTOGRAM(                                              \
            (exec_ctx), GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,                    \
            grpc_stats_histo_find_bucket_slow((exec_ctx), (value),             \
                                              grpc_stats_table_0, 64));        \
      }                                                                        \
    }                                                                          \
  } while (false)
extern const double grpc_stats_table_0[64];
extern const uint8_t grpc_stats_table_1[87];
extern const double grpc_stats_table_2[64];
extern const uint8_t grpc_stats_table_3[52];
extern const int grpc_stats_histo_buckets[3];
extern const int grpc_stats_histo_start[3];
extern const double *const grpc_stats_histo_bucket_boundaries[3];

#endif /* GRPC_CORE_LIB_DEBUG_STATS_DATA_H */