aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/qps
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpp/qps')
-rw-r--r--test/cpp/qps/BUILD41
-rw-r--r--test/cpp/qps/client.h15
-rw-r--r--test/cpp/qps/client_async.cc8
-rw-r--r--test/cpp/qps/client_sync.cc1
-rw-r--r--test/cpp/qps/driver.cc7
-rw-r--r--test/cpp/qps/qps_json_driver.cc1
-rw-r--r--test/cpp/qps/report.cc21
-rw-r--r--test/cpp/qps/report.h7
-rw-r--r--test/cpp/qps/server.h14
-rw-r--r--test/cpp/qps/server_async.cc8
10 files changed, 104 insertions, 19 deletions
diff --git a/test/cpp/qps/BUILD b/test/cpp/qps/BUILD
index 6492b63ec3..c6a1fd2fce 100644
--- a/test/cpp/qps/BUILD
+++ b/test/cpp/qps/BUILD
@@ -29,14 +29,17 @@
licenses(["notice"]) # 3-clause BSD
-cc_library(
+load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_cc_library", "grpc_cc_binary")
+
+grpc_cc_library(
name = "parse_json",
srcs = ["parse_json.cc"],
hdrs = ["parse_json.h"],
deps = ["//:grpc++"],
+ external_deps = ["protobuf"],
)
-cc_library(
+grpc_cc_library(
name = "qps_worker_impl",
srcs = [
"client_async.cc",
@@ -56,7 +59,6 @@ cc_library(
":usage_timer",
"//:grpc",
"//:grpc++",
- "//external:gtest",
"//src/proto/grpc/testing:control_proto",
"//src/proto/grpc/testing:payloads_proto",
"//src/proto/grpc/testing:services_proto",
@@ -65,9 +67,12 @@ cc_library(
"//test/core/util:grpc_test_util",
"//test/cpp/util:test_util",
],
+ external_deps = [
+ "gtest",
+ ],
)
-cc_library(
+grpc_cc_library(
name = "driver_impl",
srcs = [
"driver.cc",
@@ -90,7 +95,7 @@ cc_library(
],
)
-cc_library(
+grpc_cc_library(
name = "benchmark_config",
srcs = [
"benchmark_config.cc",
@@ -102,12 +107,14 @@ cc_library(
":driver_impl",
":histogram",
"//:grpc++",
- "//external:gflags",
"//src/proto/grpc/testing:control_proto",
],
+ external_deps = [
+ "gflags",
+ ],
)
-cc_library(
+grpc_cc_library(
name = "histogram",
hdrs = [
"histogram.h",
@@ -116,13 +123,13 @@ cc_library(
deps = ["//:gpr"],
)
-cc_library(
+grpc_cc_library(
name = "interarrival",
hdrs = ["interarrival.h"],
deps = ["//:grpc++"],
)
-cc_binary(
+grpc_cc_binary(
name = "json_run_localhost",
srcs = ["json_run_localhost.cc"],
deps = [
@@ -133,7 +140,7 @@ cc_binary(
],
)
-cc_test(
+grpc_cc_test(
name = "qps_interarrival_test",
srcs = ["qps_interarrival_test.cc"],
deps = [
@@ -142,18 +149,20 @@ cc_test(
],
)
-cc_binary(
+grpc_cc_binary(
name = "qps_json_driver",
srcs = ["qps_json_driver.cc"],
deps = [
":benchmark_config",
":driver_impl",
"//:grpc++",
- "//external:gflags",
+ ],
+ external_deps = [
+ "gflags",
],
)
-cc_test(
+grpc_cc_test(
name = "qps_openloop_test",
srcs = ["qps_openloop_test.cc"],
deps = [
@@ -163,7 +172,7 @@ cc_test(
],
)
-cc_test(
+grpc_cc_test(
name = "secure_sync_unary_ping_pong_test",
srcs = ["secure_sync_unary_ping_pong_test.cc"],
deps = [
@@ -173,14 +182,14 @@ cc_test(
],
)
-cc_library(
+grpc_cc_library(
name = "usage_timer",
srcs = ["usage_timer.cc"],
hdrs = ["usage_timer.h"],
deps = ["//:gpr"],
)
-cc_binary(
+grpc_cc_binary(
name = "qps_worker",
srcs = ["worker.cc"],
deps = [
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index c3197eb622..5ae6b54f89 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -46,6 +46,7 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
+#include "src/core/lib/surface/completion_queue.h"
#include "src/proto/grpc/testing/payloads.pb.h"
#include "src/proto/grpc/testing/services.grpc.pb.h"
@@ -150,7 +151,8 @@ class Client {
Client()
: timer_(new UsageTimer),
interarrival_timer_(),
- started_requests_(false) {
+ started_requests_(false),
+ last_reset_poll_count_(0) {
gpr_event_init(&start_requests_);
}
virtual ~Client() {}
@@ -162,6 +164,8 @@ class Client {
MaybeStartRequests();
+ 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());
@@ -176,6 +180,7 @@ class Client {
MergeStatusHistogram(to_merge_status[i], &statuses);
}
timer_result = timer->Mark();
+ last_reset_poll_count_ = cur_poll_count;
} else {
// merge snapshots of each thread histogram
for (size_t i = 0; i < threads_.size(); i++) {
@@ -195,6 +200,7 @@ class Client {
stats.set_time_elapsed(timer_result.wall);
stats.set_time_system(timer_result.system);
stats.set_time_user(timer_result.user);
+ stats.set_cq_poll_count(poll_count);
return stats;
}
@@ -209,6 +215,11 @@ class Client {
}
}
+ virtual int GetPollCount() {
+ // For sync client.
+ return 0;
+ }
+
protected:
bool closed_loop_;
gpr_atm thread_pool_done_;
@@ -351,6 +362,8 @@ class Client {
gpr_event start_requests_;
bool started_requests_;
+ int last_reset_poll_count_;
+
void MaybeStartRequests() {
if (!started_requests_) {
started_requests_ = true;
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index 82c3356f02..6b8f736813 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -205,6 +205,14 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
}
}
+ int GetPollCount() override {
+ int count = 0;
+ for (auto cq = cli_cqs_.begin(); cq != cli_cqs_.end(); cq++) {
+ count += grpc_get_cq_poll_num((*cq)->cq());
+ }
+ return count;
+ }
+
protected:
const int num_async_threads_;
diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc
index 9075033bd4..f35713280a 100644
--- a/test/cpp/qps/client_sync.cc
+++ b/test/cpp/qps/client_sync.cc
@@ -48,7 +48,6 @@
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
-#include <gtest/gtest.h>
#include "src/core/lib/profiling/timers.h"
#include "src/proto/grpc/testing/services.grpc.pb.h"
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index 74fe3662c1..ace5028876 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -112,6 +112,8 @@ static deque<string> 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 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(); }
@@ -180,6 +182,11 @@ static void postprocess_scenario_result(ScenarioResult* result) {
result->mutable_summary()->set_failed_requests_per_second(failures /
time_estimate);
}
+
+ result->mutable_summary()->set_client_polls_per_request(
+ sum(result->client_stats(), CliPollCount) / histogram.Count());
+ result->mutable_summary()->set_server_polls_per_request(
+ sum(result->server_stats(), SvrPollCount) / histogram.Count());
}
std::unique_ptr<ScenarioResult> RunScenario(
diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc
index a906137474..f00f771ea0 100644
--- a/test/cpp/qps/qps_json_driver.cc
+++ b/test/cpp/qps/qps_json_driver.cc
@@ -94,6 +94,7 @@ static std::unique_ptr<ScenarioResult> RunAndReport(const Scenario& scenario,
GetReporter()->ReportLatency(*result);
GetReporter()->ReportTimes(*result);
GetReporter()->ReportCpuUsage(*result);
+ GetReporter()->ReportPollCount(*result);
for (int i = 0; *success && i < result->client_success_size(); i++) {
*success = result->client_success(i);
diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc
index a9130bf5d4..8bb4c9a3a5 100644
--- a/test/cpp/qps/report.cc
+++ b/test/cpp/qps/report.cc
@@ -80,6 +80,12 @@ void CompositeReporter::ReportCpuUsage(const ScenarioResult& result) {
}
}
+void CompositeReporter::ReportPollCount(const ScenarioResult& result) {
+ for (size_t i = 0; i < reporters_.size(); ++i) {
+ reporters_[i]->ReportPollCount(result);
+ }
+}
+
void GprLogReporter::ReportQPS(const ScenarioResult& result) {
gpr_log(GPR_INFO, "QPS: %.1f", result.summary().qps());
if (result.summary().failed_requests_per_second() > 0) {
@@ -121,6 +127,13 @@ void GprLogReporter::ReportCpuUsage(const ScenarioResult& result) {
result.summary().server_cpu_usage());
}
+void GprLogReporter::ReportPollCount(const ScenarioResult& result) {
+ 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) {
grpc::string json_string =
SerializeJson(result, "type.googleapis.com/grpc.testing.ScenarioResult");
@@ -145,6 +158,10 @@ void JsonReporter::ReportCpuUsage(const ScenarioResult& result) {
// NOP - all reporting is handled by ReportQPS.
}
+void JsonReporter::ReportPollCount(const ScenarioResult& result) {
+ // NOP - all reporting is handled by ReportQPS.
+}
+
void RpcReporter::ReportQPS(const ScenarioResult& result) {
grpc::ClientContext context;
grpc::Status status;
@@ -177,5 +194,9 @@ void RpcReporter::ReportCpuUsage(const ScenarioResult& result) {
// NOP - all reporting is handled by ReportQPS.
}
+void RpcReporter::ReportPollCount(const ScenarioResult& result) {
+ // NOP - all reporting is handled by ReportQPS.
+}
+
} // namespace testing
} // namespace grpc
diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h
index 1749be98c6..621fa7cb00 100644
--- a/test/cpp/qps/report.h
+++ b/test/cpp/qps/report.h
@@ -76,6 +76,9 @@ class Reporter {
/** Reports server cpu usage. */
virtual void ReportCpuUsage(const ScenarioResult& result) = 0;
+ /** Reports client and server poll usage inside completion queue. */
+ virtual void ReportPollCount(const ScenarioResult& result) = 0;
+
private:
const string name_;
};
@@ -93,6 +96,7 @@ class CompositeReporter : public Reporter {
void ReportLatency(const ScenarioResult& result) override;
void ReportTimes(const ScenarioResult& result) override;
void ReportCpuUsage(const ScenarioResult& result) override;
+ void ReportPollCount(const ScenarioResult& result) override;
private:
std::vector<std::unique_ptr<Reporter> > reporters_;
@@ -109,6 +113,7 @@ class GprLogReporter : public Reporter {
void ReportLatency(const ScenarioResult& result) override;
void ReportTimes(const ScenarioResult& result) override;
void ReportCpuUsage(const ScenarioResult& result) override;
+ void ReportPollCount(const ScenarioResult& result) override;
};
/** Dumps the report to a JSON file. */
@@ -123,6 +128,7 @@ class JsonReporter : public Reporter {
void ReportLatency(const ScenarioResult& result) override;
void ReportTimes(const ScenarioResult& result) override;
void ReportCpuUsage(const ScenarioResult& result) override;
+ void ReportPollCount(const ScenarioResult& result) override;
const string report_file_;
};
@@ -138,6 +144,7 @@ class RpcReporter : public Reporter {
void ReportLatency(const ScenarioResult& result) override;
void ReportTimes(const ScenarioResult& result) override;
void ReportCpuUsage(const ScenarioResult& result) override;
+ void ReportPollCount(const ScenarioResult& result) override;
std::unique_ptr<ReportQpsScenarioService::Stub> stub_;
};
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h
index 8fbf37a095..a03dd1a695 100644
--- a/test/cpp/qps/server.h
+++ b/test/cpp/qps/server.h
@@ -38,6 +38,7 @@
#include <grpc/support/cpu.h>
#include <vector>
+#include "src/core/lib/surface/completion_queue.h"
#include "src/proto/grpc/testing/control.pb.h"
#include "src/proto/grpc/testing/messages.pb.h"
#include "test/core/end2end/data/ssl_test_data.h"
@@ -49,7 +50,8 @@ 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 +64,13 @@ class Server {
ServerStats Mark(bool reset) {
UsageTimer::Result timer_result;
+ 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_ = cur_poll_count;
} else {
timer_result = timer_->Mark();
}
@@ -76,6 +81,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(poll_count);
return stats;
}
@@ -106,10 +112,16 @@ class Server {
}
}
+ virtual int GetPollCount() {
+ // For sync server.
+ return 0;
+ }
+
private:
int port_;
int cores_;
std::unique_ptr<UsageTimer> timer_;
+ int last_reset_poll_count_;
};
std::unique_ptr<Server> CreateSynchronousServer(const ServerConfig& config);
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 84f1579c2f..3403ffd326 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -186,6 +186,14 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
shutdown_thread.join();
}
+ int GetPollCount() override {
+ int count = 0;
+ for (auto cq = srv_cqs_.begin(); cq != srv_cqs_.end(); cq++) {
+ count += grpc_get_cq_poll_num((*cq)->cq());
+ }
+ return count;
+ }
+
private:
void ShutdownThreadFunc() {
// TODO (vpai): Remove this deadline and allow Shutdown to finish properly