aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks/bm_pollset.cc
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-12-06 09:47:54 -0800
committerGravatar GitHub <noreply@github.com>2017-12-06 09:47:54 -0800
commit8cf1470a51ea276ca84825e7495d4ee24743540d (patch)
tree72385cc865094115bc08cb813201d48cb09840bb /test/cpp/microbenchmarks/bm_pollset.cc
parent1d4e99508409be052bd129ba507bae1fbe7eb7fa (diff)
Revert "Revert "All instances of exec_ctx being passed around in src/core removed""
Diffstat (limited to 'test/cpp/microbenchmarks/bm_pollset.cc')
-rw-r--r--test/cpp/microbenchmarks/bm_pollset.cc53
1 files changed, 25 insertions, 28 deletions
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc
index 4da79693f1..d9d5164cce 100644
--- a/test/cpp/microbenchmarks/bm_pollset.cc
+++ b/test/cpp/microbenchmarks/bm_pollset.cc
@@ -41,8 +41,8 @@
auto& force_library_initialization = Library::get();
-static void shutdown_ps(grpc_exec_ctx* exec_ctx, void* ps, grpc_error* error) {
- grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(ps));
+static void shutdown_ps(void* ps, grpc_error* error) {
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(ps));
}
static void BM_CreateDestroyPollset(benchmark::State& state) {
@@ -50,7 +50,7 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
size_t ps_sz = grpc_pollset_size();
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_malloc(ps_sz));
gpr_mu* mu;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
@@ -58,11 +58,11 @@ static void BM_CreateDestroyPollset(benchmark::State& state) {
memset(ps, 0, ps_sz);
grpc_pollset_init(ps, &mu);
gpr_mu_lock(mu);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@@ -114,17 +114,17 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_mu_lock(mu);
while (state.KeepRunning()) {
- GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, nullptr, 0));
+ GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, 0));
}
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@@ -136,24 +136,23 @@ static void BM_PollAddFd(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_wakeup_fd wakeup_fd;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd)));
grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx");
while (state.KeepRunning()) {
- grpc_pollset_add_fd(&exec_ctx, ps, fd);
- grpc_exec_ctx_flush(&exec_ctx);
+ grpc_pollset_add_fd(ps, fd);
+ grpc_core::ExecCtx::Get()->Flush();
}
- grpc_fd_orphan(&exec_ctx, fd, nullptr, nullptr, false /* already_closed */,
- "xxx");
+ grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, "xxx");
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
gpr_mu_lock(mu);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(ps);
track_counters.Finish(state);
}
@@ -170,7 +169,7 @@ Closure* MakeClosure(F f, grpc_closure_scheduler* scheduler) {
C(F f, grpc_closure_scheduler* scheduler) : f_(f) {
GRPC_CLOSURE_INIT(this, C::cbfn, this, scheduler);
}
- static void cbfn(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+ static void cbfn(void* arg, grpc_error* error) {
C* p = static_cast<C*>(arg);
p->f_();
}
@@ -219,11 +218,11 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
gpr_mu* mu;
grpc_pollset_init(ps, &mu);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_wakeup_fd wakeup_fd;
GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd));
grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read");
- grpc_pollset_add_fd(&exec_ctx, ps, wakeup);
+ grpc_pollset_add_fd(ps, wakeup);
bool done = false;
Closure* continue_closure = MakeClosure(
[&]() {
@@ -233,25 +232,23 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
return;
}
GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd));
- grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
+ grpc_fd_notify_on_read(wakeup, continue_closure);
},
grpc_schedule_on_exec_ctx);
GRPC_ERROR_UNREF(grpc_wakeup_fd_wakeup(&wakeup_fd));
- grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
+ grpc_fd_notify_on_read(wakeup, continue_closure);
gpr_mu_lock(mu);
while (!done) {
- GRPC_ERROR_UNREF(
- grpc_pollset_work(&exec_ctx, ps, nullptr, GRPC_MILLIS_INF_FUTURE));
+ GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, GRPC_MILLIS_INF_FUTURE));
}
- grpc_fd_orphan(&exec_ctx, wakeup, nullptr, nullptr,
- false /* already_closed */, "done");
+ grpc_fd_orphan(wakeup, nullptr, nullptr, false /* already_closed */, "done");
wakeup_fd.read_fd = 0;
grpc_closure shutdown_ps_closure;
GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps,
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ grpc_pollset_shutdown(ps, &shutdown_ps_closure);
gpr_mu_unlock(mu);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
grpc_wakeup_fd_destroy(&wakeup_fd);
gpr_free(ps);
track_counters.Finish(state);