aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr/combiner.cc
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2019-01-09 13:43:24 -0800
committerGravatar GitHub <noreply@github.com>2019-01-09 13:43:24 -0800
commit302e7b4d2b97a2f4742296234b66507842bb096b (patch)
tree0fd5eb3b5166604c83e98f7e51d6689b1bf84a51 /src/core/lib/iomgr/combiner.cc
parent54963bb90de38f6349f3dc3e82810f257c713621 (diff)
parent11eff929e24cae59ed21c2f3a0bde22a6dbe0d91 (diff)
Merge pull request #17658 from guantaol/avoid_thd_jump
Avoid the thread jump in server callback APIs.
Diffstat (limited to 'src/core/lib/iomgr/combiner.cc')
-rw-r--r--src/core/lib/iomgr/combiner.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc
index 7c0062eb4e..402f8904ea 100644
--- a/src/core/lib/iomgr/combiner.cc
+++ b/src/core/lib/iomgr/combiner.cc
@@ -29,6 +29,7 @@
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/iomgr/executor.h"
+#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/profiling/timers.h"
grpc_core::DebugOnlyTraceFlag grpc_combiner_trace(false, "combiner");
@@ -228,8 +229,14 @@ bool grpc_combiner_continue_exec_ctx() {
grpc_core::ExecCtx::Get()->IsReadyToFinish(),
lock->time_to_execute_final_list));
+ // offload only if all the following conditions are true:
+ // 1. the combiner is contended and has more than one closure to execute
+ // 2. the current execution context needs to finish as soon as possible
+ // 3. the DEFAULT executor is threaded
+ // 4. the current thread is not a worker for any background poller
if (contended && grpc_core::ExecCtx::Get()->IsReadyToFinish() &&
- grpc_executor_is_threaded()) {
+ grpc_executor_is_threaded() &&
+ !grpc_iomgr_is_any_background_poller_thread()) {
GPR_TIMER_MARK("offload_from_finished_exec_ctx", 0);
// this execution context wants to move on: schedule remaining work to be
// picked up on the executor