From f8365cd87b5e76dbc050c0c2647e2875a07bca68 Mon Sep 17 00:00:00 2001 From: Yuxuan Li Date: Wed, 3 May 2017 23:29:17 -0700 Subject: [PATCH] clean up, fix minor issue --- src/core/lib/surface/completion_queue.c | 10 +++++----- test/cpp/qps/client.h | 10 ++++------ test/cpp/qps/client_async.cc | 5 +---- test/cpp/qps/server.h | 7 ++++--- test/cpp/qps/server_async.cc | 5 +---- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index bfdd7f22fda..346ea18d5ae 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -227,7 +227,7 @@ struct grpc_completion_queue { /* TODO: sreek - This will no longer be needed. Use polling_type set */ int is_non_listening_server_cq; int num_pluckers; - gpr_atm num_poll; + gpr_atm num_polls; plucker pluckers[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS]; grpc_closure pollset_shutdown_done; @@ -293,7 +293,7 @@ grpc_completion_queue *grpc_completion_queue_create_internal( cc->is_server_cq = 0; cc->is_non_listening_server_cq = 0; cc->num_pluckers = 0; - gpr_atm_no_barrier_store(&cc->num_poll, 0); + gpr_atm_no_barrier_store(&cc->num_polls, 0); gpr_atm_no_barrier_store(&cc->things_queued_ever, 0); #ifndef NDEBUG cc->outstanding_tag_count = 0; @@ -311,7 +311,7 @@ grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cc) { } gpr_atm grpc_get_cq_poll_num(grpc_completion_queue *cc) { - return gpr_atm_no_barrier_load(&cc->num_poll); + return gpr_atm_no_barrier_load(&cc->num_polls); } #ifdef GRPC_CQ_REF_COUNT_DEBUG @@ -598,7 +598,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, gpr_mu_lock(cc->mu); continue; } else { - cc->num_poll++; + gpr_atm_no_barrier_fetch_add(&cc->num_polls, 1); grpc_error *err = cc->poller_vtable->work(&exec_ctx, POLLSET_FROM_CQ(cc), NULL, now, iteration_deadline); if (err != GRPC_ERROR_NONE) { @@ -791,7 +791,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(cc->mu); } else { - gpr_atm_no_barrier_fetch_add(&cc->num_poll, 1); + gpr_atm_no_barrier_fetch_add(&cc->num_polls, 1); grpc_error *err = cc->poller_vtable->work( &exec_ctx, POLLSET_FROM_CQ(cc), &worker, now, iteration_deadline); if (err != GRPC_ERROR_NONE) { diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 173f5ab0c43..8006cacedd7 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -163,7 +163,8 @@ class Client { MaybeStartRequests(); - int last_reset_poll_count_to_use = last_reset_poll_count_; + int cur_poll_count = GetPollCount(); + int poll_count = cur_poll_count - last_reset_poll_count_; if (reset) { std::vector to_merge(threads_.size()); std::vector to_merge_status(threads_.size()); @@ -178,7 +179,7 @@ class Client { MergeStatusHistogram(to_merge_status[i], &statuses); } timer_result = timer->Mark(); - last_reset_poll_count_ = GetPollCount(); + last_reset_poll_count_ = cur_poll_count; } else { // merge snapshots of each thread histogram for (size_t i = 0; i < threads_.size(); i++) { @@ -198,10 +199,7 @@ class Client { stats.set_time_elapsed(timer_result.wall); stats.set_time_system(timer_result.system); stats.set_time_user(timer_result.user); - gpr_log(GPR_INFO, "*****poll count : %d %d %d", GetPollCount(), - last_reset_poll_count_, last_reset_poll_count_to_use); - - stats.set_cq_poll_count(GetPollCount() - last_reset_poll_count_to_use); + stats.set_cq_poll_count(poll_count); return stats; } diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 49f9b5ca40e..05756f0563c 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -211,11 +211,8 @@ class AsyncClient : public ClientImpl { int GetPollCount() { int count = 0; - // int i = 0; for (auto cq = cli_cqs_.begin(); cq != cli_cqs_.end(); cq++) { - int k = (int)grpc_get_cq_poll_num((*cq)->cq()); - // gpr_log(GPR_INFO, "%d: per cq poll:%d", i++, k); - count += k; + count += (int)grpc_get_cq_poll_num((*cq)->cq()); } return count; } diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index e9951564cbd..d75f3795766 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -63,12 +63,13 @@ class Server { ServerStats Mark(bool reset) { UsageTimer::Result timer_result; - int last_reset_poll_count_to_use = last_reset_poll_count_; + int cur_poll_count = GetPollCount(); + int poll_count = cur_poll_count - last_reset_poll_count_; if (reset) { std::unique_ptr timer(new UsageTimer); timer.swap(timer_); timer_result = timer->Mark(); - last_reset_poll_count_ = GetPollCount(); + last_reset_poll_count_ = cur_poll_count; } else { timer_result = timer_->Mark(); } @@ -79,7 +80,7 @@ class Server { stats.set_time_user(timer_result.user); stats.set_total_cpu_time(timer_result.total_cpu_time); stats.set_idle_cpu_time(timer_result.idle_cpu_time); - stats.set_cq_poll_count(GetPollCount() - last_reset_poll_count_to_use); + stats.set_cq_poll_count(poll_count); return stats; } diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 4bd7af3d2da..7d00cb33dce 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -160,11 +160,8 @@ class AsyncQpsServerTest final : public grpc::testing::Server { int GetPollCount() { int count = 0; - // int i = 0; for (auto cq = srv_cqs_.begin(); cq != srv_cqs_.end(); cq++) { - int k = (int)grpc_get_cq_poll_num((*cq)->cq()); - // gpr_log(GPR_INFO, "%d: per cq poll:%d", i++, k); - count += k; + count += (int)grpc_get_cq_poll_num((*cq)->cq()); } return count; }