adding server side poll stat

pull/11000/head
Yuxuan Li 8 years ago
parent 999ac157e6
commit 5d3ddeeea1
  1. 1
      src/proto/grpc/testing/control.proto
  2. 2
      src/proto/grpc/testing/stats.proto
  3. 9
      test/cpp/qps/driver.cc
  4. 4
      test/cpp/qps/report.cc
  5. 11
      test/cpp/qps/server.h
  6. 14
      test/cpp/qps/server_async.cc

@ -243,6 +243,7 @@ message ScenarioResultSummary
double failed_requests_per_second = 14; double failed_requests_per_second = 14;
double client_polls_per_request = 15; double client_polls_per_request = 15;
double server_polls_per_request = 16;
} }
// Results of a single benchmark scenario. // Results of a single benchmark scenario.

@ -47,6 +47,8 @@ message ServerStats {
// change in idle time of the server (data from proc/stat) // change in idle time of the server (data from proc/stat)
uint64 idle_cpu_time = 5; uint64 idle_cpu_time = 5;
uint64 cq_poll_count = 6;
} }
// Histogram params based on grpc/support/histogram.c // Histogram params based on grpc/support/histogram.c

@ -112,7 +112,8 @@ static deque<string> get_workers(const string& env_name) {
static double WallTime(ClientStats s) { return s.time_elapsed(); } static double WallTime(ClientStats s) { return s.time_elapsed(); }
static double SystemTime(ClientStats s) { return s.time_system(); } static double SystemTime(ClientStats s) { return s.time_system(); }
static double UserTime(ClientStats s) { return s.time_user(); } 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 ServerWallTime(ServerStats s) { return s.time_elapsed(); }
static double ServerSystemTime(ServerStats s) { return s.time_system(); } static double ServerSystemTime(ServerStats s) { return s.time_system(); }
static double ServerUserTime(ServerStats s) { return s.time_user(); } 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 / result->mutable_summary()->set_failed_requests_per_second(failures /
time_estimate); time_estimate);
} }
gpr_log(GPR_INFO, "poll count : %f", sum(result->client_stats(), PollCount)); 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(), PollCount)/histogram.Count()); 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<ScenarioResult> RunScenario( std::unique_ptr<ScenarioResult> RunScenario(

@ -128,8 +128,10 @@ void GprLogReporter::ReportCpuUsage(const ScenarioResult& result) {
} }
void GprLogReporter::ReportPollCount(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()); 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) { void JsonReporter::ReportQPS(const ScenarioResult& result) {

@ -49,7 +49,7 @@ namespace testing {
class Server { class Server {
public: 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(); cores_ = gpr_cpu_num_cores();
if (config.port()) { if (config.port()) {
port_ = config.port(); port_ = config.port();
@ -62,10 +62,12 @@ class Server {
ServerStats Mark(bool reset) { ServerStats Mark(bool reset) {
UsageTimer::Result timer_result; UsageTimer::Result timer_result;
int last_reset_poll_count_to_use = last_reset_poll_count_;
if (reset) { if (reset) {
std::unique_ptr<UsageTimer> timer(new UsageTimer); std::unique_ptr<UsageTimer> timer(new UsageTimer);
timer.swap(timer_); timer.swap(timer_);
timer_result = timer->Mark(); timer_result = timer->Mark();
last_reset_poll_count_ = GetPollCount();
} else { } else {
timer_result = timer_->Mark(); timer_result = timer_->Mark();
} }
@ -76,6 +78,7 @@ class Server {
stats.set_time_user(timer_result.user); stats.set_time_user(timer_result.user);
stats.set_total_cpu_time(timer_result.total_cpu_time); stats.set_total_cpu_time(timer_result.total_cpu_time);
stats.set_idle_cpu_time(timer_result.idle_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; return stats;
} }
@ -106,10 +109,16 @@ class Server {
} }
} }
virtual int GetPollCount() {
// For sync server.
return 0;
}
private: private:
int port_; int port_;
int cores_; int cores_;
std::unique_ptr<UsageTimer> timer_; std::unique_ptr<UsageTimer> timer_;
int last_reset_poll_count_;
}; };
std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config); std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config);

@ -53,6 +53,10 @@
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/qps/server.h" #include "test/cpp/qps/server.h"
extern "C" {
#include "src/core/lib/surface/completion_queue.h"
}
namespace grpc { namespace grpc {
namespace testing { namespace testing {
@ -154,6 +158,16 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
shutdown_thread.join(); 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: private:
void ShutdownThreadFunc() { void ShutdownThreadFunc() {
// TODO (vpai): Remove this deadline and allow Shutdown to finish properly // TODO (vpai): Remove this deadline and allow Shutdown to finish properly

Loading…
Cancel
Save