Add workqueue tracer

pull/10833/head
ncteisen 8 years ago
parent 9c43fc0242
commit a135485bb8
  1. 3
      src/core/ext/filters/client_channel/lb_policy.c
  2. 2
      src/core/ext/filters/client_channel/lb_policy.h
  3. 2
      src/core/ext/filters/client_channel/resolver.c
  4. 2
      src/core/ext/filters/client_channel/resolver.h
  5. 2
      src/core/lib/iomgr/closure.c
  6. 2
      src/core/lib/iomgr/closure.h
  7. 8
      src/core/lib/iomgr/combiner.c
  8. 3
      src/core/lib/iomgr/combiner.h
  9. 2
      src/core/lib/iomgr/error.c
  10. 2
      src/core/lib/iomgr/error.h
  11. 19
      src/core/lib/iomgr/ev_epollsig_linux.c
  12. 1
      src/core/lib/iomgr/ev_poll_posix.c
  13. 1
      src/core/lib/iomgr/ev_posix.c
  14. 3
      src/core/lib/transport/transport.c
  15. 2
      src/core/lib/transport/transport.h

@ -21,7 +21,10 @@
#define WEAK_REF_BITS 16 #define WEAK_REF_BITS 16
#ifndef NDEBUG
grpc_tracer_flag grpc_trace_lb_policy_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_lb_policy_refcount = GRPC_TRACER_INITIALIZER(false);
#endif
void grpc_lb_policy_init(grpc_lb_policy *policy, void grpc_lb_policy_init(grpc_lb_policy *policy,
const grpc_lb_policy_vtable *vtable, const grpc_lb_policy_vtable *vtable,

@ -29,7 +29,9 @@ typedef struct grpc_lb_policy grpc_lb_policy;
typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable; typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable;
typedef struct grpc_lb_policy_args grpc_lb_policy_args; typedef struct grpc_lb_policy_args grpc_lb_policy_args;
#ifndef NDEBUG
extern grpc_tracer_flag grpc_trace_lb_policy_refcount; extern grpc_tracer_flag grpc_trace_lb_policy_refcount;
#endif
struct grpc_lb_policy { struct grpc_lb_policy {
const grpc_lb_policy_vtable *vtable; const grpc_lb_policy_vtable *vtable;

@ -19,7 +19,9 @@
#include "src/core/ext/filters/client_channel/resolver.h" #include "src/core/ext/filters/client_channel/resolver.h"
#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/combiner.h"
#ifndef NDEBUG
grpc_tracer_flag grpc_trace_resolver_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_resolver_refcount = GRPC_TRACER_INITIALIZER(false);
#endif
void grpc_resolver_init(grpc_resolver *resolver, void grpc_resolver_init(grpc_resolver *resolver,
const grpc_resolver_vtable *vtable, const grpc_resolver_vtable *vtable,

@ -25,7 +25,9 @@
typedef struct grpc_resolver grpc_resolver; typedef struct grpc_resolver grpc_resolver;
typedef struct grpc_resolver_vtable grpc_resolver_vtable; typedef struct grpc_resolver_vtable grpc_resolver_vtable;
#ifndef NDEBUG
extern grpc_tracer_flag grpc_trace_resolver_refcount; extern grpc_tracer_flag grpc_trace_resolver_refcount;
#endif
/** \a grpc_resolver provides \a grpc_channel_args objects to its caller */ /** \a grpc_resolver provides \a grpc_channel_args objects to its caller */
struct grpc_resolver { struct grpc_resolver {

@ -24,7 +24,9 @@
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
#ifndef NDEBUG
grpc_tracer_flag grpc_trace_closure = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_closure = GRPC_TRACER_INITIALIZER(false);
#endif
#ifndef NDEBUG #ifndef NDEBUG
grpc_closure *grpc_closure_init(const char *file, int line, grpc_closure *grpc_closure_init(const char *file, int line,

@ -29,7 +29,9 @@
struct grpc_closure; struct grpc_closure;
typedef struct grpc_closure grpc_closure; typedef struct grpc_closure grpc_closure;
#ifndef NDEBUG
extern grpc_tracer_flag grpc_trace_closure; extern grpc_tracer_flag grpc_trace_closure;
#endif
typedef struct grpc_closure_list { typedef struct grpc_closure_list {
grpc_closure *head; grpc_closure *head;

@ -102,12 +102,12 @@ static void start_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
} }
} }
#ifdef GRPC_COMBINER_REFCOUNT_DEBUG #ifndef NDEBUG
#define GRPC_COMBINER_DEBUG_SPAM(op, delta) \ #define GRPC_COMBINER_DEBUG_SPAM(op, delta) \
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, \ if (GRPC_TRACER_ON(grpc_combiner_trace)) { gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, \
"combiner[%p] %s %" PRIdPTR " --> %" PRIdPTR " %s", lock, (op), \ "C:%p %s %" PRIdPTR " --> %" PRIdPTR " %s", lock, (op), \
gpr_atm_no_barrier_load(&lock->refs.count), \ gpr_atm_no_barrier_load(&lock->refs.count), \
gpr_atm_no_barrier_load(&lock->refs.count) + (delta), reason); gpr_atm_no_barrier_load(&lock->refs.count) + (delta), reason); }
#else #else
#define GRPC_COMBINER_DEBUG_SPAM(op, delta) #define GRPC_COMBINER_DEBUG_SPAM(op, delta)
#endif #endif

@ -35,8 +35,7 @@
// necessary // necessary
grpc_combiner *grpc_combiner_create(void); grpc_combiner *grpc_combiner_create(void);
//#define GRPC_COMBINER_REFCOUNT_DEBUG #ifndef NDEBUG
#ifdef GRPC_COMBINER_REFCOUNT_DEBUG
#define GRPC_COMBINER_DEBUG_ARGS \ #define GRPC_COMBINER_DEBUG_ARGS \
, const char *file, int line, const char *reason , const char *file, int line, const char *reason
#define GRPC_COMBINER_REF(combiner, reason) \ #define GRPC_COMBINER_REF(combiner, reason) \

@ -34,7 +34,9 @@
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_internal.h"
#ifndef NDEBUG
grpc_tracer_flag grpc_trace_error_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_error_refcount = GRPC_TRACER_INITIALIZER(false);
#endif
static const char *error_int_name(grpc_error_ints key) { static const char *error_int_name(grpc_error_ints key) {
switch (key) { switch (key) {

@ -38,7 +38,9 @@ extern "C" {
typedef struct grpc_error grpc_error; typedef struct grpc_error grpc_error;
#ifndef NDEBUG
extern grpc_tracer_flag grpc_trace_error_refcount; extern grpc_tracer_flag grpc_trace_error_refcount;
#endif
typedef enum { typedef enum {
/// 'errno' from the operating system /// 'errno' from the operating system

@ -161,20 +161,18 @@ static void fd_global_shutdown(void);
* Polling island Declarations * Polling island Declarations
*/ */
//#define PI_REFCOUNT_DEBUG #ifndef NDEBUG
#ifdef PI_REFCOUNT_DEBUG
#define PI_ADD_REF(p, r) pi_add_ref_dbg((p), (r), __FILE__, __LINE__) #define PI_ADD_REF(p, r) pi_add_ref_dbg((p), (r), __FILE__, __LINE__)
#define PI_UNREF(exec_ctx, p, r) \ #define PI_UNREF(exec_ctx, p, r) \
pi_unref_dbg((exec_ctx), (p), (r), __FILE__, __LINE__) pi_unref_dbg((exec_ctx), (p), (r), __FILE__, __LINE__)
#else /* defined(GRPC_WORKQUEUE_REFCOUNT_DEBUG) */ #else
#define PI_ADD_REF(p, r) pi_add_ref((p)) #define PI_ADD_REF(p, r) pi_add_ref((p))
#define PI_UNREF(exec_ctx, p, r) pi_unref((exec_ctx), (p)) #define PI_UNREF(exec_ctx, p, r) pi_unref((exec_ctx), (p))
#endif /* !defined(GRPC_PI_REF_COUNT_DEBUG) */ #endif
/* This is also used as grpc_workqueue (by directly casing it) */ /* This is also used as grpc_workqueue (by directly casing it) */
typedef struct polling_island { typedef struct polling_island {
@ -287,22 +285,27 @@ gpr_atm g_epoll_sync;
static void pi_add_ref(polling_island *pi); static void pi_add_ref(polling_island *pi);
static void pi_unref(grpc_exec_ctx *exec_ctx, polling_island *pi); static void pi_unref(grpc_exec_ctx *exec_ctx, polling_island *pi);
#ifdef PI_REFCOUNT_DEBUG #ifndef NDEBUG
grpc_tracer_flag grpc_trace_workqueue_refcount = GRPC_TRACER_INITIALIZER(false);
static void pi_add_ref_dbg(polling_island *pi, const char *reason, static void pi_add_ref_dbg(polling_island *pi, const char *reason,
const char *file, int line) { const char *file, int line) {
if (GRPC_TRACER_ON(grpc_trace_workqueue_refcount)) {
long old_cnt = gpr_atm_acq_load(&pi->ref_count); long old_cnt = gpr_atm_acq_load(&pi->ref_count);
pi_add_ref(pi);
gpr_log(GPR_DEBUG, "Add ref pi: %p, old: %ld -> new:%ld (%s) - (%s, %d)", gpr_log(GPR_DEBUG, "Add ref pi: %p, old: %ld -> new:%ld (%s) - (%s, %d)",
(void *)pi, old_cnt, old_cnt + 1, reason, file, line); (void *)pi, old_cnt, old_cnt + 1, reason, file, line);
} }
pi_add_ref(pi);
}
static void pi_unref_dbg(grpc_exec_ctx *exec_ctx, polling_island *pi, static void pi_unref_dbg(grpc_exec_ctx *exec_ctx, polling_island *pi,
const char *reason, const char *file, int line) { const char *reason, const char *file, int line) {
if (GRPC_TRACER_ON(grpc_trace_workqueue_refcount)) {
long old_cnt = gpr_atm_acq_load(&pi->ref_count); long old_cnt = gpr_atm_acq_load(&pi->ref_count);
pi_unref(exec_ctx, pi);
gpr_log(GPR_DEBUG, "Unref pi: %p, old:%ld -> new:%ld (%s) - (%s, %d)", gpr_log(GPR_DEBUG, "Unref pi: %p, old:%ld -> new:%ld (%s) - (%s, %d)",
(void *)pi, old_cnt, (old_cnt - 1), reason, file, line); (void *)pi, old_cnt, (old_cnt - 1), reason, file, line);
} }
pi_unref(exec_ctx, pi);
}
#endif #endif
static void pi_add_ref(polling_island *pi) { static void pi_add_ref(polling_island *pi) {

@ -1272,6 +1272,7 @@ static void pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
} }
/******************************************************************************* /*******************************************************************************
* Condition Variable polling extensions * Condition Variable polling extensions
*/ */

@ -38,6 +38,7 @@
#include "src/core/lib/iomgr/ev_poll_posix.h" #include "src/core/lib/iomgr/ev_poll_posix.h"
#include "src/core/lib/support/env.h" #include "src/core/lib/support/env.h"
grpc_tracer_flag grpc_polling_trace = grpc_tracer_flag grpc_polling_trace =
GRPC_TRACER_INITIALIZER(false); /* Disabled by default */ GRPC_TRACER_INITIALIZER(false); /* Disabled by default */

@ -31,7 +31,10 @@
#include "src/core/lib/support/string.h" #include "src/core/lib/support/string.h"
#include "src/core/lib/transport/transport_impl.h" #include "src/core/lib/transport/transport_impl.h"
#ifndef NDEBUG
grpc_tracer_flag grpc_trace_stream_refcount = GRPC_TRACER_INITIALIZER(false); grpc_tracer_flag grpc_trace_stream_refcount = GRPC_TRACER_INITIALIZER(false);
#endif
#ifndef NDEBUG #ifndef NDEBUG
void grpc_stream_ref(grpc_stream_refcount *refcount, const char *reason) { void grpc_stream_ref(grpc_stream_refcount *refcount, const char *reason) {

@ -42,7 +42,9 @@ typedef struct grpc_transport grpc_transport;
for a stream. */ for a stream. */
typedef struct grpc_stream grpc_stream; typedef struct grpc_stream grpc_stream;
#ifndef NDEBUG
extern grpc_tracer_flag grpc_trace_stream_refcount; extern grpc_tracer_flag grpc_trace_stream_refcount;
#endif
typedef struct grpc_stream_refcount { typedef struct grpc_stream_refcount {
gpr_refcount refs; gpr_refcount refs;

Loading…
Cancel
Save