From 73423ae76d1ffcec73af4a504aaac6884f3df49e Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 5 May 2015 17:11:04 -0700 Subject: Added important (!) profiling mark. It's meant to have a special status in the analysis, whereby latencies from important marks to all their enclosing BEGIN ({) and END (}) markings will be measured. --- src/core/profiling/basic_timers.c | 14 +++++++++++++- src/core/profiling/stap_probes.d | 1 + src/core/profiling/stap_timers.c | 5 +++++ src/core/profiling/timers.h | 12 ++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/core/profiling/basic_timers.c b/src/core/profiling/basic_timers.c index 866833f225..124a8d6621 100644 --- a/src/core/profiling/basic_timers.c +++ b/src/core/profiling/basic_timers.c @@ -45,7 +45,12 @@ #include #include -typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type; +typedef enum { + BEGIN = '{', + END = '}', + MARK = '.', + IMPORTANT = '!' +} marker_type; typedef struct grpc_timer_entry { grpc_precise_clock tm; @@ -101,6 +106,13 @@ void grpc_timer_add_mark(int tag, void* id, const char* file, int line) { } } +void grpc_timer_add_important_mark(int tag, void* id, const char* file, + int line) { + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { + grpc_timers_log_add(tag, IMPORTANT, id, file, line); + } +} + void grpc_timer_begin(int tag, void* id, const char* file, int line) { if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { grpc_timers_log_add(tag, BEGIN, id, file, line); diff --git a/src/core/profiling/stap_probes.d b/src/core/profiling/stap_probes.d index 374eeedd6c..153de91752 100644 --- a/src/core/profiling/stap_probes.d +++ b/src/core/profiling/stap_probes.d @@ -1,5 +1,6 @@ provider _stap { probe add_mark(int tag); + probe add_important_mark(int tag); probe timing_ns_begin(int tag); probe timing_ns_end(int tag); }; diff --git a/src/core/profiling/stap_timers.c b/src/core/profiling/stap_timers.c index 6e3a965dae..064c86e794 100644 --- a/src/core/profiling/stap_timers.c +++ b/src/core/profiling/stap_timers.c @@ -46,6 +46,11 @@ void grpc_timer_add_mark(int tag, void* id, const char* file, int line) { _STAP_ADD_MARK(tag); } +void grpc_timer_add_important_mark(int tag, void* id, const char* file, + int line) { + _STAP_ADD_IMPORTANT_MARK(tag); +} + void grpc_timer_begin(int tag, void* id, const char* file, int line) { _STAP_TIMING_NS_BEGIN(tag); } diff --git a/src/core/profiling/timers.h b/src/core/profiling/timers.h index 0b0f7152e7..4fb465c237 100644 --- a/src/core/profiling/timers.h +++ b/src/core/profiling/timers.h @@ -42,6 +42,8 @@ void grpc_timers_global_init(void); void grpc_timers_global_destroy(void); void grpc_timer_add_mark(int tag, void *id, const char *file, int line); +void grpc_timer_add_important_mark(int tag, void *id, const char *file, + int line); void grpc_timer_begin(int tag, void *id, const char *file, int line); void grpc_timer_end(int tag, void *id, const char *file, int line); @@ -82,6 +84,10 @@ enum grpc_profiling_tags { do { \ } while (0) +#define GRPC_TIMER_IMPORTANT_MARK(tag, id) \ + do { \ + } while (0) + #define GRPC_TIMER_BEGIN(tag, id) \ do { \ } while (0) @@ -102,6 +108,12 @@ enum grpc_profiling_tags { grpc_timer_add_mark(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \ } +#define GRPC_TIMER_IMPORTANT_MARK(tag, id) \ + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \ + grpc_timer_add_important_mark(tag, ((void *)(gpr_intptr)(id)), __FILE__, \ + __LINE__); \ + } + #define GRPC_TIMER_BEGIN(tag, id) \ if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \ grpc_timer_begin(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \ -- cgit v1.2.3