src/core/lib/debug/stats.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_DEBUG_STATS_H
20 #define GRPC_CORE_LIB_DEBUG_STATS_H
21 
23 
24 #include <stddef.h>
25 
26 #include <string>
27 
28 #include <grpc/support/atm.h>
29 
32 
33 typedef struct grpc_stats_data {
37 
39 
40 #define GRPC_THREAD_STATS_DATA() \
41  (&grpc_stats_per_cpu_storage[grpc_core::ExecCtx::Get()->starting_cpu()])
42 
43 /* Only collect stats if GRPC_COLLECT_STATS is defined or it is a debug build.
44  */
45 #if defined(GRPC_COLLECT_STATS) || !defined(NDEBUG)
46 #define GRPC_STATS_INC_COUNTER(ctr) \
47  (gpr_atm_no_barrier_fetch_add(&GRPC_THREAD_STATS_DATA()->counters[(ctr)], 1))
48 
49 #define GRPC_STATS_INC_HISTOGRAM(histogram, index) \
50  (gpr_atm_no_barrier_fetch_add( \
51  &GRPC_THREAD_STATS_DATA()->histograms[histogram##_FIRST_SLOT + (index)], \
52  1))
53 #else /* defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) */
54 #define GRPC_STATS_INC_COUNTER(ctr)
55 #define GRPC_STATS_INC_HISTOGRAM(histogram, index)
56 #endif /* defined(GRPC_COLLECT_STATS) || !defined(NDEBUG) */
57 
58 void grpc_stats_init(void);
60 // c = b-a
65  int table_size);
68  double percentile);
71 
72 #endif // GRPC_CORE_LIB_DEBUG_STATS_H
grpc_stats_init
void grpc_stats_init(void)
Definition: stats.cc:40
stats_data.h
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
profile_analyzer.percentile
def percentile(N, percent, key=lambda x:x)
Definition: profile_analyzer.py:187
grpc_stats_data::counters
gpr_atm counters[GRPC_STATS_COUNTER_COUNT]
Definition: src/core/lib/debug/stats.h:34
grpc_stats_histo_count
size_t grpc_stats_histo_count(const grpc_stats_data *stats, grpc_stats_histograms histogram)
Definition: stats.cc:89
c
void c(T a)
Definition: miscompile_with_no_unique_address_test.cc:40
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
grpc_stats_data::histograms
gpr_atm histograms[GRPC_STATS_HISTOGRAM_BUCKETS]
Definition: src/core/lib/debug/stats.h:35
grpc_stats_data_as_json
std::string grpc_stats_data_as_json(const grpc_stats_data *data)
Definition: stats.cc:148
grpc_stats_per_cpu_storage
grpc_stats_data * grpc_stats_per_cpu_storage
Definition: stats.cc:36
grpc_stats_histo_find_bucket_slow
int grpc_stats_histo_find_bucket_slow(int value, const int *table, int table_size)
Definition: stats.cc:72
gen_stats_data.stats
list stats
Definition: gen_stats_data.py:58
histogram
static grpc_histogram * histogram
Definition: test/core/fling/client.cc:34
grpc_stats_diff
void grpc_stats_diff(const grpc_stats_data *b, const grpc_stats_data *a, grpc_stats_data *c)
Definition: stats.cc:62
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
grpc_stats_data
struct grpc_stats_data grpc_stats_data
value
const char * value
Definition: hpack_parser_table.cc:165
gpr_atm
intptr_t gpr_atm
Definition: impl/codegen/atm_gcc_atomic.h:32
grpc_stats_data
Definition: src/core/lib/debug/stats.h:33
GRPC_STATS_HISTOGRAM_BUCKETS
@ GRPC_STATS_HISTOGRAM_BUCKETS
Definition: stats_data.h:173
grpc_stats_histograms
grpc_stats_histograms
Definition: stats_data.h:128
exec_ctx.h
table
uint8_t table[256]
Definition: hpack_parser.cc:456
GRPC_STATS_COUNTER_COUNT
@ GRPC_STATS_COUNTER_COUNT
Definition: stats_data.h:124
atm.h
grpc_stats_collect
void grpc_stats_collect(grpc_stats_data *output)
Definition: stats.cc:48
grpc_stats_histo_percentile
double grpc_stats_histo_percentile(const grpc_stats_data *stats, grpc_stats_histograms histogram, double percentile)
Definition: stats.cc:136
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:17