diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index a55483e3e0e..aa6a23abe5a 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -243,6 +243,7 @@ message ScenarioResultSummary double failed_requests_per_second = 14; double client_polls_per_request = 15; + double server_polls_per_request = 16; } // Results of a single benchmark scenario. diff --git a/src/proto/grpc/testing/stats.proto b/src/proto/grpc/testing/stats.proto index 8818f70cc5f..78df5333421 100644 --- a/src/proto/grpc/testing/stats.proto +++ b/src/proto/grpc/testing/stats.proto @@ -47,6 +47,8 @@ message ServerStats { // change in idle time of the server (data from proc/stat) uint64 idle_cpu_time = 5; + + uint64 cq_poll_count = 6; } // Histogram params based on grpc/support/histogram.c diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index c4cae286fde..24e9f730af1 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -112,7 +112,8 @@ static deque get_workers(const string& env_name) { static double WallTime(ClientStats s) { return s.time_elapsed(); } static double SystemTime(ClientStats s) { return s.time_system(); } static double UserTime(ClientStats s) { return s.time_user(); } -static double PollCount(ClientStats s) { return s.cq_poll_count(); } +static double CliPollCount(ClientStats s) { return s.cq_poll_count(); } +static double SvrPollCount(ServerStats s) { return s.cq_poll_count(); } static double ServerWallTime(ServerStats s) { return s.time_elapsed(); } static double ServerSystemTime(ServerStats s) { return s.time_system(); } static double ServerUserTime(ServerStats s) { return s.time_user(); } @@ -181,8 +182,10 @@ static void postprocess_scenario_result(ScenarioResult* result) { result->mutable_summary()->set_failed_requests_per_second(failures / time_estimate); } - gpr_log(GPR_INFO, "poll count : %f", sum(result->client_stats(), PollCount)); - result->mutable_summary()->set_client_polls_per_request(sum(result->client_stats(), PollCount)/histogram.Count()); + gpr_log(GPR_INFO, "client poll count : %f", sum(result->client_stats(), CliPollCount)); + result->mutable_summary()->set_client_polls_per_request(sum(result->client_stats(), CliPollCount)/histogram.Count()); + gpr_log(GPR_INFO, "server poll count : %f", sum(result->server_stats(), SvrPollCount)); + result->mutable_summary()->set_server_polls_per_request(sum(result->server_stats(), SvrPollCount)/histogram.Count()); } std::unique_ptr RunScenario( diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index ae56b0e8574..8bb4c9a3a50 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -128,8 +128,10 @@ void GprLogReporter::ReportCpuUsage(const ScenarioResult& result) { } void GprLogReporter::ReportPollCount(const ScenarioResult& result) { - gpr_log(GPR_INFO, "Client Polls per Request: %.2f%%", + gpr_log(GPR_INFO, "Client Polls per Request: %.2f", result.summary().client_polls_per_request()); + gpr_log(GPR_INFO, "Server Polls per Request: %.2f", + result.summary().server_polls_per_request()); } void JsonReporter::ReportQPS(const ScenarioResult& result) { diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 8fbf37a0957..5d5d5ffe096 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -49,7 +49,7 @@ namespace testing { class Server { public: - explicit Server(const ServerConfig& config) : timer_(new UsageTimer) { + explicit Server(const ServerConfig& config) : timer_(new UsageTimer), last_reset_poll_count_(0) { cores_ = gpr_cpu_num_cores(); if (config.port()) { port_ = config.port(); @@ -62,10 +62,12 @@ class Server { ServerStats Mark(bool reset) { UsageTimer::Result timer_result; + int last_reset_poll_count_to_use = last_reset_poll_count_; if (reset) { std::unique_ptr timer(new UsageTimer); timer.swap(timer_); timer_result = timer->Mark(); + last_reset_poll_count_ = GetPollCount(); } else { timer_result = timer_->Mark(); } @@ -76,6 +78,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); return stats; } @@ -106,10 +109,16 @@ class Server { } } + virtual int GetPollCount() { + // For sync server. + return 0; + } + private: int port_; int cores_; std::unique_ptr timer_; + int last_reset_poll_count_; }; std::unique_ptr CreateSynchronousServer(const ServerConfig& config); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index b499b82091e..e503e622047 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -53,6 +53,10 @@ #include "test/core/util/test_config.h" #include "test/cpp/qps/server.h" +extern "C" { +#include "src/core/lib/surface/completion_queue.h" +} + namespace grpc { namespace testing { @@ -154,6 +158,16 @@ class AsyncQpsServerTest final : public grpc::testing::Server { shutdown_thread.join(); } + 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; + } + return count; + } private: void ShutdownThreadFunc() { // TODO (vpai): Remove this deadline and allow Shutdown to finish properly