|  | @@ -34,52 +34,78 @@
 | 
	
		
			
				|  |  |  #ifndef GRPC_CORE_PROFILING_TIMERS_H
 | 
	
		
			
				|  |  |  #define GRPC_CORE_PROFILING_TIMERS_H
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#include <stdio.h>
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -#ifdef GRPC_STAP_PROFILER
 | 
	
		
			
				|  |  | -#include <sys/sdt.h>
 | 
	
		
			
				|  |  | -/* Generated from src/core/profiling/stap_probes.d */
 | 
	
		
			
				|  |  | -#include "src/core/profiling/stap_probes.h"
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -#define GRPC_STAP_TIMING_NS_BEGIN(tag) _STAP_TIMING_NS_BEGIN(tag)
 | 
	
		
			
				|  |  | -#define GRPC_STAP_TIMING_NS_END(tag) _STAP_TIMING_NS_END(tag)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -#else /* !GRPC_STAP_PROFILER */
 | 
	
		
			
				|  |  | -#define GRPC_STAP_BEGIN_NS(x, s) \
 | 
	
		
			
				|  |  | -  do {                        \
 | 
	
		
			
				|  |  | -  } while (0)
 | 
	
		
			
				|  |  | -#define GRPC_STAP_END_NS(x, s) \
 | 
	
		
			
				|  |  | -  do {                        \
 | 
	
		
			
				|  |  | -  } while (0)
 | 
	
		
			
				|  |  | -#endif /* GRPC_STAP_PROFILER */
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  #ifdef __cplusplus
 | 
	
		
			
				|  |  |  extern "C" {
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#ifdef GRPC_LATENCY_PROFILER
 | 
	
		
			
				|  |  | +void grpc_timers_global_init(void);
 | 
	
		
			
				|  |  | +void grpc_timers_global_destroy(void);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -typedef struct grpc_timers_log grpc_timers_log;
 | 
	
		
			
				|  |  | +void grpc_timer_add_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);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE* dump);
 | 
	
		
			
				|  |  | -void grpc_timers_log_add(grpc_timers_log*, const char* tag, void* id,
 | 
	
		
			
				|  |  | -                         const char* file, int line);
 | 
	
		
			
				|  |  | -void grpc_timers_log_destroy(grpc_timers_log *);
 | 
	
		
			
				|  |  | +enum profiling_tags {
 | 
	
		
			
				|  |  | +  /* Re. Protos. */
 | 
	
		
			
				|  |  | +  PTAG_PROTO_SERIALIZE = 100,
 | 
	
		
			
				|  |  | +  PTAG_PROTO_DESERIALIZE = 101,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -extern grpc_timers_log *grpc_timers_log_global;
 | 
	
		
			
				|  |  | +  /* Re. sockets. */
 | 
	
		
			
				|  |  | +  PTAG_HANDLE_READ = 200,
 | 
	
		
			
				|  |  | +  PTAG_SENDMSG = 201,
 | 
	
		
			
				|  |  | +  PTAG_RECVMSG = 202,
 | 
	
		
			
				|  |  | +  PTAG_POLL_FINISHED = 203,
 | 
	
		
			
				|  |  | +  PTAG_TCP_CB_WRITE = 204,
 | 
	
		
			
				|  |  | +  PTAG_TCP_WRITE = 205,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#define GRPC_TIMER_MARK(x, s) \
 | 
	
		
			
				|  |  | -  grpc_timers_log_add(grpc_timers_log_global, #x, ((void *)(gpr_intptr)(s)), \
 | 
	
		
			
				|  |  | -                      __FILE__, __LINE__)
 | 
	
		
			
				|  |  | +  /* C++ */
 | 
	
		
			
				|  |  | +  PTAG_CPP_CALL_CREATED = 300,
 | 
	
		
			
				|  |  | +  PTAG_CPP_PERFORM_OPS = 301,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#else /* !GRPC_LATENCY_PROFILER */
 | 
	
		
			
				|  |  | -#define GRPC_TIMER_MARK(x, s) \
 | 
	
		
			
				|  |  | -  do {                        \
 | 
	
		
			
				|  |  | -  } while (0)
 | 
	
		
			
				|  |  | -#endif /* GRPC_LATENCY_PROFILER */
 | 
	
		
			
				|  |  | +  /* > 1024 Unassigned reserved. For any miscellaneous use.
 | 
	
		
			
				|  |  | +   * Use addition to generate tags from this base or take advantage of the 10
 | 
	
		
			
				|  |  | +   * zero'd bits for OR-ing. */
 | 
	
		
			
				|  |  | +  PTAG_OTHER_BASE = 1024
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER))
 | 
	
		
			
				|  |  | +/* No profiling. No-op all the things. */
 | 
	
		
			
				|  |  | +#define GRPC_TIMER_MARK(tag, id) \
 | 
	
		
			
				|  |  | +  do {} while(0)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#define GRPC_TIMER_BEGIN(tag, id) \
 | 
	
		
			
				|  |  | +  do {} while(0)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#define GRPC_TIMER_END(tag, id) \
 | 
	
		
			
				|  |  | +  do {} while(0)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#else /* at least one profiler requested... */
 | 
	
		
			
				|  |  | +/* ... hopefully only one. */
 | 
	
		
			
				|  |  | +#if defined(GRPC_STAP_PROFILER) && defined(GRPC_BASIC_PROFILER)
 | 
	
		
			
				|  |  | +#error "GRPC_STAP_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive."
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Generic profiling interface. */
 | 
	
		
			
				|  |  | +#define GRPC_TIMER_MARK(tag, id) \
 | 
	
		
			
				|  |  | +  grpc_timer_add_mark(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#define GRPC_TIMER_BEGIN(tag, id) \
 | 
	
		
			
				|  |  | +  grpc_timer_begin(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#define GRPC_TIMER_END(tag, id) \
 | 
	
		
			
				|  |  | +  grpc_timer_end(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#ifdef GRPC_STAP_PROFILER
 | 
	
		
			
				|  |  | +/* Empty placeholder for now. */
 | 
	
		
			
				|  |  | +#endif /* GRPC_STAP_PROFILER */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#ifdef GRPC_BASIC_PROFILER
 | 
	
		
			
				|  |  | +typedef struct grpc_timers_log grpc_timers_log;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +extern grpc_timers_log *grpc_timers_log_global;
 | 
	
		
			
				|  |  | +#endif /* GRPC_BASIC_PROFILER */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void grpc_timers_log_global_init(void);
 | 
	
		
			
				|  |  | -void grpc_timers_log_global_destroy(void);
 | 
	
		
			
				|  |  | +#endif /* at least one profiler requested. */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #ifdef __cplusplus
 | 
	
		
			
				|  |  |  }
 |