diff options
author | Noah Eisen <ncteisen@gmail.com> | 2018-05-23 14:10:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-23 14:10:55 -0700 |
commit | 1bd0debdc7f57f2d51716789660b895a6c229350 (patch) | |
tree | 56d246487b1a5426ed72041647cb0c0e9bd07c85 | |
parent | f30db9db2320e533c1ffed9bc9b80ca7b2a457be (diff) | |
parent | b500281f91ca020c388f5036aa9a9b9abe328877 (diff) |
Merge pull request #15516 from ncteisen/cull-the-tracers
Create GRPC_USE_TRACERS to support OSS/internal difference
-rw-r--r-- | src/core/lib/debug/trace.h | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/lib/debug/trace.h b/src/core/lib/debug/trace.h index 28157c6383..fe6301a3fc 100644 --- a/src/core/lib/debug/trace.h +++ b/src/core/lib/debug/trace.h @@ -57,14 +57,14 @@ class TraceFlag { const char* name() const { return name_; } -// This following define may be commented out to ensure that the compiler -// deletes any "if (tracer.enabled()) {...}" codeblocks. This is useful to -// test the performance impact tracers have on the system. -// -// #define COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD -#ifdef COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD - bool enabled() { return false; } -#else +// Use the symbol GRPC_USE_TRACERS to determine if tracers will be enabled in +// opt builds (tracers are always on in dbg builds). The default in OSS is for +// tracers to be on since we support binary distributions of gRPC for the +// wrapped language (wr don't want to force recompilation to get tracing). +// Internally, however, for performance reasons, we compile them out by +// default, since internal build systems make recompiling trivial. +#define GRPC_USE_TRACERS // tracers on by default in OSS +#if defined(GRPC_USE_TRACERS) || !defined(NDEBUG) bool enabled() { #ifdef GRPC_THREADSAFE_TRACER return gpr_atm_no_barrier_load(&value_) != 0; @@ -72,7 +72,9 @@ class TraceFlag { return value_; #endif // GRPC_THREADSAFE_TRACER } -#endif // COMPILE_OUT_ALL_TRACERS_IN_OPT_BUILD +#else + bool enabled() { return false; } +#endif /* defined(GRPC_USE_TRACERS) || !defined(NDEBUG) */ private: friend void grpc_core::testing::grpc_tracer_enable_flag(TraceFlag* flag); |