GRPC Core 0.10.0.0

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
timers.h
Go to the documentation of this file.
1 /*
2 *
3 * Copyright 2015, Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34 #ifndef GRPC_CORE_PROFILING_TIMERS_H
35 #define GRPC_CORE_PROFILING_TIMERS_H
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 void grpc_timers_global_init(void);
42 void grpc_timers_global_destroy(void);
43
44 void grpc_timer_add_mark(int tag, const char *tagstr, void *id,
45 const char *file, int line);
46 void grpc_timer_add_important_mark(int tag, const char *tagstr, void *id,
47 const char *file, int line);
48 void grpc_timer_begin(int tag, const char *tagstr, void *id, const char *file,
49 int line);
50 void grpc_timer_end(int tag, const char *tagstr, void *id, const char *file,
51 int line);
52
53 enum grpc_profiling_tags {
54 /* Any GRPC_PTAG_* >= than the threshold won't generate any profiling mark. */
55 GRPC_PTAG_IGNORE_THRESHOLD = 1000000,
56
57 /* Re. Protos. */
58 GRPC_PTAG_PROTO_SERIALIZE = 100 + GRPC_PTAG_IGNORE_THRESHOLD,
59 GRPC_PTAG_PROTO_DESERIALIZE = 101 + GRPC_PTAG_IGNORE_THRESHOLD,
60
61 /* Re. sockets. */
62 GRPC_PTAG_HANDLE_READ = 200 + GRPC_PTAG_IGNORE_THRESHOLD,
63 GRPC_PTAG_SENDMSG = 201 + GRPC_PTAG_IGNORE_THRESHOLD,
64 GRPC_PTAG_RECVMSG = 202 + GRPC_PTAG_IGNORE_THRESHOLD,
65 GRPC_PTAG_POLL_FINISHED = 203 + GRPC_PTAG_IGNORE_THRESHOLD,
66 GRPC_PTAG_TCP_CB_WRITE = 204 + GRPC_PTAG_IGNORE_THRESHOLD,
67 GRPC_PTAG_TCP_WRITE = 205 + GRPC_PTAG_IGNORE_THRESHOLD,
68 GRPC_PTAG_CALL_ON_DONE_RECV = 206 + GRPC_PTAG_IGNORE_THRESHOLD,
69
70 /* C++ */
71 GRPC_PTAG_CPP_CALL_CREATED = 300 + GRPC_PTAG_IGNORE_THRESHOLD,
72 GRPC_PTAG_CPP_PERFORM_OPS = 301 + GRPC_PTAG_IGNORE_THRESHOLD,
73
74 /* Transports */
75 GRPC_PTAG_HTTP2_UNLOCK = 401 + GRPC_PTAG_IGNORE_THRESHOLD,
76 GRPC_PTAG_HTTP2_UNLOCK_CLEANUP = 402 + GRPC_PTAG_IGNORE_THRESHOLD,
77
78 /* > 1024 Unassigned reserved. For any miscellaneous use.
79 * Use addition to generate tags from this base or take advantage of the 10
80 * zero'd bits for OR-ing. */
81 GRPC_PTAG_OTHER_BASE = 1024
82 };
83
84 #if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER))
85 /* No profiling. No-op all the things. */
86 #define GRPC_TIMER_MARK(tag, id) \
87 do { \
88 } while (0)
89
90 #define GRPC_TIMER_IMPORTANT_MARK(tag, id) \
91 do { \
92 } while (0)
93
94 #define GRPC_TIMER_BEGIN(tag, id) \
95 do { \
96 } while (0)
97
98 #define GRPC_TIMER_END(tag, id) \
99 do { \
100 } while (0)
101
102 #else /* at least one profiler requested... */
103 /* ... hopefully only one. */
104 #if defined(GRPC_STAP_PROFILER) && defined(GRPC_BASIC_PROFILER)
105 #error "GRPC_STAP_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive."
106 #endif
107
108 /* Generic profiling interface. */
109 #define GRPC_TIMER_MARK(tag, id) \
110 if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \
111 grpc_timer_add_mark(tag, #tag, ((void *)(gpr_intptr)(id)), __FILE__, \
112 __LINE__); \
113 }
114
115 #define GRPC_TIMER_IMPORTANT_MARK(tag, id) \
116 if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \
117 grpc_timer_add_important_mark(tag, #tag, ((void *)(gpr_intptr)(id)), \
118 __FILE__, __LINE__); \
119 }
120
121 #define GRPC_TIMER_BEGIN(tag, id) \
122 if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \
123 grpc_timer_begin(tag, #tag, ((void *)(gpr_intptr)(id)), __FILE__, \
124 __LINE__); \
125 }
126
127 #define GRPC_TIMER_END(tag, id) \
128 if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \
129 grpc_timer_end(tag, #tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \
130 }
131
132 #ifdef GRPC_STAP_PROFILER
133 /* Empty placeholder for now. */
134 #endif /* GRPC_STAP_PROFILER */
135
136 #ifdef GRPC_BASIC_PROFILER
137 /* Empty placeholder for now. */
138 #endif /* GRPC_BASIC_PROFILER */
139
140 #endif /* at least one profiler requested. */
141
142 #ifdef __cplusplus
143 }
144 #endif
145
146 #endif /* GRPC_CORE_PROFILING_TIMERS_H */
grpc_timer_add_mark
void grpc_timer_add_mark(int tag, const char *tagstr, void *id, const char *file, int line)
GRPC_PTAG_CPP_PERFORM_OPS
Definition: timers.h:72
GRPC_PTAG_HANDLE_READ
Definition: timers.h:62
grpc_timer_begin
void grpc_timer_begin(int tag, const char *tagstr, void *id, const char *file, int line)
grpc_timer_add_important_mark
void grpc_timer_add_important_mark(int tag, const char *tagstr, void *id, const char *file, int line)
GRPC_PTAG_IGNORE_THRESHOLD
Definition: timers.h:55
GRPC_PTAG_RECVMSG
Definition: timers.h:64
GRPC_PTAG_CPP_CALL_CREATED
Definition: timers.h:71
GRPC_PTAG_CALL_ON_DONE_RECV
Definition: timers.h:68
GRPC_PTAG_TCP_CB_WRITE
Definition: timers.h:66
GRPC_PTAG_POLL_FINISHED
Definition: timers.h:65
GRPC_PTAG_HTTP2_UNLOCK
Definition: timers.h:75
grpc_timers_global_destroy
void grpc_timers_global_destroy(void)
Definition: basic_timers.c:141
grpc_timer_end
void grpc_timer_end(int tag, const char *tagstr, void *id, const char *file, int line)
GRPC_PTAG_SENDMSG
Definition: timers.h:63
GRPC_PTAG_PROTO_SERIALIZE
Definition: timers.h:58
GRPC_PTAG_OTHER_BASE
Definition: timers.h:81
GRPC_PTAG_PROTO_DESERIALIZE
Definition: timers.h:59
GRPC_PTAG_HTTP2_UNLOCK_CLEANUP
Definition: timers.h:76
grpc_timers_global_init
void grpc_timers_global_init(void)
Definition: basic_timers.c:140
grpc_profiling_tags
grpc_profiling_tags
Definition: timers.h:53
GRPC_PTAG_TCP_WRITE
Definition: timers.h:67