clean up, fix minor issue

pull/11000/head
Yuxuan Li 8 years ago
parent 28efff3e1e
commit f8365cd87b
  1. 10
      src/core/lib/surface/completion_queue.c
  2. 10
      test/cpp/qps/client.h
  3. 5
      test/cpp/qps/client_async.cc
  4. 7
      test/cpp/qps/server.h
  5. 5
      test/cpp/qps/server_async.cc

@ -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) {

@ -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<Histogram> to_merge(threads_.size());
std::vector<StatusHistogram> 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;
}

@ -211,11 +211,8 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
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;
}

@ -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<UsageTimer> 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;
}

@ -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;
}

Loading…
Cancel
Save