diff options
author | Craig Tiller <ctiller@google.com> | 2017-06-02 16:05:47 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-06-02 16:05:47 -0700 |
commit | 0d8b98da1f04d643fcc1baa9be3acfb99cb3b09a (patch) | |
tree | 808d69c405aa8d9e17b5412d8d7cefe9f2dcb1d1 /src | |
parent | 54f8d9835c7ccef56113f8d36f0a68de51dd7174 (diff) | |
parent | 27cb323c5941146202853dd6e30fda30760c6acf (diff) |
Merge branch 'faster_timer_pool' into ALL-the-things
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lib/iomgr/timer_generic.c | 5 | ||||
-rw-r--r-- | src/core/lib/iomgr/timer_manager.c | 12 | ||||
-rw-r--r-- | src/core/lib/support/log.c | 6 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/core/lib/iomgr/timer_generic.c b/src/core/lib/iomgr/timer_generic.c index 288782c060..019cd8f309 100644 --- a/src/core/lib/iomgr/timer_generic.c +++ b/src/core/lib/iomgr/timer_generic.c @@ -433,7 +433,7 @@ static grpc_timer_check_result run_some_expired_timers(grpc_exec_ctx *exec_ctx, gpr_tls_set(&g_last_seen_min_timer, min_timer); if (now < min_timer) { if (next != NULL) *next = GPR_MIN(*next, min_timer); - return 0; + return GRPC_TIMERS_CHECKED_AND_EMPTY; } if (gpr_spinlock_trylock(&g_shared_mutables.checker_mu)) { @@ -553,8 +553,7 @@ grpc_timer_check_result grpc_timer_check(grpc_exec_ctx *exec_ctx, gpr_asprintf(&next_str, "%" PRId64 ".%09d [%" PRIdPTR "]", next->tv_sec, next->tv_nsec, next_atm); } - gpr_log(GPR_DEBUG, "TIMER CHECK END: %d timers triggered; next=%s", r, - next_str); + gpr_log(GPR_DEBUG, "TIMER CHECK END: r=%d; next=%s", r, next_str); gpr_free(next_str); } return r; diff --git a/src/core/lib/iomgr/timer_manager.c b/src/core/lib/iomgr/timer_manager.c index 767bb64961..082dfe8299 100644 --- a/src/core/lib/iomgr/timer_manager.c +++ b/src/core/lib/iomgr/timer_manager.c @@ -143,7 +143,10 @@ static bool wait_until(gpr_timespec next) { const gpr_timespec inf_future = gpr_inf_future(GPR_CLOCK_MONOTONIC); gpr_mu_lock(&g_mu); // if we're not threaded anymore, leave - if (!g_threaded) return false; + if (!g_threaded) { + gpr_mu_unlock(&g_mu); + return false; + } // if there's no timed waiter, we should become one: that waiter waits // only until the next timer should expire // all other timers wait forever @@ -155,7 +158,9 @@ static bool wait_until(gpr_timespec next) { // figure stuff out instead of incurring a wakeup) my_timed_waiter_generation = ++g_timed_waiter_generation; if (GRPC_TRACER_ON(grpc_timer_check_trace)) { - gpr_log(GPR_DEBUG, "sleep for a while"); + gpr_timespec wait_time = gpr_time_sub(next, gpr_now(GPR_CLOCK_MONOTONIC)); + gpr_log(GPR_DEBUG, "sleep for a %" PRId64 ".%09d seconds", + wait_time.tv_sec, wait_time.tv_nsec); } } else { next = inf_future; @@ -204,6 +209,9 @@ static void timer_main_loop(grpc_exec_ctx *exec_ctx) { Consequently, we can just sleep forever here and be happy at some saved wakeup cycles. */ + if (GRPC_TRACER_ON(grpc_timer_check_trace)) { + gpr_log(GPR_DEBUG, "timers not checked: expect another thread to"); + } next = inf_future; /* fall through */ case GRPC_TIMERS_CHECKED_AND_EMPTY: diff --git a/src/core/lib/support/log.c b/src/core/lib/support/log.c index af1651dae5..4d15553768 100644 --- a/src/core/lib/support/log.c +++ b/src/core/lib/support/log.c @@ -43,7 +43,7 @@ #include <string.h> extern void gpr_default_log(gpr_log_func_args *args); -static gpr_log_func g_log_func = gpr_default_log; +static gpr_atm g_log_func = (gpr_atm)gpr_default_log; static gpr_atm g_min_severity_to_print = GPR_LOG_VERBOSITY_UNSET; const char *gpr_log_severity_string(gpr_log_severity severity) { @@ -70,7 +70,7 @@ void gpr_log_message(const char *file, int line, gpr_log_severity severity, lfargs.line = line; lfargs.severity = severity; lfargs.message = message; - g_log_func(&lfargs); + ((gpr_log_func)gpr_atm_no_barrier_load(&g_log_func))(&lfargs); } void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) { @@ -99,5 +99,5 @@ void gpr_log_verbosity_init() { } void gpr_set_log_function(gpr_log_func f) { - g_log_func = f ? f : gpr_default_log; + gpr_atm_no_barrier_store(&g_log_func, (gpr_atm)(f ? f : gpr_default_log)); } |