• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 gRPC authors.
3  *
4  * 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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * 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 #include <grpc/support/port_platform.h>
22 
23 #include "src/core/lib/debug/stats.h"
24 #include "src/core/lib/debug/stats_data.h"
25 #include "src/core/lib/gpr/useful.h"
26 #include "src/core/lib/iomgr/exec_ctx.h"
27 
28 const char* grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = {
29     "client_calls_created",
30     "server_calls_created",
31     "cqs_created",
32     "client_channels_created",
33     "client_subchannels_created",
34     "server_channels_created",
35     "syscall_poll",
36     "syscall_wait",
37     "pollset_kick",
38     "pollset_kicked_without_poller",
39     "pollset_kicked_again",
40     "pollset_kick_wakeup_fd",
41     "pollset_kick_wakeup_cv",
42     "pollset_kick_own_thread",
43     "syscall_epoll_ctl",
44     "pollset_fd_cache_hits",
45     "histogram_slow_lookups",
46     "syscall_write",
47     "syscall_read",
48     "tcp_backup_pollers_created",
49     "tcp_backup_poller_polls",
50     "http2_op_batches",
51     "http2_op_cancel",
52     "http2_op_send_initial_metadata",
53     "http2_op_send_message",
54     "http2_op_send_trailing_metadata",
55     "http2_op_recv_initial_metadata",
56     "http2_op_recv_message",
57     "http2_op_recv_trailing_metadata",
58     "http2_settings_writes",
59     "http2_pings_sent",
60     "http2_writes_begun",
61     "http2_writes_offloaded",
62     "http2_writes_continued",
63     "http2_partial_writes",
64     "http2_initiate_write_due_to_initial_write",
65     "http2_initiate_write_due_to_start_new_stream",
66     "http2_initiate_write_due_to_send_message",
67     "http2_initiate_write_due_to_send_initial_metadata",
68     "http2_initiate_write_due_to_send_trailing_metadata",
69     "http2_initiate_write_due_to_retry_send_ping",
70     "http2_initiate_write_due_to_continue_pings",
71     "http2_initiate_write_due_to_goaway_sent",
72     "http2_initiate_write_due_to_rst_stream",
73     "http2_initiate_write_due_to_close_from_api",
74     "http2_initiate_write_due_to_stream_flow_control",
75     "http2_initiate_write_due_to_transport_flow_control",
76     "http2_initiate_write_due_to_send_settings",
77     "http2_initiate_write_due_to_bdp_estimator_ping",
78     "http2_initiate_write_due_to_flow_control_unstalled_by_setting",
79     "http2_initiate_write_due_to_flow_control_unstalled_by_update",
80     "http2_initiate_write_due_to_application_ping",
81     "http2_initiate_write_due_to_keepalive_ping",
82     "http2_initiate_write_due_to_transport_flow_control_unstalled",
83     "http2_initiate_write_due_to_ping_response",
84     "http2_initiate_write_due_to_force_rst_stream",
85     "http2_spurious_writes_begun",
86     "hpack_recv_indexed",
87     "hpack_recv_lithdr_incidx",
88     "hpack_recv_lithdr_incidx_v",
89     "hpack_recv_lithdr_notidx",
90     "hpack_recv_lithdr_notidx_v",
91     "hpack_recv_lithdr_nvridx",
92     "hpack_recv_lithdr_nvridx_v",
93     "hpack_recv_uncompressed",
94     "hpack_recv_huffman",
95     "hpack_recv_binary",
96     "hpack_recv_binary_base64",
97     "hpack_send_indexed",
98     "hpack_send_lithdr_incidx",
99     "hpack_send_lithdr_incidx_v",
100     "hpack_send_lithdr_notidx",
101     "hpack_send_lithdr_notidx_v",
102     "hpack_send_lithdr_nvridx",
103     "hpack_send_lithdr_nvridx_v",
104     "hpack_send_uncompressed",
105     "hpack_send_huffman",
106     "hpack_send_binary",
107     "hpack_send_binary_base64",
108     "combiner_locks_initiated",
109     "combiner_locks_scheduled_items",
110     "combiner_locks_scheduled_final_items",
111     "combiner_locks_offloaded",
112     "call_combiner_locks_initiated",
113     "call_combiner_locks_scheduled_items",
114     "call_combiner_set_notify_on_cancel",
115     "call_combiner_cancelled",
116     "executor_scheduled_short_items",
117     "executor_scheduled_long_items",
118     "executor_scheduled_to_self",
119     "executor_wakeup_initiated",
120     "executor_queue_drained",
121     "executor_push_retries",
122     "server_requested_calls",
123     "server_slowpath_requests_queued",
124     "cq_ev_queue_trylock_failures",
125     "cq_ev_queue_trylock_successes",
126     "cq_ev_queue_transient_pop_failures",
127 };
128 const char* grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
129     "Number of client side calls created by this process",
130     "Number of server side calls created by this process",
131     "Number of completion queues created",
132     "Number of client channels created",
133     "Number of client subchannels created",
134     "Number of server channels created",
135     "Number of polling syscalls (epoll_wait, poll, etc) made by this process",
136     "Number of sleeping syscalls made by this process",
137     "How many polling wakeups were performed by the process (only valid for "
138     "epoll1 right now)",
139     "How many times was a polling wakeup requested without an active poller "
140     "(only valid for epoll1 right now)",
141     "How many times was the same polling worker awoken repeatedly before "
142     "waking up (only valid for epoll1 right now)",
143     "How many times was an eventfd used as the wakeup vector for a polling "
144     "wakeup (only valid for epoll1 right now)",
145     "How many times was a condition variable used as the wakeup vector for a "
146     "polling wakeup (only valid for epoll1 right now)",
147     "How many times could a polling wakeup be satisfied by keeping the waking "
148     "thread awake? (only valid for epoll1 right now)",
149     "Number of epoll_ctl calls made (only valid for epollex right now)",
150     "Number of epoll_ctl calls skipped because the fd was cached as already "
151     "being added.  (only valid for epollex right now)",
152     "Number of times histogram increments went through the slow (binary "
153     "search) path",
154     "Number of write syscalls (or equivalent - eg sendmsg) made by this "
155     "process",
156     "Number of read syscalls (or equivalent - eg recvmsg) made by this process",
157     "Number of times a backup poller has been created (this can be expensive)",
158     "Number of polls performed on the backup poller",
159     "Number of batches received by HTTP2 transport",
160     "Number of cancelations received by HTTP2 transport",
161     "Number of batches containing send initial metadata",
162     "Number of batches containing send message",
163     "Number of batches containing send trailing metadata",
164     "Number of batches containing receive initial metadata",
165     "Number of batches containing receive message",
166     "Number of batches containing receive trailing metadata",
167     "Number of settings frames sent",
168     "Number of HTTP2 pings sent by process",
169     "Number of HTTP2 writes initiated",
170     "Number of HTTP2 writes offloaded to the executor from application threads",
171     "Number of HTTP2 writes that finished seeing more data needed to be "
172     "written",
173     "Number of HTTP2 writes that were made knowing there was still more data "
174     "to be written (we cap maximum write size to syscall_write)",
175     "Number of HTTP2 writes initiated due to 'initial_write'",
176     "Number of HTTP2 writes initiated due to 'start_new_stream'",
177     "Number of HTTP2 writes initiated due to 'send_message'",
178     "Number of HTTP2 writes initiated due to 'send_initial_metadata'",
179     "Number of HTTP2 writes initiated due to 'send_trailing_metadata'",
180     "Number of HTTP2 writes initiated due to 'retry_send_ping'",
181     "Number of HTTP2 writes initiated due to 'continue_pings'",
182     "Number of HTTP2 writes initiated due to 'goaway_sent'",
183     "Number of HTTP2 writes initiated due to 'rst_stream'",
184     "Number of HTTP2 writes initiated due to 'close_from_api'",
185     "Number of HTTP2 writes initiated due to 'stream_flow_control'",
186     "Number of HTTP2 writes initiated due to 'transport_flow_control'",
187     "Number of HTTP2 writes initiated due to 'send_settings'",
188     "Number of HTTP2 writes initiated due to 'bdp_estimator_ping'",
189     "Number of HTTP2 writes initiated due to "
190     "'flow_control_unstalled_by_setting'",
191     "Number of HTTP2 writes initiated due to "
192     "'flow_control_unstalled_by_update'",
193     "Number of HTTP2 writes initiated due to 'application_ping'",
194     "Number of HTTP2 writes initiated due to 'keepalive_ping'",
195     "Number of HTTP2 writes initiated due to "
196     "'transport_flow_control_unstalled'",
197     "Number of HTTP2 writes initiated due to 'ping_response'",
198     "Number of HTTP2 writes initiated due to 'force_rst_stream'",
199     "Number of HTTP2 writes initiated with nothing to write",
200     "Number of HPACK indexed fields received",
201     "Number of HPACK literal headers received with incremental indexing",
202     "Number of HPACK literal headers received with incremental indexing and "
203     "literal keys",
204     "Number of HPACK literal headers received with no indexing",
205     "Number of HPACK literal headers received with no indexing and literal "
206     "keys",
207     "Number of HPACK literal headers received with never-indexing",
208     "Number of HPACK literal headers received with never-indexing and literal "
209     "keys",
210     "Number of uncompressed strings received in metadata",
211     "Number of huffman encoded strings received in metadata",
212     "Number of binary strings received in metadata",
213     "Number of binary strings received encoded in base64 in metadata",
214     "Number of HPACK indexed fields sent",
215     "Number of HPACK literal headers sent with incremental indexing",
216     "Number of HPACK literal headers sent with incremental indexing and "
217     "literal keys",
218     "Number of HPACK literal headers sent with no indexing",
219     "Number of HPACK literal headers sent with no indexing and literal keys",
220     "Number of HPACK literal headers sent with never-indexing",
221     "Number of HPACK literal headers sent with never-indexing and literal keys",
222     "Number of uncompressed strings sent in metadata",
223     "Number of huffman encoded strings sent in metadata",
224     "Number of binary strings received in metadata",
225     "Number of binary strings received encoded in base64 in metadata",
226     "Number of combiner lock entries by process (first items queued to a "
227     "combiner)",
228     "Number of items scheduled against combiner locks",
229     "Number of final items scheduled against combiner locks",
230     "Number of combiner locks offloaded to different threads",
231     "Number of call combiner lock entries by process (first items queued to a "
232     "call combiner)",
233     "Number of items scheduled against call combiner locks",
234     "Number of times a cancellation callback was set on a call combiner",
235     "Number of times a call combiner was cancelled",
236     "Number of finite runtime closures scheduled against the executor (gRPC "
237     "thread pool)",
238     "Number of potentially infinite runtime closures scheduled against the "
239     "executor (gRPC thread pool)",
240     "Number of closures scheduled by the executor to the executor",
241     "Number of thread wakeups initiated within the executor",
242     "Number of times an executor queue was drained",
243     "Number of times we raced and were forced to retry pushing a closure to "
244     "the executor",
245     "How many calls were requested (not necessarily received) by the server",
246     "How many times was the server slow path taken (indicates too few "
247     "outstanding requests)",
248     "Number of lock (trylock) acquisition failures on completion queue event "
249     "queue. High value here indicates high contention on completion queues",
250     "Number of lock (trylock) acquisition successes on completion queue event "
251     "queue.",
252     "Number of times NULL was popped out of completion queue's event queue "
253     "even though the event queue was not empty",
254 };
255 const char* grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT] = {
256     "call_initial_size",
257     "poll_events_returned",
258     "tcp_write_size",
259     "tcp_write_iov_size",
260     "tcp_read_size",
261     "tcp_read_offer",
262     "tcp_read_offer_iov_size",
263     "http2_send_message_size",
264     "http2_send_initial_metadata_per_write",
265     "http2_send_message_per_write",
266     "http2_send_trailing_metadata_per_write",
267     "http2_send_flowctl_per_write",
268     "server_cqs_checked",
269 };
270 const char* grpc_stats_histogram_doc[GRPC_STATS_HISTOGRAM_COUNT] = {
271     "Initial size of the grpc_call arena created at call start",
272     "How many events are called for each syscall_poll",
273     "Number of bytes offered to each syscall_write",
274     "Number of byte segments offered to each syscall_write",
275     "Number of bytes received by each syscall_read",
276     "Number of bytes offered to each syscall_read",
277     "Number of byte segments offered to each syscall_read",
278     "Size of messages received by HTTP2 transport",
279     "Number of streams initiated written per TCP write",
280     "Number of streams whose payload was written per TCP write",
281     "Number of streams terminated per TCP write",
282     "Number of flow control updates written per TCP write",
283     "How many completion queues were checked looking for a CQ that had "
284     "requested the incoming call",
285 };
286 const int grpc_stats_table_0[65] = {
287     0,      1,      2,      3,      4,     5,     7,     9,     11,    14,
288     17,     21,     26,     32,     39,    47,    57,    68,    82,    98,
289     117,    140,    167,    199,    238,   284,   339,   404,   482,   575,
290     685,    816,    972,    1158,   1380,  1644,  1959,  2334,  2780,  3312,
291     3945,   4699,   5597,   6667,   7941,  9459,  11267, 13420, 15984, 19038,
292     22676,  27009,  32169,  38315,  45635, 54353, 64737, 77104, 91834, 109378,
293     130273, 155159, 184799, 220100, 262144};
294 const uint8_t grpc_stats_table_1[124] = {
295     0,  0,  0,  1,  1,  1,  2,  2,  3,  3,  3,  4,  4,  5,  5,  6,  6,  6,
296     7,  7,  7,  8,  9,  9,  10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15,
297     15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 22, 23, 24,
298     24, 25, 25, 26, 26, 26, 27, 27, 28, 29, 29, 30, 30, 30, 31, 31, 32, 33,
299     33, 34, 34, 34, 35, 35, 36, 37, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41,
300     42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50,
301     51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58};
302 const int grpc_stats_table_2[129] = {
303     0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
304     15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  30,
305     32,  34,  36,  38,  40,  42,  44,  46,  48,  50,  52,  54,  56,  58,  60,
306     63,  66,  69,  72,  75,  78,  81,  84,  87,  90,  94,  98,  102, 106, 110,
307     114, 118, 122, 126, 131, 136, 141, 146, 151, 156, 162, 168, 174, 180, 186,
308     192, 199, 206, 213, 220, 228, 236, 244, 252, 260, 269, 278, 287, 297, 307,
309     317, 327, 338, 349, 360, 372, 384, 396, 409, 422, 436, 450, 464, 479, 494,
310     510, 526, 543, 560, 578, 596, 615, 634, 654, 674, 695, 717, 739, 762, 785,
311     809, 834, 859, 885, 912, 939, 967, 996, 1024};
312 const uint8_t grpc_stats_table_3[166] = {
313     0,  0,  0,  1,  1,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,  7,  7,
314     8,  8,  9,  9,  10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 16,
315     17, 17, 18, 19, 19, 20, 21, 21, 22, 23, 23, 24, 25, 25, 26, 26, 27, 27, 28,
316     28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 36, 36, 37, 38, 39,
317     40, 40, 41, 42, 42, 43, 44, 44, 45, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51,
318     51, 52, 52, 53, 53, 54, 54, 55, 56, 57, 58, 59, 59, 60, 61, 62, 63, 63, 64,
319     65, 65, 66, 67, 67, 68, 69, 69, 70, 71, 71, 72, 72, 73, 73, 74, 75, 75, 76,
320     76, 77, 78, 79, 79, 80, 81, 82, 83, 84, 85, 85, 86, 87, 88, 88, 89, 90, 90,
321     91, 92, 92, 93, 94, 94, 95, 95, 96, 97, 97, 98, 98, 99};
322 const int grpc_stats_table_4[65] = {
323     0,       1,       2,       3,       4,       6,       8,        11,
324     15,      20,      26,      34,      44,      57,      73,       94,
325     121,     155,     199,     255,     327,     419,     537,      688,
326     881,     1128,    1444,    1848,    2365,    3026,    3872,     4954,
327     6338,    8108,    10373,   13270,   16976,   21717,   27782,    35541,
328     45467,   58165,   74409,   95189,   121772,  155778,  199281,   254933,
329     326126,  417200,  533707,  682750,  873414,  1117323, 1429345,  1828502,
330     2339127, 2992348, 3827987, 4896985, 6264509, 8013925, 10251880, 13114801,
331     16777216};
332 const uint8_t grpc_stats_table_5[87] = {
333     0,  0,  1,  1,  2,  3,  3,  4,  4,  5,  6,  6,  7,  8,  8,  9,  10, 11,
334     11, 12, 13, 13, 14, 15, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 22, 23,
335     24, 25, 25, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35, 36,
336     36, 37, 38, 39, 39, 40, 41, 41, 42, 43, 44, 44, 45, 45, 46, 47, 48, 48,
337     49, 50, 51, 51, 52, 53, 53, 54, 55, 56, 56, 57, 58, 58, 59};
338 const int grpc_stats_table_6[65] = {
339     0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,
340     14,  16,  18,  20,  22,  24,  27,  30,  33,  36,  39,  43,  47,
341     51,  56,  61,  66,  72,  78,  85,  92,  100, 109, 118, 128, 139,
342     151, 164, 178, 193, 209, 226, 244, 264, 285, 308, 333, 359, 387,
343     418, 451, 486, 524, 565, 609, 656, 707, 762, 821, 884, 952, 1024};
344 const uint8_t grpc_stats_table_7[102] = {
345     0,  0,  0,  1,  1,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,
346     6,  7,  7,  7,  8,  8,  9,  9,  10, 11, 11, 12, 12, 13, 13, 14, 14,
347     14, 15, 15, 16, 16, 17, 17, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23,
348     23, 24, 24, 24, 25, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32,
349     32, 33, 33, 34, 35, 35, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41,
350     42, 42, 43, 44, 44, 45, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51, 51};
351 const int grpc_stats_table_8[9] = {0, 1, 2, 4, 7, 13, 23, 39, 64};
352 const uint8_t grpc_stats_table_9[9] = {0, 0, 1, 2, 2, 3, 4, 4, 5};
grpc_stats_inc_call_initial_size(int value)353 void grpc_stats_inc_call_initial_size(int value) {
354   value = GPR_CLAMP(value, 0, 262144);
355   if (value < 6) {
356     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE, value);
357     return;
358   }
359   union {
360     double dbl;
361     uint64_t uint;
362   } _val, _bkt;
363   _val.dbl = value;
364   if (_val.uint < 4651092515166879744ull) {
365     int bucket =
366         grpc_stats_table_1[((_val.uint - 4618441417868443648ull) >> 49)] + 6;
367     _bkt.dbl = grpc_stats_table_0[bucket];
368     bucket -= (_val.uint < _bkt.uint);
369     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE, bucket);
370     return;
371   }
372   GRPC_STATS_INC_HISTOGRAM(
373       GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
374       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_0, 64));
375 }
grpc_stats_inc_poll_events_returned(int value)376 void grpc_stats_inc_poll_events_returned(int value) {
377   value = GPR_CLAMP(value, 0, 1024);
378   if (value < 29) {
379     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, value);
380     return;
381   }
382   union {
383     double dbl;
384     uint64_t uint;
385   } _val, _bkt;
386   _val.dbl = value;
387   if (_val.uint < 4642789003353915392ull) {
388     int bucket =
389         grpc_stats_table_3[((_val.uint - 4628855992006737920ull) >> 47)] + 29;
390     _bkt.dbl = grpc_stats_table_2[bucket];
391     bucket -= (_val.uint < _bkt.uint);
392     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, bucket);
393     return;
394   }
395   GRPC_STATS_INC_HISTOGRAM(
396       GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED,
397       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_2, 128));
398 }
grpc_stats_inc_tcp_write_size(int value)399 void grpc_stats_inc_tcp_write_size(int value) {
400   value = GPR_CLAMP(value, 0, 16777216);
401   if (value < 5) {
402     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, value);
403     return;
404   }
405   union {
406     double dbl;
407     uint64_t uint;
408   } _val, _bkt;
409   _val.dbl = value;
410   if (_val.uint < 4683743612465315840ull) {
411     int bucket =
412         grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
413     _bkt.dbl = grpc_stats_table_4[bucket];
414     bucket -= (_val.uint < _bkt.uint);
415     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, bucket);
416     return;
417   }
418   GRPC_STATS_INC_HISTOGRAM(
419       GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
420       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
421 }
grpc_stats_inc_tcp_write_iov_size(int value)422 void grpc_stats_inc_tcp_write_iov_size(int value) {
423   value = GPR_CLAMP(value, 0, 1024);
424   if (value < 13) {
425     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, value);
426     return;
427   }
428   union {
429     double dbl;
430     uint64_t uint;
431   } _val, _bkt;
432   _val.dbl = value;
433   if (_val.uint < 4637863191261478912ull) {
434     int bucket =
435         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
436     _bkt.dbl = grpc_stats_table_6[bucket];
437     bucket -= (_val.uint < _bkt.uint);
438     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, bucket);
439     return;
440   }
441   GRPC_STATS_INC_HISTOGRAM(
442       GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,
443       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
444 }
grpc_stats_inc_tcp_read_size(int value)445 void grpc_stats_inc_tcp_read_size(int value) {
446   value = GPR_CLAMP(value, 0, 16777216);
447   if (value < 5) {
448     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, value);
449     return;
450   }
451   union {
452     double dbl;
453     uint64_t uint;
454   } _val, _bkt;
455   _val.dbl = value;
456   if (_val.uint < 4683743612465315840ull) {
457     int bucket =
458         grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
459     _bkt.dbl = grpc_stats_table_4[bucket];
460     bucket -= (_val.uint < _bkt.uint);
461     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, bucket);
462     return;
463   }
464   GRPC_STATS_INC_HISTOGRAM(
465       GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
466       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
467 }
grpc_stats_inc_tcp_read_offer(int value)468 void grpc_stats_inc_tcp_read_offer(int value) {
469   value = GPR_CLAMP(value, 0, 16777216);
470   if (value < 5) {
471     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER, value);
472     return;
473   }
474   union {
475     double dbl;
476     uint64_t uint;
477   } _val, _bkt;
478   _val.dbl = value;
479   if (_val.uint < 4683743612465315840ull) {
480     int bucket =
481         grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
482     _bkt.dbl = grpc_stats_table_4[bucket];
483     bucket -= (_val.uint < _bkt.uint);
484     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER, bucket);
485     return;
486   }
487   GRPC_STATS_INC_HISTOGRAM(
488       GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
489       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
490 }
grpc_stats_inc_tcp_read_offer_iov_size(int value)491 void grpc_stats_inc_tcp_read_offer_iov_size(int value) {
492   value = GPR_CLAMP(value, 0, 1024);
493   if (value < 13) {
494     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
495                              value);
496     return;
497   }
498   union {
499     double dbl;
500     uint64_t uint;
501   } _val, _bkt;
502   _val.dbl = value;
503   if (_val.uint < 4637863191261478912ull) {
504     int bucket =
505         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
506     _bkt.dbl = grpc_stats_table_6[bucket];
507     bucket -= (_val.uint < _bkt.uint);
508     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
509                              bucket);
510     return;
511   }
512   GRPC_STATS_INC_HISTOGRAM(
513       GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
514       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
515 }
grpc_stats_inc_http2_send_message_size(int value)516 void grpc_stats_inc_http2_send_message_size(int value) {
517   value = GPR_CLAMP(value, 0, 16777216);
518   if (value < 5) {
519     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
520                              value);
521     return;
522   }
523   union {
524     double dbl;
525     uint64_t uint;
526   } _val, _bkt;
527   _val.dbl = value;
528   if (_val.uint < 4683743612465315840ull) {
529     int bucket =
530         grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
531     _bkt.dbl = grpc_stats_table_4[bucket];
532     bucket -= (_val.uint < _bkt.uint);
533     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
534                              bucket);
535     return;
536   }
537   GRPC_STATS_INC_HISTOGRAM(
538       GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
539       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
540 }
grpc_stats_inc_http2_send_initial_metadata_per_write(int value)541 void grpc_stats_inc_http2_send_initial_metadata_per_write(int value) {
542   value = GPR_CLAMP(value, 0, 1024);
543   if (value < 13) {
544     GRPC_STATS_INC_HISTOGRAM(
545         GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE, value);
546     return;
547   }
548   union {
549     double dbl;
550     uint64_t uint;
551   } _val, _bkt;
552   _val.dbl = value;
553   if (_val.uint < 4637863191261478912ull) {
554     int bucket =
555         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
556     _bkt.dbl = grpc_stats_table_6[bucket];
557     bucket -= (_val.uint < _bkt.uint);
558     GRPC_STATS_INC_HISTOGRAM(
559         GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE, bucket);
560     return;
561   }
562   GRPC_STATS_INC_HISTOGRAM(
563       GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
564       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
565 }
grpc_stats_inc_http2_send_message_per_write(int value)566 void grpc_stats_inc_http2_send_message_per_write(int value) {
567   value = GPR_CLAMP(value, 0, 1024);
568   if (value < 13) {
569     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
570                              value);
571     return;
572   }
573   union {
574     double dbl;
575     uint64_t uint;
576   } _val, _bkt;
577   _val.dbl = value;
578   if (_val.uint < 4637863191261478912ull) {
579     int bucket =
580         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
581     _bkt.dbl = grpc_stats_table_6[bucket];
582     bucket -= (_val.uint < _bkt.uint);
583     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
584                              bucket);
585     return;
586   }
587   GRPC_STATS_INC_HISTOGRAM(
588       GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
589       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
590 }
grpc_stats_inc_http2_send_trailing_metadata_per_write(int value)591 void grpc_stats_inc_http2_send_trailing_metadata_per_write(int value) {
592   value = GPR_CLAMP(value, 0, 1024);
593   if (value < 13) {
594     GRPC_STATS_INC_HISTOGRAM(
595         GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE, value);
596     return;
597   }
598   union {
599     double dbl;
600     uint64_t uint;
601   } _val, _bkt;
602   _val.dbl = value;
603   if (_val.uint < 4637863191261478912ull) {
604     int bucket =
605         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
606     _bkt.dbl = grpc_stats_table_6[bucket];
607     bucket -= (_val.uint < _bkt.uint);
608     GRPC_STATS_INC_HISTOGRAM(
609         GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE, bucket);
610     return;
611   }
612   GRPC_STATS_INC_HISTOGRAM(
613       GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
614       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
615 }
grpc_stats_inc_http2_send_flowctl_per_write(int value)616 void grpc_stats_inc_http2_send_flowctl_per_write(int value) {
617   value = GPR_CLAMP(value, 0, 1024);
618   if (value < 13) {
619     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
620                              value);
621     return;
622   }
623   union {
624     double dbl;
625     uint64_t uint;
626   } _val, _bkt;
627   _val.dbl = value;
628   if (_val.uint < 4637863191261478912ull) {
629     int bucket =
630         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
631     _bkt.dbl = grpc_stats_table_6[bucket];
632     bucket -= (_val.uint < _bkt.uint);
633     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
634                              bucket);
635     return;
636   }
637   GRPC_STATS_INC_HISTOGRAM(
638       GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
639       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
640 }
grpc_stats_inc_server_cqs_checked(int value)641 void grpc_stats_inc_server_cqs_checked(int value) {
642   value = GPR_CLAMP(value, 0, 64);
643   if (value < 3) {
644     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, value);
645     return;
646   }
647   union {
648     double dbl;
649     uint64_t uint;
650   } _val, _bkt;
651   _val.dbl = value;
652   if (_val.uint < 4625196817309499392ull) {
653     int bucket =
654         grpc_stats_table_9[((_val.uint - 4613937818241073152ull) >> 51)] + 3;
655     _bkt.dbl = grpc_stats_table_8[bucket];
656     bucket -= (_val.uint < _bkt.uint);
657     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, bucket);
658     return;
659   }
660   GRPC_STATS_INC_HISTOGRAM(
661       GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED,
662       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_8, 8));
663 }
664 const int grpc_stats_histo_buckets[13] = {64, 128, 64, 64, 64, 64, 64,
665                                           64, 64,  64, 64, 64, 8};
666 const int grpc_stats_histo_start[13] = {0,   64,  192, 256, 320, 384, 448,
667                                         512, 576, 640, 704, 768, 832};
668 const int* const grpc_stats_histo_bucket_boundaries[13] = {
669     grpc_stats_table_0, grpc_stats_table_2, grpc_stats_table_4,
670     grpc_stats_table_6, grpc_stats_table_4, grpc_stats_table_4,
671     grpc_stats_table_6, grpc_stats_table_4, grpc_stats_table_6,
672     grpc_stats_table_6, grpc_stats_table_6, grpc_stats_table_6,
673     grpc_stats_table_8};
674 void (*const grpc_stats_inc_histogram[13])(int x) = {
675     grpc_stats_inc_call_initial_size,
676     grpc_stats_inc_poll_events_returned,
677     grpc_stats_inc_tcp_write_size,
678     grpc_stats_inc_tcp_write_iov_size,
679     grpc_stats_inc_tcp_read_size,
680     grpc_stats_inc_tcp_read_offer,
681     grpc_stats_inc_tcp_read_offer_iov_size,
682     grpc_stats_inc_http2_send_message_size,
683     grpc_stats_inc_http2_send_initial_metadata_per_write,
684     grpc_stats_inc_http2_send_message_per_write,
685     grpc_stats_inc_http2_send_trailing_metadata_per_write,
686     grpc_stats_inc_http2_send_flowctl_per_write,
687     grpc_stats_inc_server_cqs_checked};
688