• 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     // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
284     ("How many completion queues were checked looking for a CQ that had "
285     "requested the incoming call")
286 };
287 const int grpc_stats_table_0[65] = {
288     0,      1,      2,      3,      4,     5,     7,     9,     11,    14,
289     17,     21,     26,     32,     39,    47,    57,    68,    82,    98,
290     117,    140,    167,    199,    238,   284,   339,   404,   482,   575,
291     685,    816,    972,    1158,   1380,  1644,  1959,  2334,  2780,  3312,
292     3945,   4699,   5597,   6667,   7941,  9459,  11267, 13420, 15984, 19038,
293     22676,  27009,  32169,  38315,  45635, 54353, 64737, 77104, 91834, 109378,
294     130273, 155159, 184799, 220100, 262144};
295 const uint8_t grpc_stats_table_1[124] = {
296     0,  0,  0,  1,  1,  1,  2,  2,  3,  3,  3,  4,  4,  5,  5,  6,  6,  6,
297     7,  7,  7,  8,  9,  9,  10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15,
298     15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 22, 23, 24,
299     24, 25, 25, 26, 26, 26, 27, 27, 28, 29, 29, 30, 30, 30, 31, 31, 32, 33,
300     33, 34, 34, 34, 35, 35, 36, 37, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41,
301     42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50,
302     51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58};
303 const int grpc_stats_table_2[129] = {
304     0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
305     15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  30,
306     32,  34,  36,  38,  40,  42,  44,  46,  48,  50,  52,  54,  56,  58,  60,
307     63,  66,  69,  72,  75,  78,  81,  84,  87,  90,  94,  98,  102, 106, 110,
308     114, 118, 122, 126, 131, 136, 141, 146, 151, 156, 162, 168, 174, 180, 186,
309     192, 199, 206, 213, 220, 228, 236, 244, 252, 260, 269, 278, 287, 297, 307,
310     317, 327, 338, 349, 360, 372, 384, 396, 409, 422, 436, 450, 464, 479, 494,
311     510, 526, 543, 560, 578, 596, 615, 634, 654, 674, 695, 717, 739, 762, 785,
312     809, 834, 859, 885, 912, 939, 967, 996, 1024};
313 const uint8_t grpc_stats_table_3[166] = {
314     0,  0,  0,  1,  1,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,  7,  7,
315     8,  8,  9,  9,  10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 16,
316     17, 17, 18, 19, 19, 20, 21, 21, 22, 23, 23, 24, 25, 25, 26, 26, 27, 27, 28,
317     28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 36, 36, 37, 38, 39,
318     40, 40, 41, 42, 42, 43, 44, 44, 45, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51,
319     51, 52, 52, 53, 53, 54, 54, 55, 56, 57, 58, 59, 59, 60, 61, 62, 63, 63, 64,
320     65, 65, 66, 67, 67, 68, 69, 69, 70, 71, 71, 72, 72, 73, 73, 74, 75, 75, 76,
321     76, 77, 78, 79, 79, 80, 81, 82, 83, 84, 85, 85, 86, 87, 88, 88, 89, 90, 90,
322     91, 92, 92, 93, 94, 94, 95, 95, 96, 97, 97, 98, 98, 99};
323 const int grpc_stats_table_4[65] = {
324     0,       1,       2,       3,       4,       6,       8,        11,
325     15,      20,      26,      34,      44,      57,      73,       94,
326     121,     155,     199,     255,     327,     419,     537,      688,
327     881,     1128,    1444,    1848,    2365,    3026,    3872,     4954,
328     6338,    8108,    10373,   13270,   16976,   21717,   27782,    35541,
329     45467,   58165,   74409,   95189,   121772,  155778,  199281,   254933,
330     326126,  417200,  533707,  682750,  873414,  1117323, 1429345,  1828502,
331     2339127, 2992348, 3827987, 4896985, 6264509, 8013925, 10251880, 13114801,
332     16777216};
333 const uint8_t grpc_stats_table_5[87] = {
334     0,  0,  1,  1,  2,  3,  3,  4,  4,  5,  6,  6,  7,  8,  8,  9,  10, 11,
335     11, 12, 13, 13, 14, 15, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 22, 23,
336     24, 25, 25, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35, 36,
337     36, 37, 38, 39, 39, 40, 41, 41, 42, 43, 44, 44, 45, 45, 46, 47, 48, 48,
338     49, 50, 51, 51, 52, 53, 53, 54, 55, 56, 56, 57, 58, 58, 59};
339 const int grpc_stats_table_6[65] = {
340     0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,
341     14,  16,  18,  20,  22,  24,  27,  30,  33,  36,  39,  43,  47,
342     51,  56,  61,  66,  72,  78,  85,  92,  100, 109, 118, 128, 139,
343     151, 164, 178, 193, 209, 226, 244, 264, 285, 308, 333, 359, 387,
344     418, 451, 486, 524, 565, 609, 656, 707, 762, 821, 884, 952, 1024};
345 const uint8_t grpc_stats_table_7[102] = {
346     0,  0,  0,  1,  1,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,
347     6,  7,  7,  7,  8,  8,  9,  9,  10, 11, 11, 12, 12, 13, 13, 14, 14,
348     14, 15, 15, 16, 16, 17, 17, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23,
349     23, 24, 24, 24, 25, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32,
350     32, 33, 33, 34, 35, 35, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41,
351     42, 42, 43, 44, 44, 45, 46, 46, 47, 48, 48, 49, 49, 50, 50, 51, 51};
352 const int grpc_stats_table_8[9] = {0, 1, 2, 4, 7, 13, 23, 39, 64};
353 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)354 void grpc_stats_inc_call_initial_size(int value) {
355   value = GPR_CLAMP(value, 0, 262144);
356   if (value < 6) {
357     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE, value);
358     return;
359   }
360   union {
361     double dbl;
362     uint64_t uint;
363   } _val, _bkt;
364   _val.dbl = value;
365   if (_val.uint < 4651092515166879744ull) {
366     int bucket =
367         grpc_stats_table_1[((_val.uint - 4618441417868443648ull) >> 49)] + 6;
368     _bkt.dbl = grpc_stats_table_0[bucket];
369     bucket -= (_val.uint < _bkt.uint);
370     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE, bucket);
371     return;
372   }
373   GRPC_STATS_INC_HISTOGRAM(
374       GRPC_STATS_HISTOGRAM_CALL_INITIAL_SIZE,
375       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_0, 64));
376 }
grpc_stats_inc_poll_events_returned(int value)377 void grpc_stats_inc_poll_events_returned(int value) {
378   value = GPR_CLAMP(value, 0, 1024);
379   if (value < 29) {
380     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, value);
381     return;
382   }
383   union {
384     double dbl;
385     uint64_t uint;
386   } _val, _bkt;
387   _val.dbl = value;
388   if (_val.uint < 4642789003353915392ull) {
389     int bucket =
390         grpc_stats_table_3[((_val.uint - 4628855992006737920ull) >> 47)] + 29;
391     _bkt.dbl = grpc_stats_table_2[bucket];
392     bucket -= (_val.uint < _bkt.uint);
393     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED, bucket);
394     return;
395   }
396   GRPC_STATS_INC_HISTOGRAM(
397       GRPC_STATS_HISTOGRAM_POLL_EVENTS_RETURNED,
398       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_2, 128));
399 }
grpc_stats_inc_tcp_write_size(int value)400 void grpc_stats_inc_tcp_write_size(int value) {
401   value = GPR_CLAMP(value, 0, 16777216);
402   if (value < 5) {
403     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, value);
404     return;
405   }
406   union {
407     double dbl;
408     uint64_t uint;
409   } _val, _bkt;
410   _val.dbl = value;
411   if (_val.uint < 4683743612465315840ull) {
412     int bucket =
413         grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
414     _bkt.dbl = grpc_stats_table_4[bucket];
415     bucket -= (_val.uint < _bkt.uint);
416     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE, bucket);
417     return;
418   }
419   GRPC_STATS_INC_HISTOGRAM(
420       GRPC_STATS_HISTOGRAM_TCP_WRITE_SIZE,
421       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
422 }
grpc_stats_inc_tcp_write_iov_size(int value)423 void grpc_stats_inc_tcp_write_iov_size(int value) {
424   value = GPR_CLAMP(value, 0, 1024);
425   if (value < 13) {
426     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, value);
427     return;
428   }
429   union {
430     double dbl;
431     uint64_t uint;
432   } _val, _bkt;
433   _val.dbl = value;
434   if (_val.uint < 4637863191261478912ull) {
435     int bucket =
436         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
437     _bkt.dbl = grpc_stats_table_6[bucket];
438     bucket -= (_val.uint < _bkt.uint);
439     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE, bucket);
440     return;
441   }
442   GRPC_STATS_INC_HISTOGRAM(
443       GRPC_STATS_HISTOGRAM_TCP_WRITE_IOV_SIZE,
444       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
445 }
grpc_stats_inc_tcp_read_size(int value)446 void grpc_stats_inc_tcp_read_size(int value) {
447   value = GPR_CLAMP(value, 0, 16777216);
448   if (value < 5) {
449     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, value);
450     return;
451   }
452   union {
453     double dbl;
454     uint64_t uint;
455   } _val, _bkt;
456   _val.dbl = value;
457   if (_val.uint < 4683743612465315840ull) {
458     int bucket =
459         grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
460     _bkt.dbl = grpc_stats_table_4[bucket];
461     bucket -= (_val.uint < _bkt.uint);
462     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_SIZE, bucket);
463     return;
464   }
465   GRPC_STATS_INC_HISTOGRAM(
466       GRPC_STATS_HISTOGRAM_TCP_READ_SIZE,
467       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
468 }
grpc_stats_inc_tcp_read_offer(int value)469 void grpc_stats_inc_tcp_read_offer(int value) {
470   value = GPR_CLAMP(value, 0, 16777216);
471   if (value < 5) {
472     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER, value);
473     return;
474   }
475   union {
476     double dbl;
477     uint64_t uint;
478   } _val, _bkt;
479   _val.dbl = value;
480   if (_val.uint < 4683743612465315840ull) {
481     int bucket =
482         grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
483     _bkt.dbl = grpc_stats_table_4[bucket];
484     bucket -= (_val.uint < _bkt.uint);
485     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER, bucket);
486     return;
487   }
488   GRPC_STATS_INC_HISTOGRAM(
489       GRPC_STATS_HISTOGRAM_TCP_READ_OFFER,
490       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
491 }
grpc_stats_inc_tcp_read_offer_iov_size(int value)492 void grpc_stats_inc_tcp_read_offer_iov_size(int value) {
493   value = GPR_CLAMP(value, 0, 1024);
494   if (value < 13) {
495     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
496                              value);
497     return;
498   }
499   union {
500     double dbl;
501     uint64_t uint;
502   } _val, _bkt;
503   _val.dbl = value;
504   if (_val.uint < 4637863191261478912ull) {
505     int bucket =
506         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
507     _bkt.dbl = grpc_stats_table_6[bucket];
508     bucket -= (_val.uint < _bkt.uint);
509     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
510                              bucket);
511     return;
512   }
513   GRPC_STATS_INC_HISTOGRAM(
514       GRPC_STATS_HISTOGRAM_TCP_READ_OFFER_IOV_SIZE,
515       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
516 }
grpc_stats_inc_http2_send_message_size(int value)517 void grpc_stats_inc_http2_send_message_size(int value) {
518   value = GPR_CLAMP(value, 0, 16777216);
519   if (value < 5) {
520     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
521                              value);
522     return;
523   }
524   union {
525     double dbl;
526     uint64_t uint;
527   } _val, _bkt;
528   _val.dbl = value;
529   if (_val.uint < 4683743612465315840ull) {
530     int bucket =
531         grpc_stats_table_5[((_val.uint - 4617315517961601024ull) >> 50)] + 5;
532     _bkt.dbl = grpc_stats_table_4[bucket];
533     bucket -= (_val.uint < _bkt.uint);
534     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
535                              bucket);
536     return;
537   }
538   GRPC_STATS_INC_HISTOGRAM(
539       GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_SIZE,
540       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_4, 64));
541 }
grpc_stats_inc_http2_send_initial_metadata_per_write(int value)542 void grpc_stats_inc_http2_send_initial_metadata_per_write(int value) {
543   value = GPR_CLAMP(value, 0, 1024);
544   if (value < 13) {
545     GRPC_STATS_INC_HISTOGRAM(
546         GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE, value);
547     return;
548   }
549   union {
550     double dbl;
551     uint64_t uint;
552   } _val, _bkt;
553   _val.dbl = value;
554   if (_val.uint < 4637863191261478912ull) {
555     int bucket =
556         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
557     _bkt.dbl = grpc_stats_table_6[bucket];
558     bucket -= (_val.uint < _bkt.uint);
559     GRPC_STATS_INC_HISTOGRAM(
560         GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE, bucket);
561     return;
562   }
563   GRPC_STATS_INC_HISTOGRAM(
564       GRPC_STATS_HISTOGRAM_HTTP2_SEND_INITIAL_METADATA_PER_WRITE,
565       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
566 }
grpc_stats_inc_http2_send_message_per_write(int value)567 void grpc_stats_inc_http2_send_message_per_write(int value) {
568   value = GPR_CLAMP(value, 0, 1024);
569   if (value < 13) {
570     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
571                              value);
572     return;
573   }
574   union {
575     double dbl;
576     uint64_t uint;
577   } _val, _bkt;
578   _val.dbl = value;
579   if (_val.uint < 4637863191261478912ull) {
580     int bucket =
581         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
582     _bkt.dbl = grpc_stats_table_6[bucket];
583     bucket -= (_val.uint < _bkt.uint);
584     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
585                              bucket);
586     return;
587   }
588   GRPC_STATS_INC_HISTOGRAM(
589       GRPC_STATS_HISTOGRAM_HTTP2_SEND_MESSAGE_PER_WRITE,
590       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
591 }
grpc_stats_inc_http2_send_trailing_metadata_per_write(int value)592 void grpc_stats_inc_http2_send_trailing_metadata_per_write(int value) {
593   value = GPR_CLAMP(value, 0, 1024);
594   if (value < 13) {
595     GRPC_STATS_INC_HISTOGRAM(
596         GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE, value);
597     return;
598   }
599   union {
600     double dbl;
601     uint64_t uint;
602   } _val, _bkt;
603   _val.dbl = value;
604   if (_val.uint < 4637863191261478912ull) {
605     int bucket =
606         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
607     _bkt.dbl = grpc_stats_table_6[bucket];
608     bucket -= (_val.uint < _bkt.uint);
609     GRPC_STATS_INC_HISTOGRAM(
610         GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE, bucket);
611     return;
612   }
613   GRPC_STATS_INC_HISTOGRAM(
614       GRPC_STATS_HISTOGRAM_HTTP2_SEND_TRAILING_METADATA_PER_WRITE,
615       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
616 }
grpc_stats_inc_http2_send_flowctl_per_write(int value)617 void grpc_stats_inc_http2_send_flowctl_per_write(int value) {
618   value = GPR_CLAMP(value, 0, 1024);
619   if (value < 13) {
620     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
621                              value);
622     return;
623   }
624   union {
625     double dbl;
626     uint64_t uint;
627   } _val, _bkt;
628   _val.dbl = value;
629   if (_val.uint < 4637863191261478912ull) {
630     int bucket =
631         grpc_stats_table_7[((_val.uint - 4623507967449235456ull) >> 48)] + 13;
632     _bkt.dbl = grpc_stats_table_6[bucket];
633     bucket -= (_val.uint < _bkt.uint);
634     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
635                              bucket);
636     return;
637   }
638   GRPC_STATS_INC_HISTOGRAM(
639       GRPC_STATS_HISTOGRAM_HTTP2_SEND_FLOWCTL_PER_WRITE,
640       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_6, 64));
641 }
grpc_stats_inc_server_cqs_checked(int value)642 void grpc_stats_inc_server_cqs_checked(int value) {
643   value = GPR_CLAMP(value, 0, 64);
644   if (value < 3) {
645     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, value);
646     return;
647   }
648   union {
649     double dbl;
650     uint64_t uint;
651   } _val, _bkt;
652   _val.dbl = value;
653   if (_val.uint < 4625196817309499392ull) {
654     int bucket =
655         grpc_stats_table_9[((_val.uint - 4613937818241073152ull) >> 51)] + 3;
656     _bkt.dbl = grpc_stats_table_8[bucket];
657     bucket -= (_val.uint < _bkt.uint);
658     GRPC_STATS_INC_HISTOGRAM(GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED, bucket);
659     return;
660   }
661   GRPC_STATS_INC_HISTOGRAM(
662       GRPC_STATS_HISTOGRAM_SERVER_CQS_CHECKED,
663       grpc_stats_histo_find_bucket_slow(value, grpc_stats_table_8, 8));
664 }
665 const int grpc_stats_histo_buckets[13] = {64, 128, 64, 64, 64, 64, 64,
666                                           64, 64,  64, 64, 64, 8};
667 const int grpc_stats_histo_start[13] = {0,   64,  192, 256, 320, 384, 448,
668                                         512, 576, 640, 704, 768, 832};
669 const int* const grpc_stats_histo_bucket_boundaries[13] = {
670     grpc_stats_table_0, grpc_stats_table_2, grpc_stats_table_4,
671     grpc_stats_table_6, grpc_stats_table_4, grpc_stats_table_4,
672     grpc_stats_table_6, grpc_stats_table_4, grpc_stats_table_6,
673     grpc_stats_table_6, grpc_stats_table_6, grpc_stats_table_6,
674     grpc_stats_table_8};
675 void (*const grpc_stats_inc_histogram[13])(int x) = {
676     grpc_stats_inc_call_initial_size,
677     grpc_stats_inc_poll_events_returned,
678     grpc_stats_inc_tcp_write_size,
679     grpc_stats_inc_tcp_write_iov_size,
680     grpc_stats_inc_tcp_read_size,
681     grpc_stats_inc_tcp_read_offer,
682     grpc_stats_inc_tcp_read_offer_iov_size,
683     grpc_stats_inc_http2_send_message_size,
684     grpc_stats_inc_http2_send_initial_metadata_per_write,
685     grpc_stats_inc_http2_send_message_per_write,
686     grpc_stats_inc_http2_send_trailing_metadata_per_write,
687     grpc_stats_inc_http2_send_flowctl_per_write,
688     grpc_stats_inc_server_cqs_checked};
689