From 15f383c6cc74e94cdc7223552824135acab00e7f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 7 Jan 2016 12:45:32 -0800 Subject: Exploratory refactoring for mixed sync/async methods on the same C++ service --- test/cpp/qps/server_async.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index c151918ce4..3fa8fc77f4 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -67,7 +67,7 @@ class AsyncQpsServerTest : public Server { Server::CreateServerCredentials(config)); gpr_free(server_address); - builder.RegisterAsyncService(&async_service_); + builder.RegisterService(&async_service_); for (int i = 0; i < config.async_server_threads(); i++) { srv_cqs_.emplace_back(builder.AddCompletionQueue()); } -- cgit v1.2.3 From 0e66efdaddf096f9833ca37e7eee958b2316242f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 13 Jan 2016 11:15:49 -0800 Subject: Make core limitation work for both client and server so that we can run tests on the same machine if desired. The core_list flags to qps_driver are comma-separated lists of core numbers. --- Makefile | 3 ++ build.yaml | 2 + src/proto/grpc/testing/control.proto | 6 +++ test/cpp/qps/client.h | 13 ++++++ test/cpp/qps/coresched.cc | 72 ++++++++++++++++++++++++++++++ test/cpp/qps/coresched.h | 45 +++++++++++++++++++ test/cpp/qps/qps_driver.cc | 37 +++++++++++++-- test/cpp/qps/qps_worker.cc | 5 --- test/cpp/qps/server.h | 15 ++++++- tools/run_tests/sources_and_headers.json | 3 ++ vsprojects/vcxproj/qps/qps.vcxproj | 3 ++ vsprojects/vcxproj/qps/qps.vcxproj.filters | 6 +++ 12 files changed, 201 insertions(+), 9 deletions(-) create mode 100644 test/cpp/qps/coresched.cc create mode 100644 test/cpp/qps/coresched.h (limited to 'test/cpp/qps') diff --git a/Makefile b/Makefile index 52414cffc1..2f41732d64 100644 --- a/Makefile +++ b/Makefile @@ -3596,6 +3596,7 @@ LIBQPS_SRC = \ $(GENDIR)/src/proto/grpc/testing/perf_db.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.grpc.pb.cc \ test/cpp/qps/client_async.cc \ test/cpp/qps/client_sync.cc \ + test/cpp/qps/coresched.cc \ test/cpp/qps/driver.cc \ test/cpp/qps/perf_db_client.cc \ test/cpp/qps/qps_worker.cc \ @@ -3650,6 +3651,7 @@ endif endif $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/qps/coresched.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/perf_db_client.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.pb.cc $(GENDIR)/src/proto/grpc/testing/perf_db.grpc.pb.cc @@ -12812,6 +12814,7 @@ test/cpp/interop/server.cc: $(OPENSSL_DEP) test/cpp/interop/server_helper.cc: $(OPENSSL_DEP) test/cpp/qps/client_async.cc: $(OPENSSL_DEP) test/cpp/qps/client_sync.cc: $(OPENSSL_DEP) +test/cpp/qps/coresched.cc: $(OPENSSL_DEP) test/cpp/qps/driver.cc: $(OPENSSL_DEP) test/cpp/qps/perf_db_client.cc: $(OPENSSL_DEP) test/cpp/qps/qps_worker.cc: $(OPENSSL_DEP) diff --git a/build.yaml b/build.yaml index aa30bae9f6..2b9a2ba3b6 100644 --- a/build.yaml +++ b/build.yaml @@ -760,6 +760,7 @@ libs: language: c++ headers: - test/cpp/qps/client.h + - test/cpp/qps/coresched.h - test/cpp/qps/driver.h - test/cpp/qps/histogram.h - test/cpp/qps/interarrival.h @@ -779,6 +780,7 @@ libs: - src/proto/grpc/testing/perf_db.proto - test/cpp/qps/client_async.cc - test/cpp/qps/client_sync.cc + - test/cpp/qps/coresched.cc - test/cpp/qps/driver.cc - test/cpp/qps/perf_db_client.cc - test/cpp/qps/qps_worker.cc diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index 0784ebf91c..3892ed3eb3 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -106,6 +106,9 @@ message ClientConfig { LoadParams load_params = 10; PayloadConfig payload_config = 11; HistogramParams histogram_params = 12; + + // Specify the cores we should run the client on, if desired + repeated int32 core_list = 13; } message ClientStatus { ClientStats stats = 1; } @@ -135,6 +138,9 @@ message ServerConfig { // restrict core usage, currently unused int32 core_limit = 8; PayloadConfig payload_config = 9; + + // Specify the cores we should run the server on, if desired + repeated int32 core_list = 10; } message ServerArgs { diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index ee0049578d..a81155c242 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -36,9 +36,13 @@ #include #include +#include + +#include #include "test/cpp/qps/histogram.h" #include "test/cpp/qps/interarrival.h" +#include "test/cpp/qps/coresched.h" #include "test/cpp/qps/timer.h" #include "test/cpp/util/create_test_channel.h" #include "src/proto/grpc/testing/payloads.grpc.pb.h" @@ -72,6 +76,15 @@ class Client { : channels_(config.client_channels()), timer_(new Timer), interarrival_timer_() { + int clsize = config.core_list_size(); + if (clsize > 0) { + std::vector core_list; + for (int i = 0; i < clsize; i++) { + core_list.push_back(config.core_list(i)); + } + LimitCores(core_list); + } + for (int i = 0; i < config.client_channels(); i++) { channels_[i].init(config.server_targets(i % config.server_targets_size()), config); diff --git a/test/cpp/qps/coresched.cc b/test/cpp/qps/coresched.cc new file mode 100644 index 0000000000..8a7b4d4e67 --- /dev/null +++ b/test/cpp/qps/coresched.cc @@ -0,0 +1,72 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "test/cpp/qps/coresched.h" + +#include +#include +#include +#include + +namespace grpc { +namespace testing { + +#ifdef GPR_CPU_LINUX +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +int LimitCores(std::vector cores) { + size_t num_cores = static_cast(gpr_cpu_num_cores()); + if (num_cores > cores.size()) { + cpu_set_t *cpup = CPU_ALLOC(num_cores); + GPR_ASSERT(cpup); + size_t size = CPU_ALLOC_SIZE(num_cores); + CPU_ZERO_S(size, cpup); + + for (size_t i = 0; i < cores.size(); i++) { + CPU_SET_S(cores[i], size, cpup); + } + GPR_ASSERT(sched_setaffinity(0, size, cpup) == 0); + CPU_FREE(cpup); + return cores.size(); + } else { + return num_cores; + } +} +#else +// LimitCores is not currently supported for non-Linux platforms +int LimitCores(std::vector core_vec) {return gpr_cpu_num_cores();} +#endif +} // namespace testing +} // namespace grpc diff --git a/test/cpp/qps/coresched.h b/test/cpp/qps/coresched.h new file mode 100644 index 0000000000..38f6859636 --- /dev/null +++ b/test/cpp/qps/coresched.h @@ -0,0 +1,45 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef TEST_QPS_CORESCHED_H +#define TEST_QPS_CORESCHED_H + +#include + +namespace grpc { +namespace testing { +int LimitCores(std::vector core_vec); +} // namespace testing +} // namespace grpc + +#endif // TEST_QPS_CORESCHED_H diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index c7096391e6..6eafabcc2c 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -48,14 +48,13 @@ DEFINE_int32(warmup_seconds, 5, "Warmup time (in seconds)"); DEFINE_int32(benchmark_seconds, 30, "Benchmark time (in seconds)"); DEFINE_int32(local_workers, 0, "Number of local workers to start"); -// Common config -DEFINE_string(rpc_type, "UNARY", "Type of RPC: UNARY or STREAMING"); - // Server config DEFINE_int32(async_server_threads, 1, "Number of threads for async servers"); DEFINE_string(server_type, "SYNC_SERVER", "Server type"); +DEFINE_string(server_core_list, "", "Comma-separated list of cores for server"); // Client config +DEFINE_string(rpc_type, "UNARY", "Type of RPC: UNARY or STREAMING"); DEFINE_int32(outstanding_rpcs_per_channel, 1, "Number of outstanding rpcs per channel"); DEFINE_int32(client_channels, 1, "Number of client channels"); @@ -73,6 +72,8 @@ DEFINE_double(determ_load, -1.0, "Deterministic offered load (qps)"); DEFINE_double(pareto_base, -1.0, "Pareto base interarrival time (us)"); DEFINE_double(pareto_alpha, -1.0, "Pareto alpha value"); +DEFINE_string(client_core_list, "", "Comma-separated list of cores for client"); + DEFINE_bool(secure_test, false, "Run a secure test"); using grpc::testing::ClientConfig; @@ -86,6 +87,22 @@ using grpc::testing::SecurityParams; namespace grpc { namespace testing { +static std::vector IntParse(const std::string& s) { + size_t pos = 0; + std::vector res; + while (pos < s.size()) { + size_t comma = s.find(',', pos); + if (comma == std::string::npos) { + res.push_back(std::stoi(s.substr(pos))); + break; + } else { + res.push_back(std::stoi(s.substr(pos, comma-pos), nullptr)); + pos = comma + 1; + } + } + return res; +} + static void QpsDriver() { RpcType rpc_type; GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type)); @@ -142,11 +159,25 @@ static void QpsDriver() { client_config.mutable_histogram_params()->set_max_possible( Histogram::default_max_possible()); + if (FLAGS_client_core_list.size() > 0) { + auto v = IntParse(FLAGS_client_core_list); + for (size_t i=0; i 0) { + auto v = IntParse(FLAGS_server_core_list); + for (size_t i=0; i CreateClient(const ClientConfig& config) { abort(); } -static void LimitCores(int cores) {} - static std::unique_ptr CreateServer(const ServerConfig& config) { - if (config.core_limit() > 0) { - LimitCores(config.core_limit()); - } switch (config.server_type()) { case ServerType::SYNC_SERVER: return CreateSynchronousServer(config); diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 620bc32f4b..474473a7d0 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -34,11 +34,13 @@ #ifndef TEST_QPS_SERVER_H #define TEST_QPS_SERVER_H +#include #include #include #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" +#include "test/cpp/qps/coresched.h" #include "test/cpp/qps/timer.h" #include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/control.grpc.pb.h" @@ -49,6 +51,16 @@ namespace testing { class Server { public: explicit Server(const ServerConfig& config) : timer_(new Timer) { + int clsize = config.core_list_size(); + if (clsize > 0) { + std::vector core_list; + for (int i = 0; i < clsize; i++) { + core_list.push_back(config.core_list(i)); + } + cores_ = LimitCores(core_list); + } else { + cores_ = gpr_cpu_num_cores(); + } if (config.port()) { port_ = config.port(); } else { @@ -87,7 +99,7 @@ class Server { } int port() const { return port_; } - int cores() const { return gpr_cpu_num_cores(); } + int cores() const { return cores_;} static std::shared_ptr CreateServerCredentials( const ServerConfig& config) { if (config.has_security_params()) { @@ -104,6 +116,7 @@ class Server { private: int port_; + int cores_; std::unique_ptr timer_; }; diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 8d86fa3bf3..14e5e309e5 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -4267,6 +4267,7 @@ "src/proto/grpc/testing/stats.grpc.pb.h", "src/proto/grpc/testing/stats.pb.h", "test/cpp/qps/client.h", + "test/cpp/qps/coresched.h", "test/cpp/qps/driver.h", "test/cpp/qps/histogram.h", "test/cpp/qps/interarrival.h", @@ -4284,6 +4285,8 @@ "test/cpp/qps/client.h", "test/cpp/qps/client_async.cc", "test/cpp/qps/client_sync.cc", + "test/cpp/qps/coresched.cc", + "test/cpp/qps/coresched.h", "test/cpp/qps/driver.cc", "test/cpp/qps/driver.h", "test/cpp/qps/histogram.h", diff --git a/vsprojects/vcxproj/qps/qps.vcxproj b/vsprojects/vcxproj/qps/qps.vcxproj index 0b017e71c1..a9baccde42 100644 --- a/vsprojects/vcxproj/qps/qps.vcxproj +++ b/vsprojects/vcxproj/qps/qps.vcxproj @@ -148,6 +148,7 @@ + @@ -212,6 +213,8 @@ + + diff --git a/vsprojects/vcxproj/qps/qps.vcxproj.filters b/vsprojects/vcxproj/qps/qps.vcxproj.filters index f575eae6ca..2979a688d1 100644 --- a/vsprojects/vcxproj/qps/qps.vcxproj.filters +++ b/vsprojects/vcxproj/qps/qps.vcxproj.filters @@ -25,6 +25,9 @@ test\cpp\qps + + test\cpp\qps + test\cpp\qps @@ -54,6 +57,9 @@ test\cpp\qps + + test\cpp\qps + test\cpp\qps -- cgit v1.2.3 From 3448c27275aced9d591b70358d130f3059499b73 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 13 Jan 2016 11:17:13 -0800 Subject: clang-format --- test/cpp/qps/client.h | 6 +++--- test/cpp/qps/coresched.cc | 4 ++-- test/cpp/qps/coresched.h | 2 +- test/cpp/qps/qps_driver.cc | 6 +++--- test/cpp/qps/qps_worker.cc | 14 +++++++------- test/cpp/qps/server.h | 10 +++++----- 6 files changed, 21 insertions(+), 21 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index a81155c242..c6d3bb54d5 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -40,13 +40,13 @@ #include +#include "src/proto/grpc/testing/payloads.grpc.pb.h" +#include "src/proto/grpc/testing/services.grpc.pb.h" +#include "test/cpp/qps/coresched.h" #include "test/cpp/qps/histogram.h" #include "test/cpp/qps/interarrival.h" -#include "test/cpp/qps/coresched.h" #include "test/cpp/qps/timer.h" #include "test/cpp/util/create_test_channel.h" -#include "src/proto/grpc/testing/payloads.grpc.pb.h" -#include "src/proto/grpc/testing/services.grpc.pb.h" namespace grpc { diff --git a/test/cpp/qps/coresched.cc b/test/cpp/qps/coresched.cc index 8a7b4d4e67..4b59227bd8 100644 --- a/test/cpp/qps/coresched.cc +++ b/test/cpp/qps/coresched.cc @@ -33,10 +33,10 @@ #include "test/cpp/qps/coresched.h" -#include #include #include #include +#include namespace grpc { namespace testing { @@ -66,7 +66,7 @@ int LimitCores(std::vector cores) { } #else // LimitCores is not currently supported for non-Linux platforms -int LimitCores(std::vector core_vec) {return gpr_cpu_num_cores();} +int LimitCores(std::vector core_vec) { return gpr_cpu_num_cores(); } #endif } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/coresched.h b/test/cpp/qps/coresched.h index 38f6859636..ec32a1d7fc 100644 --- a/test/cpp/qps/coresched.h +++ b/test/cpp/qps/coresched.h @@ -42,4 +42,4 @@ int LimitCores(std::vector core_vec); } // namespace testing } // namespace grpc -#endif // TEST_QPS_CORESCHED_H +#endif // TEST_QPS_CORESCHED_H diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 6eafabcc2c..691ad0b816 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -96,7 +96,7 @@ static std::vector IntParse(const std::string& s) { res.push_back(std::stoi(s.substr(pos))); break; } else { - res.push_back(std::stoi(s.substr(pos, comma-pos), nullptr)); + res.push_back(std::stoi(s.substr(pos, comma - pos), nullptr)); pos = comma + 1; } } @@ -161,7 +161,7 @@ static void QpsDriver() { if (FLAGS_client_core_list.size() > 0) { auto v = IntParse(FLAGS_client_core_list); - for (size_t i=0; i 0) { auto v = IntParse(FLAGS_server_core_list); - for (size_t i=0; i #include #include +#include #include #include #include -#include +#include +#include +#include +#include #include #include #include -#include #include -#include -#include -#include -#include +#include +#include "src/proto/grpc/testing/services.pb.h" #include "test/core/util/grpc_profiler.h" #include "test/cpp/qps/client.h" #include "test/cpp/qps/server.h" #include "test/cpp/util/create_test_channel.h" -#include "src/proto/grpc/testing/services.pb.h" namespace grpc { namespace testing { diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 474473a7d0..3d2ffa8710 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -34,16 +34,16 @@ #ifndef TEST_QPS_SERVER_H #define TEST_QPS_SERVER_H -#include -#include #include +#include +#include +#include "src/proto/grpc/testing/control.grpc.pb.h" +#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" #include "test/cpp/qps/coresched.h" #include "test/cpp/qps/timer.h" -#include "src/proto/grpc/testing/messages.grpc.pb.h" -#include "src/proto/grpc/testing/control.grpc.pb.h" namespace grpc { namespace testing { @@ -99,7 +99,7 @@ class Server { } int port() const { return port_; } - int cores() const { return cores_;} + int cores() const { return cores_; } static std::shared_ptr CreateServerCredentials( const ServerConfig& config) { if (config.has_security_params()) { -- cgit v1.2.3 From 861eb9f13a1437542a381e466f6e5796dafa0941 Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 19 Jan 2016 13:37:27 -0800 Subject: Fix copyrights for sanity --- test/cpp/qps/coresched.cc | 2 +- test/cpp/qps/coresched.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/coresched.cc b/test/cpp/qps/coresched.cc index 4b59227bd8..9dc9fd5841 100644 --- a/test/cpp/qps/coresched.cc +++ b/test/cpp/qps/coresched.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/test/cpp/qps/coresched.h b/test/cpp/qps/coresched.h index ec32a1d7fc..e1012781b1 100644 --- a/test/cpp/qps/coresched.h +++ b/test/cpp/qps/coresched.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.3 From 4f5146dac201c234e4aefdad118413ba3aa76bd6 Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 19 Jan 2016 15:28:52 -0800 Subject: Change name from coresched to limit_cores --- test/cpp/qps/client.h | 2 +- test/cpp/qps/coresched.cc | 72 --------------------------------------------- test/cpp/qps/coresched.h | 45 ---------------------------- test/cpp/qps/limit_cores.cc | 72 +++++++++++++++++++++++++++++++++++++++++++++ test/cpp/qps/limit_cores.h | 45 ++++++++++++++++++++++++++++ test/cpp/qps/server.h | 2 +- 6 files changed, 119 insertions(+), 119 deletions(-) delete mode 100644 test/cpp/qps/coresched.cc delete mode 100644 test/cpp/qps/coresched.h create mode 100644 test/cpp/qps/limit_cores.cc create mode 100644 test/cpp/qps/limit_cores.h (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 2cb4e094c0..576adeb256 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -45,7 +45,7 @@ #include "src/proto/grpc/testing/payloads.grpc.pb.h" #include "src/proto/grpc/testing/services.grpc.pb.h" -#include "test/cpp/qps/coresched.h" +#include "test/cpp/qps/limit_cores.h" #include "test/cpp/qps/histogram.h" #include "test/cpp/qps/interarrival.h" #include "test/cpp/qps/timer.h" diff --git a/test/cpp/qps/coresched.cc b/test/cpp/qps/coresched.cc deleted file mode 100644 index 9dc9fd5841..0000000000 --- a/test/cpp/qps/coresched.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * Copyright 2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "test/cpp/qps/coresched.h" - -#include -#include -#include -#include - -namespace grpc { -namespace testing { - -#ifdef GPR_CPU_LINUX -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include -int LimitCores(std::vector cores) { - size_t num_cores = static_cast(gpr_cpu_num_cores()); - if (num_cores > cores.size()) { - cpu_set_t *cpup = CPU_ALLOC(num_cores); - GPR_ASSERT(cpup); - size_t size = CPU_ALLOC_SIZE(num_cores); - CPU_ZERO_S(size, cpup); - - for (size_t i = 0; i < cores.size(); i++) { - CPU_SET_S(cores[i], size, cpup); - } - GPR_ASSERT(sched_setaffinity(0, size, cpup) == 0); - CPU_FREE(cpup); - return cores.size(); - } else { - return num_cores; - } -} -#else -// LimitCores is not currently supported for non-Linux platforms -int LimitCores(std::vector core_vec) { return gpr_cpu_num_cores(); } -#endif -} // namespace testing -} // namespace grpc diff --git a/test/cpp/qps/coresched.h b/test/cpp/qps/coresched.h deleted file mode 100644 index e1012781b1..0000000000 --- a/test/cpp/qps/coresched.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright 2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef TEST_QPS_CORESCHED_H -#define TEST_QPS_CORESCHED_H - -#include - -namespace grpc { -namespace testing { -int LimitCores(std::vector core_vec); -} // namespace testing -} // namespace grpc - -#endif // TEST_QPS_CORESCHED_H diff --git a/test/cpp/qps/limit_cores.cc b/test/cpp/qps/limit_cores.cc new file mode 100644 index 0000000000..0ba46d3d0a --- /dev/null +++ b/test/cpp/qps/limit_cores.cc @@ -0,0 +1,72 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "test/cpp/qps/limit_cores.h" + +#include +#include +#include +#include + +namespace grpc { +namespace testing { + +#ifdef GPR_CPU_LINUX +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +int LimitCores(std::vector cores) { + size_t num_cores = static_cast(gpr_cpu_num_cores()); + if (num_cores > cores.size()) { + cpu_set_t *cpup = CPU_ALLOC(num_cores); + GPR_ASSERT(cpup); + size_t size = CPU_ALLOC_SIZE(num_cores); + CPU_ZERO_S(size, cpup); + + for (size_t i = 0; i < cores.size(); i++) { + CPU_SET_S(cores[i], size, cpup); + } + GPR_ASSERT(sched_setaffinity(0, size, cpup) == 0); + CPU_FREE(cpup); + return cores.size(); + } else { + return num_cores; + } +} +#else +// LimitCores is not currently supported for non-Linux platforms +int LimitCores(std::vector core_vec) { return gpr_cpu_num_cores(); } +#endif +} // namespace testing +} // namespace grpc diff --git a/test/cpp/qps/limit_cores.h b/test/cpp/qps/limit_cores.h new file mode 100644 index 0000000000..e1012781b1 --- /dev/null +++ b/test/cpp/qps/limit_cores.h @@ -0,0 +1,45 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef TEST_QPS_CORESCHED_H +#define TEST_QPS_CORESCHED_H + +#include + +namespace grpc { +namespace testing { +int LimitCores(std::vector core_vec); +} // namespace testing +} // namespace grpc + +#endif // TEST_QPS_CORESCHED_H diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 0c6e264a50..6195e6ce63 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -42,7 +42,7 @@ #include "src/proto/grpc/testing/messages.grpc.pb.h" #include "test/core/end2end/data/ssl_test_data.h" #include "test/core/util/port.h" -#include "test/cpp/qps/coresched.h" +#include "test/cpp/qps/limit_cores.h" #include "test/cpp/qps/timer.h" namespace grpc { -- cgit v1.2.3 From 41859d025b2596230b1d5a355e7e03a6dfddd20d Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 19 Jan 2016 15:30:22 -0800 Subject: Added todo as a reminder to drive core selection automatically --- test/cpp/qps/qps_driver.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 3d81e62957..e770f92d3f 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -51,6 +51,7 @@ DEFINE_int32(local_workers, 0, "Number of local workers to start"); // Server config DEFINE_int32(async_server_threads, 1, "Number of threads for async servers"); DEFINE_string(server_type, "SYNC_SERVER", "Server type"); +// TODO (vpai): Automatically generate the core list to avoid breakage DEFINE_string(server_core_list, "", "Comma-separated list of cores for server"); // Client config @@ -74,6 +75,7 @@ DEFINE_double(determ_load, -1.0, "Deterministic offered load (qps)"); DEFINE_double(pareto_base, -1.0, "Pareto base interarrival time (us)"); DEFINE_double(pareto_alpha, -1.0, "Pareto alpha value"); +// TODO (vpai): Automatically generate the core list to avoid breakage DEFINE_string(client_core_list, "", "Comma-separated list of cores for client"); DEFINE_bool(secure_test, false, "Run a secure test"); -- cgit v1.2.3 From f524844da919716bc5563bd60f33836d7ba78877 Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 19 Jan 2016 15:34:14 -0800 Subject: Fix include guard --- test/cpp/qps/limit_cores.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/limit_cores.h b/test/cpp/qps/limit_cores.h index e1012781b1..54c805216c 100644 --- a/test/cpp/qps/limit_cores.h +++ b/test/cpp/qps/limit_cores.h @@ -31,8 +31,8 @@ * */ -#ifndef TEST_QPS_CORESCHED_H -#define TEST_QPS_CORESCHED_H +#ifndef TEST_QPS_LIMIT_CORES_H +#define TEST_QPS_LIMIT_CORES_H #include @@ -42,4 +42,4 @@ int LimitCores(std::vector core_vec); } // namespace testing } // namespace grpc -#endif // TEST_QPS_CORESCHED_H +#endif // TEST_QPS_LIMIT_CORES_H -- cgit v1.2.3 From 6a48405ed003a416bd574d3f480b20e3dee9e9df Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 25 Jan 2016 19:12:37 -0800 Subject: pre sync_stream.cc creation. Does not compile --- BUILD | 9 + Makefile | 9 + build.yaml | 4 + include/grpc++/impl/codegen/async_stream.h | 462 +++++++++++++++++++++ include/grpc++/impl/codegen/config_protobuf.h | 72 ++++ include/grpc++/impl/codegen/proto_utils.h | 76 ++++ include/grpc++/impl/codegen/stub_options.h | 43 ++ include/grpc++/impl/proto_utils.h | 39 +- include/grpc++/support/async_stream.h | 425 +------------------ include/grpc++/support/async_unary_call.h | 15 +- include/grpc++/support/config_protobuf.h | 35 +- include/grpc++/support/stub_options.h | 6 +- include/grpc++/support/sync_stream.h | 62 +-- src/compiler/cpp_generator.cc | 14 +- test/cpp/qps/client_async.cc | 2 + test/cpp/qps/client_sync.cc | 1 + test/cpp/qps/driver.cc | 1 + tools/doxygen/Doxyfile.c++ | 3 + tools/doxygen/Doxyfile.c++.internal | 3 + tools/run_tests/sources_and_headers.json | 18 + vsprojects/vcxproj/grpc++/grpc++.vcxproj | 3 + vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 9 + .../grpc++_unsecure/grpc++_unsecure.vcxproj | 3 + .../grpc++_unsecure.vcxproj.filters | 9 + .../grpc_plugin_support.vcxproj | 3 + .../grpc_plugin_support.vcxproj.filters | 9 + 26 files changed, 792 insertions(+), 543 deletions(-) create mode 100644 include/grpc++/impl/codegen/async_stream.h create mode 100644 include/grpc++/impl/codegen/config_protobuf.h create mode 100644 include/grpc++/impl/codegen/proto_utils.h create mode 100644 include/grpc++/impl/codegen/stub_options.h (limited to 'test/cpp/qps') diff --git a/BUILD b/BUILD index 21bbd4c6c8..59e4c44470 100644 --- a/BUILD +++ b/BUILD @@ -846,12 +846,15 @@ cc_library( "include/grpc++/support/stub_options.h", "include/grpc++/support/sync_stream.h", "include/grpc++/support/time.h", + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", @@ -958,12 +961,15 @@ cc_library( "include/grpc++/support/stub_options.h", "include/grpc++/support/sync_stream.h", "include/grpc++/support/time.h", + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", @@ -1014,12 +1020,15 @@ cc_library( "src/compiler/ruby_generator.cc", ], hdrs = [ + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", diff --git a/Makefile b/Makefile index 6dfc665654..5a5434675f 100644 --- a/Makefile +++ b/Makefile @@ -3071,12 +3071,15 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/support/stub_options.h \ include/grpc++/support/sync_stream.h \ include/grpc++/support/time.h \ + include/grpc++/impl/codegen/async_stream.h \ include/grpc++/impl/codegen/call.h \ include/grpc++/impl/codegen/call_hook.h \ include/grpc++/impl/codegen/channel_interface.h \ include/grpc++/impl/codegen/client_context.h \ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ + include/grpc++/impl/codegen/config_protobuf.h \ + include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ @@ -3359,12 +3362,15 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/support/stub_options.h \ include/grpc++/support/sync_stream.h \ include/grpc++/support/time.h \ + include/grpc++/impl/codegen/async_stream.h \ include/grpc++/impl/codegen/call.h \ include/grpc++/impl/codegen/call_hook.h \ include/grpc++/impl/codegen/channel_interface.h \ include/grpc++/impl/codegen/client_context.h \ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ + include/grpc++/impl/codegen/config_protobuf.h \ + include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ @@ -3454,12 +3460,15 @@ LIBGRPC_PLUGIN_SUPPORT_SRC = \ src/compiler/ruby_generator.cc \ PUBLIC_HEADERS_CXX += \ + include/grpc++/impl/codegen/async_stream.h \ include/grpc++/impl/codegen/call.h \ include/grpc++/impl/codegen/call_hook.h \ include/grpc++/impl/codegen/channel_interface.h \ include/grpc++/impl/codegen/client_context.h \ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ + include/grpc++/impl/codegen/config_protobuf.h \ + include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ diff --git a/build.yaml b/build.yaml index 894ef0c230..4df69762a3 100644 --- a/build.yaml +++ b/build.yaml @@ -102,12 +102,16 @@ filegroups: - src/cpp/util/time.cc - name: grpc++_codegen public_headers: + - include/grpc++/impl/codegen/async_stream.h - include/grpc++/impl/codegen/call.h - include/grpc++/impl/codegen/call_hook.h - include/grpc++/impl/codegen/channel_interface.h - include/grpc++/impl/codegen/client_context.h + - include/grpc++/impl/codegen/stub_options.h - include/grpc++/impl/codegen/completion_queue_tag.h - include/grpc++/impl/codegen/config.h + - include/grpc++/impl/codegen/config_protobuf.h + - include/grpc++/impl/codegen/proto_utils.h - include/grpc++/impl/codegen/security/auth_context.h - include/grpc++/impl/codegen/serialization_traits.h - include/grpc++/impl/codegen/server_context.h diff --git a/include/grpc++/impl/codegen/async_stream.h b/include/grpc++/impl/codegen/async_stream.h new file mode 100644 index 0000000000..b0410485f8 --- /dev/null +++ b/include/grpc++/impl/codegen/async_stream.h @@ -0,0 +1,462 @@ +/* + * + * Copyright 2015-2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H +#define GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H + +#include +#include +#include +#include +#include + +namespace grpc { + +class CompletionQueue; + +/// Common interface for all client side asynchronous streaming. +class ClientAsyncStreamingInterface { + public: + virtual ~ClientAsyncStreamingInterface() {} + + /// Request notification of the reading of the initial metadata. Completion + /// will be notified by \a tag on the associated completion queue. + /// + /// \param[in] tag Tag identifying this request. + virtual void ReadInitialMetadata(void* tag) = 0; + + /// Request notification completion. + /// + /// \param[out] status To be updated with the operation status. + /// \param[in] tag Tag identifying this request. + virtual void Finish(Status* status, void* tag) = 0; +}; + +/// An interface that yields a sequence of messages of type \a R. +template +class AsyncReaderInterface { + public: + virtual ~AsyncReaderInterface() {} + + /// Read a message of type \a R into \a msg. Completion will be notified by \a + /// tag on the associated completion queue. + /// + /// \param[out] msg Where to eventually store the read message. + /// \param[in] tag The tag identifying the operation. + virtual void Read(R* msg, void* tag) = 0; +}; + +/// An interface that can be fed a sequence of messages of type \a W. +template +class AsyncWriterInterface { + public: + virtual ~AsyncWriterInterface() {} + + /// Request the writing of \a msg with identifying tag \a tag. + /// + /// Only one write may be outstanding at any given time. This means that + /// after calling Write, one must wait to receive \a tag from the completion + /// queue BEFORE calling Write again. + /// + /// \param[in] msg The message to be written. + /// \param[in] tag The tag identifying the operation. + virtual void Write(const W& msg, void* tag) = 0; +}; + +template +class ClientAsyncReaderInterface : public ClientAsyncStreamingInterface, + public AsyncReaderInterface {}; + +template +class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface { + public: + /// Create a stream and write the first request out. + template + ClientAsyncReader(ChannelInterface* channel, CompletionQueue* cq, + const RpcMethod& method, ClientContext* context, + const W& request, void* tag) + : context_(context), call_(channel->CreateCall(method, context, cq)) { + init_ops_.set_output_tag(tag); + init_ops_.SendInitialMetadata(context->send_initial_metadata_); + // TODO(ctiller): don't assert + GPR_ASSERT(init_ops_.SendMessage(request).ok()); + init_ops_.ClientSendClose(); + call_.PerformOps(&init_ops_); + } + + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) GRPC_OVERRIDE { + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Finish(Status* status, void* tag) GRPC_OVERRIDE { + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + ClientContext* context_; + Call call_; + CallOpSet + init_ops_; + CallOpSet meta_ops_; + CallOpSet> read_ops_; + CallOpSet finish_ops_; +}; + +/// Common interface for client side asynchronous writing. +template +class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface, + public AsyncWriterInterface { + public: + /// Signal the client is done with the writes. + /// + /// \param[in] tag The tag identifying the operation. + virtual void WritesDone(void* tag) = 0; +}; + +template +class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface { + public: + template + ClientAsyncWriter(ChannelInterface* channel, CompletionQueue* cq, + const RpcMethod& method, ClientContext* context, + R* response, void* tag) + : context_(context), call_(channel->CreateCall(method, context, cq)) { + finish_ops_.RecvMessage(response); + + init_ops_.set_output_tag(tag); + init_ops_.SendInitialMetadata(context->send_initial_metadata_); + call_.PerformOps(&init_ops_); + } + + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) GRPC_OVERRIDE { + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) GRPC_OVERRIDE { + writes_done_ops_.set_output_tag(tag); + writes_done_ops_.ClientSendClose(); + call_.PerformOps(&writes_done_ops_); + } + + void Finish(Status* status, void* tag) GRPC_OVERRIDE { + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + ClientContext* context_; + Call call_; + CallOpSet init_ops_; + CallOpSet meta_ops_; + CallOpSet write_ops_; + CallOpSet writes_done_ops_; + CallOpSet finish_ops_; +}; + +/// Client-side interface for asynchronous bi-directional streaming. +template +class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface, + public AsyncWriterInterface, + public AsyncReaderInterface { + public: + /// Signal the client is done with the writes. + /// + /// \param[in] tag The tag identifying the operation. + virtual void WritesDone(void* tag) = 0; +}; + +template +class ClientAsyncReaderWriter GRPC_FINAL + : public ClientAsyncReaderWriterInterface { + public: + ClientAsyncReaderWriter(ChannelInterface* channel, CompletionQueue* cq, + const RpcMethod& method, ClientContext* context, + void* tag) + : context_(context), call_(channel->CreateCall(method, context, cq)) { + init_ops_.set_output_tag(tag); + init_ops_.SendInitialMetadata(context->send_initial_metadata_); + call_.PerformOps(&init_ops_); + } + + void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!context_->initial_metadata_received_); + + meta_ops_.set_output_tag(tag); + meta_ops_.RecvInitialMetadata(context_); + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) GRPC_OVERRIDE { + read_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + read_ops_.RecvInitialMetadata(context_); + } + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) GRPC_OVERRIDE { + write_ops_.set_output_tag(tag); + // TODO(ctiller): don't assert + GPR_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void WritesDone(void* tag) GRPC_OVERRIDE { + writes_done_ops_.set_output_tag(tag); + writes_done_ops_.ClientSendClose(); + call_.PerformOps(&writes_done_ops_); + } + + void Finish(Status* status, void* tag) GRPC_OVERRIDE { + finish_ops_.set_output_tag(tag); + if (!context_->initial_metadata_received_) { + finish_ops_.RecvInitialMetadata(context_); + } + finish_ops_.ClientRecvStatus(context_, status); + call_.PerformOps(&finish_ops_); + } + + private: + ClientContext* context_; + Call call_; + CallOpSet init_ops_; + CallOpSet meta_ops_; + CallOpSet> read_ops_; + CallOpSet write_ops_; + CallOpSet writes_done_ops_; + CallOpSet finish_ops_; +}; + +template +class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncReaderInterface { + public: + explicit ServerAsyncReader(ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) GRPC_OVERRIDE { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Finish(const W& msg, const Status& status, void* tag) { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (status.ok()) { + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, + finish_ops_.SendMessage(msg)); + } else { + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); + } + call_.PerformOps(&finish_ops_); + } + + void FinishWithError(const Status& status, void* tag) { + GPR_ASSERT(!status.ok()); + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } + + Call call_; + ServerContext* ctx_; + CallOpSet meta_ops_; + CallOpSet> read_ops_; + CallOpSet finish_ops_; +}; + +template +class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncWriterInterface { + public: + explicit ServerAsyncWriter(ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Write(const W& msg, void* tag) GRPC_OVERRIDE { + write_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + // TODO(ctiller): don't assert + GPR_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Finish(const Status& status, void* tag) { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } + + Call call_; + ServerContext* ctx_; + CallOpSet meta_ops_; + CallOpSet write_ops_; + CallOpSet finish_ops_; +}; + +/// Server-side interface for asynchronous bi-directional streaming. +template +class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, + public AsyncWriterInterface, + public AsyncReaderInterface { + public: + explicit ServerAsyncReaderWriter(ServerContext* ctx) + : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} + + void SendInitialMetadata(void* tag) GRPC_OVERRIDE { + GPR_ASSERT(!ctx_->sent_initial_metadata_); + + meta_ops_.set_output_tag(tag); + meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + call_.PerformOps(&meta_ops_); + } + + void Read(R* msg, void* tag) GRPC_OVERRIDE { + read_ops_.set_output_tag(tag); + read_ops_.RecvMessage(msg); + call_.PerformOps(&read_ops_); + } + + void Write(const W& msg, void* tag) GRPC_OVERRIDE { + write_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + // TODO(ctiller): don't assert + GPR_ASSERT(write_ops_.SendMessage(msg).ok()); + call_.PerformOps(&write_ops_); + } + + void Finish(const Status& status, void* tag) { + finish_ops_.set_output_tag(tag); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); + call_.PerformOps(&finish_ops_); + } + + private: + friend class ::grpc::Server; + + void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } + + Call call_; + ServerContext* ctx_; + CallOpSet meta_ops_; + CallOpSet> read_ops_; + CallOpSet write_ops_; + CallOpSet finish_ops_; +}; + +} // namespace grpc + +#endif // GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H diff --git a/include/grpc++/impl/codegen/config_protobuf.h b/include/grpc++/impl/codegen/config_protobuf.h new file mode 100644 index 0000000000..f1b6beaca7 --- /dev/null +++ b/include/grpc++/impl/codegen/config_protobuf.h @@ -0,0 +1,72 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H +#define GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H + +#ifndef GRPC_CUSTOM_PROTOBUF_INT64 +#include +#define GRPC_CUSTOM_PROTOBUF_INT64 ::google::protobuf::int64 +#endif + +#ifndef GRPC_CUSTOM_MESSAGE +#include +#define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message +#endif + +#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM +#include +#include +#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM \ + ::google::protobuf::io::ZeroCopyOutputStream +#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \ + ::google::protobuf::io::ZeroCopyInputStream +#define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream +#endif + +namespace grpc { +namespace protobuf { + +typedef GRPC_CUSTOM_MESSAGE Message; +typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; + +namespace io { +typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream; +typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream; +typedef GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream; +} // namespace io + +} // namespace protobuf +} // namespace grpc + +#endif // GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h new file mode 100644 index 0000000000..9b81853652 --- /dev/null +++ b/include/grpc++/impl/codegen/proto_utils.h @@ -0,0 +1,76 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H +#define GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H + +#include + +#include +#include +#include +#include + +namespace grpc { + +// Serialize the msg into a buffer created inside the function. The caller +// should destroy the returned buffer when done with it. If serialization fails, +// false is returned and buffer is left unchanged. +Status SerializeProto(const grpc::protobuf::Message& msg, + grpc_byte_buffer** buffer); + +// The caller keeps ownership of buffer and msg. +Status DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg, + int max_message_size); + +template +class SerializationTraits::value>::type> { + public: + static Status Serialize(const grpc::protobuf::Message& msg, + grpc_byte_buffer** buffer, bool* own_buffer) { + *own_buffer = true; + return SerializeProto(msg, buffer); + } + static Status Deserialize(grpc_byte_buffer* buffer, + grpc::protobuf::Message* msg, + int max_message_size) { + auto status = DeserializeProto(buffer, msg, max_message_size); + grpc_byte_buffer_destroy(buffer); + return status; + } +}; + +} // namespace grpc + +#endif // GRPCXX_IMPL_CODEGEN_PROTO_UTILS_H diff --git a/include/grpc++/impl/codegen/stub_options.h b/include/grpc++/impl/codegen/stub_options.h new file mode 100644 index 0000000000..8e966a8dbf --- /dev/null +++ b/include/grpc++/impl/codegen/stub_options.h @@ -0,0 +1,43 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_IMPL_CODEGEN_STUB_OPTIONS_H +#define GRPCXX_IMPL_CODEGEN_STUB_OPTIONS_H + +namespace grpc { + +class StubOptions {}; + +} // namespace grpc + +#endif // GRPCXX_IMPL_CODEGEN_STUB_OPTIONS_H diff --git a/include/grpc++/impl/proto_utils.h b/include/grpc++/impl/proto_utils.h index 283e33486d..7110a4d9ac 100644 --- a/include/grpc++/impl/proto_utils.h +++ b/include/grpc++/impl/proto_utils.h @@ -34,43 +34,6 @@ #ifndef GRPC_INTERNAL_CPP_PROTO_PROTO_UTILS_H #define GRPC_INTERNAL_CPP_PROTO_PROTO_UTILS_H -#include - -#include -#include -#include -#include - -namespace grpc { - -// Serialize the msg into a buffer created inside the function. The caller -// should destroy the returned buffer when done with it. If serialization fails, -// false is returned and buffer is left unchanged. -Status SerializeProto(const grpc::protobuf::Message& msg, - grpc_byte_buffer** buffer); - -// The caller keeps ownership of buffer and msg. -Status DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg, - int max_message_size); - -template -class SerializationTraits::value>::type> { - public: - static Status Serialize(const grpc::protobuf::Message& msg, - grpc_byte_buffer** buffer, bool* own_buffer) { - *own_buffer = true; - return SerializeProto(msg, buffer); - } - static Status Deserialize(grpc_byte_buffer* buffer, - grpc::protobuf::Message* msg, - int max_message_size) { - auto status = DeserializeProto(buffer, msg, max_message_size); - grpc_byte_buffer_destroy(buffer); - return status; - } -}; - -} // namespace grpc +#include #endif // GRPC_INTERNAL_CPP_PROTO_PROTO_UTILS_H diff --git a/include/grpc++/support/async_stream.h b/include/grpc++/support/async_stream.h index 5a811f9217..88147ea9d6 100644 --- a/include/grpc++/support/async_stream.h +++ b/include/grpc++/support/async_stream.h @@ -34,429 +34,6 @@ #ifndef GRPCXX_SUPPORT_ASYNC_STREAM_H #define GRPCXX_SUPPORT_ASYNC_STREAM_H -#include -#include -#include -#include -#include - -namespace grpc { - -class CompletionQueue; - -/// Common interface for all client side asynchronous streaming. -class ClientAsyncStreamingInterface { - public: - virtual ~ClientAsyncStreamingInterface() {} - - /// Request notification of the reading of the initial metadata. Completion - /// will be notified by \a tag on the associated completion queue. - /// - /// \param[in] tag Tag identifying this request. - virtual void ReadInitialMetadata(void* tag) = 0; - - /// Request notification completion. - /// - /// \param[out] status To be updated with the operation status. - /// \param[in] tag Tag identifying this request. - virtual void Finish(Status* status, void* tag) = 0; -}; - -/// An interface that yields a sequence of messages of type \a R. -template -class AsyncReaderInterface { - public: - virtual ~AsyncReaderInterface() {} - - /// Read a message of type \a R into \a msg. Completion will be notified by \a - /// tag on the associated completion queue. - /// - /// \param[out] msg Where to eventually store the read message. - /// \param[in] tag The tag identifying the operation. - virtual void Read(R* msg, void* tag) = 0; -}; - -/// An interface that can be fed a sequence of messages of type \a W. -template -class AsyncWriterInterface { - public: - virtual ~AsyncWriterInterface() {} - - /// Request the writing of \a msg with identifying tag \a tag. - /// - /// Only one write may be outstanding at any given time. This means that - /// after calling Write, one must wait to receive \a tag from the completion - /// queue BEFORE calling Write again. - /// - /// \param[in] msg The message to be written. - /// \param[in] tag The tag identifying the operation. - virtual void Write(const W& msg, void* tag) = 0; -}; - -template -class ClientAsyncReaderInterface : public ClientAsyncStreamingInterface, - public AsyncReaderInterface {}; - -template -class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface { - public: - /// Create a stream and write the first request out. - template - ClientAsyncReader(ChannelInterface* channel, CompletionQueue* cq, - const RpcMethod& method, ClientContext* context, - const W& request, void* tag) - : context_(context), call_(channel->CreateCall(method, context, cq)) { - init_ops_.set_output_tag(tag); - init_ops_.SendInitialMetadata(context->send_initial_metadata_); - // TODO(ctiller): don't assert - GPR_ASSERT(init_ops_.SendMessage(request).ok()); - init_ops_.ClientSendClose(); - call_.PerformOps(&init_ops_); - } - - void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) GRPC_OVERRIDE { - read_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - read_ops_.RecvInitialMetadata(context_); - } - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Finish(Status* status, void* tag) GRPC_OVERRIDE { - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - ClientContext* context_; - Call call_; - CallOpSet - init_ops_; - CallOpSet meta_ops_; - CallOpSet> read_ops_; - CallOpSet finish_ops_; -}; - -/// Common interface for client side asynchronous writing. -template -class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface, - public AsyncWriterInterface { - public: - /// Signal the client is done with the writes. - /// - /// \param[in] tag The tag identifying the operation. - virtual void WritesDone(void* tag) = 0; -}; - -template -class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface { - public: - template - ClientAsyncWriter(ChannelInterface* channel, CompletionQueue* cq, - const RpcMethod& method, ClientContext* context, - R* response, void* tag) - : context_(context), call_(channel->CreateCall(method, context, cq)) { - finish_ops_.RecvMessage(response); - - init_ops_.set_output_tag(tag); - init_ops_.SendInitialMetadata(context->send_initial_metadata_); - call_.PerformOps(&init_ops_); - } - - void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Write(const W& msg, void* tag) GRPC_OVERRIDE { - write_ops_.set_output_tag(tag); - // TODO(ctiller): don't assert - GPR_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void WritesDone(void* tag) GRPC_OVERRIDE { - writes_done_ops_.set_output_tag(tag); - writes_done_ops_.ClientSendClose(); - call_.PerformOps(&writes_done_ops_); - } - - void Finish(Status* status, void* tag) GRPC_OVERRIDE { - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - ClientContext* context_; - Call call_; - CallOpSet init_ops_; - CallOpSet meta_ops_; - CallOpSet write_ops_; - CallOpSet writes_done_ops_; - CallOpSet finish_ops_; -}; - -/// Client-side interface for asynchronous bi-directional streaming. -template -class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface, - public AsyncWriterInterface, - public AsyncReaderInterface { - public: - /// Signal the client is done with the writes. - /// - /// \param[in] tag The tag identifying the operation. - virtual void WritesDone(void* tag) = 0; -}; - -template -class ClientAsyncReaderWriter GRPC_FINAL - : public ClientAsyncReaderWriterInterface { - public: - ClientAsyncReaderWriter(ChannelInterface* channel, CompletionQueue* cq, - const RpcMethod& method, ClientContext* context, - void* tag) - : context_(context), call_(channel->CreateCall(method, context, cq)) { - init_ops_.set_output_tag(tag); - init_ops_.SendInitialMetadata(context->send_initial_metadata_); - call_.PerformOps(&init_ops_); - } - - void ReadInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!context_->initial_metadata_received_); - - meta_ops_.set_output_tag(tag); - meta_ops_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) GRPC_OVERRIDE { - read_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - read_ops_.RecvInitialMetadata(context_); - } - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Write(const W& msg, void* tag) GRPC_OVERRIDE { - write_ops_.set_output_tag(tag); - // TODO(ctiller): don't assert - GPR_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void WritesDone(void* tag) GRPC_OVERRIDE { - writes_done_ops_.set_output_tag(tag); - writes_done_ops_.ClientSendClose(); - call_.PerformOps(&writes_done_ops_); - } - - void Finish(Status* status, void* tag) GRPC_OVERRIDE { - finish_ops_.set_output_tag(tag); - if (!context_->initial_metadata_received_) { - finish_ops_.RecvInitialMetadata(context_); - } - finish_ops_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_ops_); - } - - private: - ClientContext* context_; - Call call_; - CallOpSet init_ops_; - CallOpSet meta_ops_; - CallOpSet> read_ops_; - CallOpSet write_ops_; - CallOpSet writes_done_ops_; - CallOpSet finish_ops_; -}; - -template -class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncReaderInterface { - public: - explicit ServerAsyncReader(ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - void SendInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) GRPC_OVERRIDE { - read_ops_.set_output_tag(tag); - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Finish(const W& msg, const Status& status, void* tag) { - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (status.ok()) { - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, - finish_ops_.SendMessage(msg)); - } else { - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); - } - call_.PerformOps(&finish_ops_); - } - - void FinishWithError(const Status& status, void* tag) { - GPR_ASSERT(!status.ok()); - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } - - Call call_; - ServerContext* ctx_; - CallOpSet meta_ops_; - CallOpSet> read_ops_; - CallOpSet finish_ops_; -}; - -template -class ServerAsyncWriter GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncWriterInterface { - public: - explicit ServerAsyncWriter(ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - void SendInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Write(const W& msg, void* tag) GRPC_OVERRIDE { - write_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - // TODO(ctiller): don't assert - GPR_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Finish(const Status& status, void* tag) { - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } - - Call call_; - ServerContext* ctx_; - CallOpSet meta_ops_; - CallOpSet write_ops_; - CallOpSet finish_ops_; -}; - -/// Server-side interface for asynchronous bi-directional streaming. -template -class ServerAsyncReaderWriter GRPC_FINAL : public ServerAsyncStreamingInterface, - public AsyncWriterInterface, - public AsyncReaderInterface { - public: - explicit ServerAsyncReaderWriter(ServerContext* ctx) - : call_(nullptr, nullptr, nullptr), ctx_(ctx) {} - - void SendInitialMetadata(void* tag) GRPC_OVERRIDE { - GPR_ASSERT(!ctx_->sent_initial_metadata_); - - meta_ops_.set_output_tag(tag); - meta_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - call_.PerformOps(&meta_ops_); - } - - void Read(R* msg, void* tag) GRPC_OVERRIDE { - read_ops_.set_output_tag(tag); - read_ops_.RecvMessage(msg); - call_.PerformOps(&read_ops_); - } - - void Write(const W& msg, void* tag) GRPC_OVERRIDE { - write_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - // TODO(ctiller): don't assert - GPR_ASSERT(write_ops_.SendMessage(msg).ok()); - call_.PerformOps(&write_ops_); - } - - void Finish(const Status& status, void* tag) { - finish_ops_.set_output_tag(tag); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(ctx_->initial_metadata_); - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status); - call_.PerformOps(&finish_ops_); - } - - private: - friend class ::grpc::Server; - - void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; } - - Call call_; - ServerContext* ctx_; - CallOpSet meta_ops_; - CallOpSet> read_ops_; - CallOpSet write_ops_; - CallOpSet finish_ops_; -}; - -} // namespace grpc +#include #endif // GRPCXX_SUPPORT_ASYNC_STREAM_H diff --git a/include/grpc++/support/async_unary_call.h b/include/grpc++/support/async_unary_call.h index 55ca56b6a6..3a601e063d 100644 --- a/include/grpc++/support/async_unary_call.h +++ b/include/grpc++/support/async_unary_call.h @@ -34,17 +34,18 @@ #ifndef GRPCXX_SUPPORT_ASYNC_UNARY_CALL_H #define GRPCXX_SUPPORT_ASYNC_UNARY_CALL_H -#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace grpc { +class CompletionQueue; + template class ClientAsyncResponseReaderInterface { public: diff --git a/include/grpc++/support/config_protobuf.h b/include/grpc++/support/config_protobuf.h index 8235590d41..3e7f169652 100644 --- a/include/grpc++/support/config_protobuf.h +++ b/include/grpc++/support/config_protobuf.h @@ -34,39 +34,6 @@ #ifndef GRPCXX_SUPPORT_CONFIG_PROTOBUF_H #define GRPCXX_SUPPORT_CONFIG_PROTOBUF_H -#ifndef GRPC_CUSTOM_PROTOBUF_INT64 -#include -#define GRPC_CUSTOM_PROTOBUF_INT64 ::google::protobuf::int64 -#endif - -#ifndef GRPC_CUSTOM_MESSAGE -#include -#define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message -#endif - -#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM -#include -#include -#define GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM \ - ::google::protobuf::io::ZeroCopyOutputStream -#define GRPC_CUSTOM_ZEROCOPYINPUTSTREAM \ - ::google::protobuf::io::ZeroCopyInputStream -#define GRPC_CUSTOM_CODEDINPUTSTREAM ::google::protobuf::io::CodedInputStream -#endif - -namespace grpc { -namespace protobuf { - -typedef GRPC_CUSTOM_MESSAGE Message; -typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; - -namespace io { -typedef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM ZeroCopyOutputStream; -typedef GRPC_CUSTOM_ZEROCOPYINPUTSTREAM ZeroCopyInputStream; -typedef GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream; -} // namespace io - -} // namespace protobuf -} // namespace grpc +#include #endif // GRPCXX_SUPPORT_CONFIG_PROTOBUF_H diff --git a/include/grpc++/support/stub_options.h b/include/grpc++/support/stub_options.h index 973aa9bc83..17a13c357e 100644 --- a/include/grpc++/support/stub_options.h +++ b/include/grpc++/support/stub_options.h @@ -34,10 +34,6 @@ #ifndef GRPCXX_SUPPORT_STUB_OPTIONS_H #define GRPCXX_SUPPORT_STUB_OPTIONS_H -namespace grpc { - -class StubOptions {}; - -} // namespace grpc +#include #endif // GRPCXX_SUPPORT_STUB_OPTIONS_H diff --git a/include/grpc++/support/sync_stream.h b/include/grpc++/support/sync_stream.h index 3f3acc5308..77066ada62 100644 --- a/include/grpc++/support/sync_stream.h +++ b/include/grpc++/support/sync_stream.h @@ -34,18 +34,18 @@ #ifndef GRPCXX_SUPPORT_SYNC_STREAM_H #define GRPCXX_SUPPORT_SYNC_STREAM_H -#include -#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace grpc { +class CompletionQueue; + /// Common interface for all synchronous client side streaming. class ClientStreamingInterface { public: @@ -121,7 +121,9 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { template ClientReader(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const W& request) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + : context_(context), + cq_(new CompletionQueue), + call_(channel->CreateCall(method, context, cq_.get())) { CallOpSet ops; ops.SendInitialMetadata(context->send_initial_metadata_); @@ -129,7 +131,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { GPR_ASSERT(ops.SendMessage(request).ok()); ops.ClientSendClose(); call_.PerformOps(&ops); - cq_.Pluck(&ops); + cq_->Pluck(&ops); } void WaitForInitialMetadata() GRPC_OVERRIDE { @@ -138,7 +140,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { CallOpSet ops; ops.RecvInitialMetadata(context_); call_.PerformOps(&ops); - cq_.Pluck(&ops); /// status ignored + cq_->Pluck(&ops); /// status ignored } bool Read(R* msg) GRPC_OVERRIDE { @@ -148,7 +150,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { } ops.RecvMessage(msg); call_.PerformOps(&ops); - return cq_.Pluck(&ops) && ops.got_message; + return cq_->Pluck(&ops) && ops.got_message; } Status Finish() GRPC_OVERRIDE { @@ -156,13 +158,13 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { Status status; ops.ClientRecvStatus(context_, &status); call_.PerformOps(&ops); - GPR_ASSERT(cq_.Pluck(&ops)); + GPR_ASSERT(cq_->Pluck(&ops)); return status; } private: ClientContext* context_; - CompletionQueue cq_; + std::unique_ptr cq_; Call call_; }; @@ -185,13 +187,15 @@ class ClientWriter : public ClientWriterInterface { template ClientWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, R* response) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + : context_(context), + cq_(new CompletionQueue), + call_(channel->CreateCall(method, context, cq_.get())) { finish_ops_.RecvMessage(response); CallOpSet ops; ops.SendInitialMetadata(context->send_initial_metadata_); call_.PerformOps(&ops); - cq_.Pluck(&ops); + cq_->Pluck(&ops); } using WriterInterface::Write; @@ -201,14 +205,14 @@ class ClientWriter : public ClientWriterInterface { return false; } call_.PerformOps(&ops); - return cq_.Pluck(&ops); + return cq_->Pluck(&ops); } bool WritesDone() GRPC_OVERRIDE { CallOpSet ops; ops.ClientSendClose(); call_.PerformOps(&ops); - return cq_.Pluck(&ops); + return cq_->Pluck(&ops); } /// Read the final response and wait for the final status. @@ -216,14 +220,14 @@ class ClientWriter : public ClientWriterInterface { Status status; finish_ops_.ClientRecvStatus(context_, &status); call_.PerformOps(&finish_ops_); - GPR_ASSERT(cq_.Pluck(&finish_ops_)); + GPR_ASSERT(cq_->Pluck(&finish_ops_)); return status; } private: ClientContext* context_; CallOpSet finish_ops_; - CompletionQueue cq_; + std::unique_ptr cq_; Call call_; }; @@ -251,11 +255,13 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { /// Blocking create a stream. ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + : context_(context), + cq_(new CompletionQueue), + call_(channel->CreateCall(method, context, cq_.get())) { CallOpSet ops; ops.SendInitialMetadata(context->send_initial_metadata_); call_.PerformOps(&ops); - cq_.Pluck(&ops); + cq_->Pluck(&ops); } void WaitForInitialMetadata() GRPC_OVERRIDE { @@ -264,7 +270,7 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { CallOpSet ops; ops.RecvInitialMetadata(context_); call_.PerformOps(&ops); - cq_.Pluck(&ops); // status ignored + cq_->Pluck(&ops); // status ignored } bool Read(R* msg) GRPC_OVERRIDE { @@ -274,7 +280,7 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { } ops.RecvMessage(msg); call_.PerformOps(&ops); - return cq_.Pluck(&ops) && ops.got_message; + return cq_->Pluck(&ops) && ops.got_message; } using WriterInterface::Write; @@ -282,14 +288,14 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { CallOpSet ops; if (!ops.SendMessage(msg, options).ok()) return false; call_.PerformOps(&ops); - return cq_.Pluck(&ops); + return cq_->Pluck(&ops); } bool WritesDone() GRPC_OVERRIDE { CallOpSet ops; ops.ClientSendClose(); call_.PerformOps(&ops); - return cq_.Pluck(&ops); + return cq_->Pluck(&ops); } Status Finish() GRPC_OVERRIDE { @@ -297,13 +303,13 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { Status status; ops.ClientRecvStatus(context_, &status); call_.PerformOps(&ops); - GPR_ASSERT(cq_.Pluck(&ops)); + GPR_ASSERT(cq_->Pluck(&ops)); return status; } private: ClientContext* context_; - CompletionQueue cq_; + std::unique_ptr cq_; Call call_; }; diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index c491eb88c8..3001913181 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -112,13 +112,13 @@ grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file, grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file, const Parameters ¶ms) { grpc::string temp = - "#include \n" + "#include \n" + "#include \n" + "#include \n" "#include \n" - "#include \n" - "#include \n" + "#include \n" "#include \n" - "#include \n" - "#include \n" + "#include \n" "#include \n" "\n" "namespace grpc {\n" @@ -863,10 +863,10 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file, printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); - printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); - printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); printer.Print(vars, "#include \n"); if (!file->package().empty()) { diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index d02769d8e6..60ff7d9a32 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -43,6 +43,8 @@ #include #include +#include +#include #include #include #include diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 92fbf240ce..d93537b279 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -41,6 +41,7 @@ #include #include +#include #include #include #include diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index acb265b308..4741d4e327 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 687dd328b1..82e687e5fb 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -803,12 +803,15 @@ include/grpc++/support/string_ref.h \ include/grpc++/support/stub_options.h \ include/grpc++/support/sync_stream.h \ include/grpc++/support/time.h \ +include/grpc++/impl/codegen/async_stream.h \ include/grpc++/impl/codegen/call.h \ include/grpc++/impl/codegen/call_hook.h \ include/grpc++/impl/codegen/channel_interface.h \ include/grpc++/impl/codegen/client_context.h \ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ +include/grpc++/impl/codegen/config_protobuf.h \ +include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index d7968279f8..5df2bcf7f4 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -803,12 +803,15 @@ include/grpc++/support/string_ref.h \ include/grpc++/support/stub_options.h \ include/grpc++/support/sync_stream.h \ include/grpc++/support/time.h \ +include/grpc++/impl/codegen/async_stream.h \ include/grpc++/impl/codegen/call.h \ include/grpc++/impl/codegen/call_hook.h \ include/grpc++/impl/codegen/channel_interface.h \ include/grpc++/impl/codegen/client_context.h \ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ +include/grpc++/impl/codegen/config_protobuf.h \ +include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index bf481afd80..2b3a9a9fc7 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -3900,12 +3900,15 @@ "include/grpc++/grpc++.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", @@ -3973,12 +3976,15 @@ "include/grpc++/grpc++.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", @@ -4130,12 +4136,15 @@ "include/grpc++/grpc++.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", @@ -4200,12 +4209,15 @@ "include/grpc++/grpc++.h", "include/grpc++/impl/call.h", "include/grpc++/impl/client_unary_call.h", + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", @@ -4289,12 +4301,15 @@ { "deps": [], "headers": [ + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", @@ -4346,12 +4361,15 @@ "language": "c++", "name": "grpc_plugin_support", "src": [ + "include/grpc++/impl/codegen/async_stream.h", "include/grpc++/impl/codegen/call.h", "include/grpc++/impl/codegen/call_hook.h", "include/grpc++/impl/codegen/channel_interface.h", "include/grpc++/impl/codegen/client_context.h", "include/grpc++/impl/codegen/completion_queue_tag.h", "include/grpc++/impl/codegen/config.h", + "include/grpc++/impl/codegen/config_protobuf.h", + "include/grpc++/impl/codegen/proto_utils.h", "include/grpc++/impl/codegen/security/auth_context.h", "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index b4b0fea123..35b1c58bb3 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -301,12 +301,15 @@ + + + diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index 9f7a254e1f..d7c641e3ca 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -228,6 +228,9 @@ include\grpc++\support + + include\grpc++\impl\codegen + include\grpc++\impl\codegen @@ -246,6 +249,12 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + + + include\grpc++\impl\codegen + include\grpc++\impl\codegen\security diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index e884bf51d5..1a565c1893 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -301,12 +301,15 @@ + + + diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 78bddc4c66..4c3ee549eb 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -213,6 +213,9 @@ include\grpc++\support + + include\grpc++\impl\codegen + include\grpc++\impl\codegen @@ -231,6 +234,12 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + + + include\grpc++\impl\codegen + include\grpc++\impl\codegen\security diff --git a/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj b/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj index 350addf6b7..6d481ac373 100644 --- a/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj +++ b/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj @@ -147,12 +147,15 @@ + + + diff --git a/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj.filters b/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj.filters index dca287df85..c2ca0c5285 100644 --- a/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_plugin_support/grpc_plugin_support.vcxproj.filters @@ -18,6 +18,9 @@ + + include\grpc++\impl\codegen + include\grpc++\impl\codegen @@ -36,6 +39,12 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + + + include\grpc++\impl\codegen + include\grpc++\impl\codegen\security -- cgit v1.2.3 From 58da895a8ceecd5997b32aba5ca43007a958e606 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 26 Jan 2016 10:57:07 -0800 Subject: localhost -> wildcard address --- test/cpp/qps/qps_driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 9816a09592..620e874c14 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -153,7 +153,7 @@ static void QpsDriver() { ServerConfig server_config; server_config.set_server_type(server_type); - server_config.set_host("localhost"); + server_config.set_host("::"); // Use the wildcard server address server_config.set_async_server_threads(FLAGS_async_server_threads); if (FLAGS_secure_test) { -- cgit v1.2.3 From 57ecf766ab4137ad0265ccbc95b8610929af9808 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 26 Jan 2016 12:42:48 -0800 Subject: clang-format --- test/cpp/qps/qps_driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 620e874c14..e3e7cb296b 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -153,7 +153,7 @@ static void QpsDriver() { ServerConfig server_config; server_config.set_server_type(server_type); - server_config.set_host("::"); // Use the wildcard server address + server_config.set_host("::"); // Use the wildcard server address server_config.set_async_server_threads(FLAGS_async_server_threads); if (FLAGS_secure_test) { -- cgit v1.2.3 From 0f14209061f79d37f4f72801d66c2ab68dc69b7f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 26 Jan 2016 14:20:07 -0800 Subject: Improve logging for test --- test/cpp/qps/driver.cc | 4 ++++ test/cpp/qps/qps_worker.cc | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index acb265b308..1c4f3d0e56 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -161,6 +161,8 @@ std::unique_ptr RunScenario( // where class contained in std::vector must have a copy constructor auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { + gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", + workers[i].c_str(), i); servers[i].stub = WorkerService::NewStub( CreateChannel(workers[i], InsecureChannelCredentials())); ServerArgs args; @@ -188,6 +190,8 @@ std::unique_ptr RunScenario( // where class contained in std::vector must have a copy constructor auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { + gpr_log(GPR_INFO, "Starting client on %s (worker #%d)", + workers[i].c_str(), i); clients[i].stub = WorkerService::NewStub( CreateChannel(workers[i + num_servers], InsecureChannelCredentials())); ClientArgs args; diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index c0276d05b3..d8c8573a2c 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -61,6 +61,11 @@ namespace grpc { namespace testing { static std::unique_ptr CreateClient(const ClientConfig& config) { + gpr_log(GPR_INFO, "Starting client of type %s %s %d", + ClientType_Name(config.client_type()).c_str(), + RpcType_Name(config.rpc_type()).c_str(), + config.payload_config().has_bytebuf_params()); + switch (config.client_type()) { case ClientType::SYNC_CLIENT: return (config.rpc_type() == RpcType::UNARY) @@ -81,6 +86,9 @@ static std::unique_ptr CreateClient(const ClientConfig& config) { static void LimitCores(int cores) {} static std::unique_ptr CreateServer(const ServerConfig& config) { + gpr_log(GPR_INFO, "Starting server of type %s", + ServerType_Name(config.server_type()).c_str()); + if (config.core_limit() > 0) { LimitCores(config.core_limit()); } @@ -169,22 +177,29 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { if (!args.has_setup()) { return Status(StatusCode::INVALID_ARGUMENT, ""); } + gpr_log(GPR_INFO, "RunClientBody: about to create client"); auto client = CreateClient(args.setup()); if (!client) { return Status(StatusCode::INVALID_ARGUMENT, ""); } + gpr_log(GPR_INFO, "RunClientBody: client created"); ClientStatus status; if (!stream->Write(status)) { return Status(StatusCode::UNKNOWN, ""); } + gpr_log(GPR_INFO, "RunClientBody: creation status reported\n"); while (stream->Read(&args)) { + gpr_log(GPR_INFO, "RunClientBody: Message read\n"); if (!args.has_mark()) { + gpr_log(GPR_INFO, "RunClientBody: Message is not a mark!\n"); return Status(StatusCode::INVALID_ARGUMENT, ""); } *status.mutable_stats() = client->Mark(args.mark().reset()); stream->Write(status); + gpr_log(GPR_INFO, "RunClientBody: Mark response given\n"); } + gpr_log(GPR_INFO, "RunClientBody: Returning\n"); return Status::OK; } @@ -200,24 +215,31 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { if (server_port_ != 0) { args.mutable_setup()->set_port(server_port_); } + gpr_log(GPR_INFO, "RunServerBody: about to create server"); auto server = CreateServer(args.setup()); if (!server) { return Status(StatusCode::INVALID_ARGUMENT, ""); } + gpr_log(GPR_INFO, "RunServerBody: server created"); ServerStatus status; status.set_port(server->port()); status.set_cores(server->cores()); if (!stream->Write(status)) { return Status(StatusCode::UNKNOWN, ""); } + gpr_log(GPR_INFO, "RunServerBody: creation status reported\n"); while (stream->Read(&args)) { + gpr_log(GPR_INFO, "RunServerBody: Message read\n"); if (!args.has_mark()) { + gpr_log(GPR_INFO, "RunServerBody: Message not a mark!\n"); return Status(StatusCode::INVALID_ARGUMENT, ""); } *status.mutable_stats() = server->Mark(args.mark().reset()); stream->Write(status); + gpr_log(GPR_INFO, "RunServerBody: Mark response given\n"); } + gpr_log(GPR_INFO, "RunServerBody: Returning\n"); return Status::OK; } -- cgit v1.2.3 From bdf4acbbfb4aafbe12073808f3a4dfffe0aad283 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 26 Jan 2016 15:15:26 -0800 Subject: Properly state client name --- test/cpp/qps/driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 1c4f3d0e56..daeb33a0aa 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -191,7 +191,7 @@ std::unique_ptr RunScenario( auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { gpr_log(GPR_INFO, "Starting client on %s (worker #%d)", - workers[i].c_str(), i); + workers[i + num_servers].c_str(), i + num_servers); clients[i].stub = WorkerService::NewStub( CreateChannel(workers[i + num_servers], InsecureChannelCredentials())); ClientArgs args; -- cgit v1.2.3 From a00f998089a641ed7cc059eb5d4ce52734ba2e3e Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 26 Jan 2016 17:51:35 -0800 Subject: Actually create async generic server --- src/proto/grpc/testing/control.proto | 1 + test/cpp/qps/generic_async_streaming_ping_pong_test.cc | 2 +- test/cpp/qps/qps_driver.cc | 2 +- test/cpp/qps/qps_worker.cc | 2 ++ test/cpp/qps/server.h | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) (limited to 'test/cpp/qps') diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index 0784ebf91c..496108ab5f 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -42,6 +42,7 @@ enum ClientType { enum ServerType { SYNC_SERVER = 0; ASYNC_SERVER = 1; + ASYNC_GENERIC_SERVER = 2; } enum RpcType { diff --git a/test/cpp/qps/generic_async_streaming_ping_pong_test.cc b/test/cpp/qps/generic_async_streaming_ping_pong_test.cc index 2b2e1c820f..81c0f24103 100644 --- a/test/cpp/qps/generic_async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/generic_async_streaming_ping_pong_test.cc @@ -60,7 +60,7 @@ static void RunGenericAsyncStreamingPingPong() { bbuf->set_req_size(0); ServerConfig server_config; - server_config.set_server_type(ASYNC_SERVER); + server_config.set_server_type(ASYNC_GENERIC_SERVER); server_config.set_host("localhost"); server_config.set_async_server_threads(1); diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index e3e7cb296b..680e4b19b9 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -170,7 +170,7 @@ static void QpsDriver() { GPR_ASSERT(!client_config.payload_config().has_bytebuf_params() || (client_config.client_type() == ASYNC_CLIENT && client_config.rpc_type() == STREAMING && - server_config.server_type() == ASYNC_SERVER)); + server_config.server_type() == ASYNC_GENERIC_SERVER)); const auto result = RunScenario( client_config, FLAGS_num_clients, server_config, FLAGS_num_servers, diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index c0276d05b3..0bacc11b23 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -89,6 +89,8 @@ static std::unique_ptr CreateServer(const ServerConfig& config) { return CreateSynchronousServer(config); case ServerType::ASYNC_SERVER: return CreateAsyncServer(config); + case ServerType::ASYNC_GENERIC_SERVER: + return CreateAsyncGenericServer(config); default: abort(); } diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index 32a3e85026..196fdac8f3 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -108,6 +108,7 @@ class Server { std::unique_ptr CreateSynchronousServer(const ServerConfig& config); std::unique_ptr CreateAsyncServer(const ServerConfig& config); +std::unique_ptr CreateAsyncGenericServer(const ServerConfig& config); } // namespace testing } // namespace grpc -- cgit v1.2.3 From a091a23a7f10b6862c526f69bb5a8951d4365ecf Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 26 Jan 2016 18:10:42 -0800 Subject: No need to put \n at end of a log message --- test/cpp/qps/qps_worker.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index d8c8573a2c..e782b2a6c5 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -187,19 +187,19 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { if (!stream->Write(status)) { return Status(StatusCode::UNKNOWN, ""); } - gpr_log(GPR_INFO, "RunClientBody: creation status reported\n"); + gpr_log(GPR_INFO, "RunClientBody: creation status reported"); while (stream->Read(&args)) { - gpr_log(GPR_INFO, "RunClientBody: Message read\n"); + gpr_log(GPR_INFO, "RunClientBody: Message read"); if (!args.has_mark()) { - gpr_log(GPR_INFO, "RunClientBody: Message is not a mark!\n"); + gpr_log(GPR_INFO, "RunClientBody: Message is not a mark!"); return Status(StatusCode::INVALID_ARGUMENT, ""); } *status.mutable_stats() = client->Mark(args.mark().reset()); stream->Write(status); - gpr_log(GPR_INFO, "RunClientBody: Mark response given\n"); + gpr_log(GPR_INFO, "RunClientBody: Mark response given"); } - gpr_log(GPR_INFO, "RunClientBody: Returning\n"); + gpr_log(GPR_INFO, "RunClientBody: Returning"); return Status::OK; } @@ -227,19 +227,19 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { if (!stream->Write(status)) { return Status(StatusCode::UNKNOWN, ""); } - gpr_log(GPR_INFO, "RunServerBody: creation status reported\n"); + gpr_log(GPR_INFO, "RunServerBody: creation status reported"); while (stream->Read(&args)) { - gpr_log(GPR_INFO, "RunServerBody: Message read\n"); + gpr_log(GPR_INFO, "RunServerBody: Message read"); if (!args.has_mark()) { - gpr_log(GPR_INFO, "RunServerBody: Message not a mark!\n"); + gpr_log(GPR_INFO, "RunServerBody: Message not a mark!"); return Status(StatusCode::INVALID_ARGUMENT, ""); } *status.mutable_stats() = server->Mark(args.mark().reset()); stream->Write(status); - gpr_log(GPR_INFO, "RunServerBody: Mark response given\n"); + gpr_log(GPR_INFO, "RunServerBody: Mark response given"); } - gpr_log(GPR_INFO, "RunServerBody: Returning\n"); + gpr_log(GPR_INFO, "RunServerBody: Returning"); return Status::OK; } -- cgit v1.2.3 From 020c2f36ac7bec80a20c1acfe30d179902f77acd Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 26 Jan 2016 18:11:22 -0800 Subject: Fix copyright --- test/cpp/qps/driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index daeb33a0aa..20d429751d 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.3 From 94aada9ee5f35b5c1df6b103f3d8e8f24cbaaf70 Mon Sep 17 00:00:00 2001 From: vjpai Date: Tue, 26 Jan 2016 18:12:30 -0800 Subject: clang-format --- test/cpp/qps/driver.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 20d429751d..39b8f5cf0d 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -161,8 +161,8 @@ std::unique_ptr RunScenario( // where class contained in std::vector must have a copy constructor auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { - gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", - workers[i].c_str(), i); + gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", workers[i].c_str(), + i); servers[i].stub = WorkerService::NewStub( CreateChannel(workers[i], InsecureChannelCredentials())); ServerArgs args; -- cgit v1.2.3 From 0c31b608058a36bd9d4163c72f666e94eb8442b0 Mon Sep 17 00:00:00 2001 From: vjpai Date: Wed, 27 Jan 2016 09:03:18 -0800 Subject: Sanity failures (copyright, clang-format) --- include/grpc++/server.h | 2 +- test/cpp/qps/driver.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/cpp/qps') diff --git a/include/grpc++/server.h b/include/grpc++/server.h index c9371ba649..f24ed333bb 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 39b8f5cf0d..66269ae757 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -162,7 +162,7 @@ std::unique_ptr RunScenario( auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { gpr_log(GPR_INFO, "Starting server on %s (worker #%d)", workers[i].c_str(), - i); + i); servers[i].stub = WorkerService::NewStub( CreateChannel(workers[i], InsecureChannelCredentials())); ServerArgs args; -- cgit v1.2.3 From a24e9d774caf776e5d0182a779d39ba584c7387a Mon Sep 17 00:00:00 2001 From: vjpai Date: Wed, 27 Jan 2016 09:45:29 -0800 Subject: Sanity checks and asan fix --- include/grpc++/server.h | 2 +- src/proto/grpc/testing/control.proto | 2 +- test/cpp/qps/server_async.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'test/cpp/qps') diff --git a/include/grpc++/server.h b/include/grpc++/server.h index c9371ba649..f24ed333bb 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index 496108ab5f..7ba6f9856f 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -1,4 +1,4 @@ -// Copyright 2015, Google Inc. +// Copyright 2015-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index d530dac86b..cd8d546c28 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -373,7 +373,7 @@ static Status ProcessGenericRPC(const PayloadConfig &payload_config, const ByteBuffer *request, ByteBuffer *response) { int resp_size = payload_config.bytebuf_params().resp_size(); - std::unique_ptr buf(new char[resp_size]); + std::unique_ptr buf(new char[resp_size]); gpr_slice s = gpr_slice_from_copied_buffer(buf.get(), resp_size); Slice slice(s, Slice::STEAL_REF); *response = ByteBuffer(&slice, 1); -- cgit v1.2.3 From 32baa5e62209b67ff247e4a03803c70cb364b457 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 27 Jan 2016 10:01:41 -0800 Subject: Allow dynamic sizing of async client and server thread pools --- test/cpp/qps/client_async.cc | 62 +++++++++++++++++++++++++++++--------------- test/cpp/qps/server_async.cc | 38 +++++++++++++++++---------- 2 files changed, 65 insertions(+), 35 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index f270cd0987..13e71fec7d 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -46,13 +46,14 @@ #include #include #include +#include #include #include +#include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/cpp/qps/client.h" #include "test/cpp/qps/timer.h" #include "test/cpp/util/create_test_channel.h" -#include "src/proto/grpc/testing/services.grpc.pb.h" namespace grpc { namespace testing { @@ -93,7 +94,8 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { std::function< std::unique_ptr>( BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, - CompletionQueue*)> start_req, + CompletionQueue*)> + start_req, std::function on_done) : ClientRpcContext(channel_id), context_(), @@ -139,7 +141,8 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { std::function callback_; std::function>( BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, - CompletionQueue*)> start_req_; + CompletionQueue*)> + start_req_; grpc::Status status_; double start_; std::unique_ptr> @@ -158,20 +161,22 @@ class AsyncClient : public ClientImpl { using Client::closed_loop_; using ClientImpl::channels_; using ClientImpl::request_; - AsyncClient(const ClientConfig& config, - std::function setup_ctx, - std::function(std::shared_ptr)> - create_stub) + AsyncClient( + const ClientConfig& config, + std::function + setup_ctx, + std::function(std::shared_ptr)> + create_stub) : ClientImpl(config, create_stub), + num_async_threads_(NumThreads(config)), channel_lock_(new std::mutex[config.client_channels()]), contexts_(config.client_channels()), max_outstanding_per_channel_(config.outstanding_rpcs_per_channel()), channel_count_(config.client_channels()), - pref_channel_inc_(config.async_client_threads()) { - SetupLoadTest(config, config.async_client_threads()); + pref_channel_inc_(num_async_threads_) { + SetupLoadTest(config, num_async_threads_); - for (int i = 0; i < config.async_client_threads(); i++) { + for (int i = 0; i < num_async_threads_; i++) { cli_cqs_.emplace_back(new CompletionQueue); if (!closed_loop_) { rpc_deadlines_.emplace_back(); @@ -324,6 +329,9 @@ class AsyncClient : public ClientImpl { return true; } + protected: + int num_async_threads_; + private: class boolean { // exists only to avoid data-race on vector public: @@ -338,6 +346,15 @@ class AsyncClient : public ClientImpl { private: bool val_; }; + static int NumThreads(const ClientConfig& config) { + int num_threads = config.async_client_threads(); + if (num_threads <= 0) { // Use dynamic sizing + num_threads = gpr_cpu_num_cores(); + gpr_log(GPR_INFO, "Sizing client server to %d threads\n", num_threads); + } + return num_threads; + } + std::vector> cli_cqs_; std::vector rpc_deadlines_; // per thread deadlines @@ -363,7 +380,7 @@ class AsyncUnaryClient GRPC_FINAL public: explicit AsyncUnaryClient(const ClientConfig& config) : AsyncClient(config, SetupCtx, BenchmarkStubCreator) { - StartThreads(config.async_client_threads()); + StartThreads(num_async_threads_); } ~AsyncUnaryClient() GRPC_OVERRIDE { EndThreads(); } @@ -391,7 +408,8 @@ class ClientRpcContextStreamingImpl : public ClientRpcContext { std::function>( BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, - void*)> start_req, + void*)> + start_req, std::function on_done) : ClientRpcContext(channel_id), context_(), @@ -443,10 +461,10 @@ class ClientRpcContextStreamingImpl : public ClientRpcContext { ResponseType response_; bool (ClientRpcContextStreamingImpl::*next_state_)(bool, Histogram*); std::function callback_; - std::function< - std::unique_ptr>( - BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, - void*)> start_req_; + std::function>( + BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, void*)> + start_req_; grpc::Status status_; double start_; std::unique_ptr> @@ -461,7 +479,7 @@ class AsyncStreamingClient GRPC_FINAL // async streaming currently only supports closed loop GPR_ASSERT(closed_loop_); - StartThreads(config.async_client_threads()); + StartThreads(num_async_threads_); } ~AsyncStreamingClient() GRPC_OVERRIDE { EndThreads(); } @@ -490,7 +508,8 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { int channel_id, grpc::GenericStub* stub, const ByteBuffer& req, std::function( grpc::GenericStub*, grpc::ClientContext*, - const grpc::string& method_name, CompletionQueue*, void*)> start_req, + const grpc::string& method_name, CompletionQueue*, void*)> + start_req, std::function on_done) : ClientRpcContext(channel_id), context_(), @@ -547,7 +566,8 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { std::function callback_; std::function( grpc::GenericStub*, grpc::ClientContext*, const grpc::string&, - CompletionQueue*, void*)> start_req_; + CompletionQueue*, void*)> + start_req_; grpc::Status status_; double start_; std::unique_ptr stream_; @@ -566,7 +586,7 @@ class GenericAsyncStreamingClient GRPC_FINAL // async streaming currently only supports closed loop GPR_ASSERT(closed_loop_); - StartThreads(config.async_client_threads()); + StartThreads(num_async_threads_); } ~GenericAsyncStreamingClient() GRPC_OVERRIDE { EndThreads(); } diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index cd8d546c28..8e1503b460 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -50,8 +50,8 @@ #include #include -#include "test/cpp/qps/server.h" #include "src/proto/grpc/testing/services.grpc.pb.h" +#include "test/cpp/qps/server.h" namespace grpc { namespace testing { @@ -72,7 +72,8 @@ class AsyncQpsServerTest : public Server { CompletionQueue *, ServerCompletionQueue *, void *)> request_streaming_function, std::function process_rpc) + ResponseType *)> + process_rpc) : Server(config) { char *server_address = NULL; @@ -85,7 +86,13 @@ class AsyncQpsServerTest : public Server { register_service(&builder, &async_service_); - for (int i = 0; i < config.async_server_threads(); i++) { + int num_threads = config.async_server_threads(); + if (num_threads <= 0) { // dynamic sizing + num_threads = cores(); + gpr_log(GPR_INFO, "Sizing async server to %d threads\n", num_threads); + } + + for (int i = 0; i < num_threads; i++) { srv_cqs_.emplace_back(builder.AddCompletionQueue()); } @@ -96,8 +103,8 @@ class AsyncQpsServerTest : public Server { auto process_rpc_bound = std::bind(process_rpc, config.payload_config(), _1, _2); - for (int i = 0; i < 10000 / config.async_server_threads(); i++) { - for (int j = 0; j < config.async_server_threads(); j++) { + for (int i = 0; i < 10000 / num_threads; i++) { + for (int j = 0; j < num_threads; j++) { if (request_unary_function) { auto request_unary = std::bind(request_unary_function, &async_service_, _1, _2, _3, @@ -115,10 +122,10 @@ class AsyncQpsServerTest : public Server { } } - for (int i = 0; i < config.async_server_threads(); i++) { + for (int i = 0; i < num_threads; i++) { shutdown_state_.emplace_back(new PerThreadShutdownState()); } - for (int i = 0; i < config.async_server_threads(); i++) { + for (int i = 0; i < num_threads; i++) { threads_.emplace_back(&AsyncQpsServerTest::ThreadFunc, this, i); } } @@ -184,7 +191,8 @@ class AsyncQpsServerTest : public Server { ServerRpcContextUnaryImpl( std::function *, - void *)> request_method, + void *)> + request_method, std::function invoke_method) : srv_ctx_(new ServerContextType), @@ -381,12 +389,14 @@ static Status ProcessGenericRPC(const PayloadConfig &payload_config, } std::unique_ptr CreateAsyncServer(const ServerConfig &config) { - return std::unique_ptr(new AsyncQpsServerTest< - SimpleRequest, SimpleResponse, BenchmarkService::AsyncService, - grpc::ServerContext>( - config, RegisterBenchmarkService, - &BenchmarkService::AsyncService::RequestUnaryCall, - &BenchmarkService::AsyncService::RequestStreamingCall, ProcessSimpleRPC)); + return std::unique_ptr( + new AsyncQpsServerTest( + config, RegisterBenchmarkService, + &BenchmarkService::AsyncService::RequestUnaryCall, + &BenchmarkService::AsyncService::RequestStreamingCall, + ProcessSimpleRPC)); } std::unique_ptr CreateAsyncGenericServer(const ServerConfig &config) { return std::unique_ptr( -- cgit v1.2.3 From d02dd30a1fb0895bac9f6139bf8ef9418a26b69d Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 27 Jan 2016 11:23:34 -0800 Subject: Also dynamic sizing for num_clients on performance tests --- test/cpp/qps/driver.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index acb265b308..4ef70a2570 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -31,24 +31,24 @@ * */ +#include #include #include -#include #include -#include -#include -#include #include #include +#include +#include +#include #include "src/core/support/env.h" +#include "src/proto/grpc/testing/services.grpc.pb.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" #include "test/cpp/qps/driver.h" #include "test/cpp/qps/histogram.h" #include "test/cpp/qps/qps_worker.h" -#include "src/proto/grpc/testing/services.grpc.pb.h" using std::list; using std::thread; @@ -142,6 +142,12 @@ std::unique_ptr RunScenario( } } + // if num_clients is set to <=0, do dynamic sizing: all workers + // except for servers are clients + if (num_clients <= 0) { + num_clients = workers.size() - num_servers; + } + // TODO(ctiller): support running multiple configurations, and binpack // client/server pairs // to available workers -- cgit v1.2.3 From 7a984f0e3aa65367dac193d8f616bd7692e61998 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 27 Jan 2016 11:24:57 -0800 Subject: Copyright --- test/cpp/qps/driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 4ef70a2570..240c66d7a3 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.3 From 7d8335f8753afe33117358bee32f89808eae5d31 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 27 Jan 2016 12:00:41 -0800 Subject: Don't log newlines --- test/cpp/qps/client_async.cc | 2 +- test/cpp/qps/server_async.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 13e71fec7d..4ab74a9d4c 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -350,7 +350,7 @@ class AsyncClient : public ClientImpl { int num_threads = config.async_client_threads(); if (num_threads <= 0) { // Use dynamic sizing num_threads = gpr_cpu_num_cores(); - gpr_log(GPR_INFO, "Sizing client server to %d threads\n", num_threads); + gpr_log(GPR_INFO, "Sizing client server to %d threads", num_threads); } return num_threads; } diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 8e1503b460..ddfeb8638d 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -89,7 +89,7 @@ class AsyncQpsServerTest : public Server { int num_threads = config.async_server_threads(); if (num_threads <= 0) { // dynamic sizing num_threads = cores(); - gpr_log(GPR_INFO, "Sizing async server to %d threads\n", num_threads); + gpr_log(GPR_INFO, "Sizing async server to %d threads", num_threads); } for (int i = 0; i < num_threads; i++) { -- cgit v1.2.3 From 16e45702ac13ce756a911e492317856e94d067aa Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 27 Jan 2016 14:51:12 -0800 Subject: clang-format --- test/cpp/qps/client_async.cc | 34 ++++++++++++++-------------------- test/cpp/qps/server_async.cc | 20 ++++++++------------ 2 files changed, 22 insertions(+), 32 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 4ab74a9d4c..e423ee2598 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -94,8 +94,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { std::function< std::unique_ptr>( BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, - CompletionQueue*)> - start_req, + CompletionQueue*)> start_req, std::function on_done) : ClientRpcContext(channel_id), context_(), @@ -141,8 +140,7 @@ class ClientRpcContextUnaryImpl : public ClientRpcContext { std::function callback_; std::function>( BenchmarkService::Stub*, grpc::ClientContext*, const RequestType&, - CompletionQueue*)> - start_req_; + CompletionQueue*)> start_req_; grpc::Status status_; double start_; std::unique_ptr> @@ -161,12 +159,11 @@ class AsyncClient : public ClientImpl { using Client::closed_loop_; using ClientImpl::channels_; using ClientImpl::request_; - AsyncClient( - const ClientConfig& config, - std::function - setup_ctx, - std::function(std::shared_ptr)> - create_stub) + AsyncClient(const ClientConfig& config, + std::function setup_ctx, + std::function(std::shared_ptr)> + create_stub) : ClientImpl(config, create_stub), num_async_threads_(NumThreads(config)), channel_lock_(new std::mutex[config.client_channels()]), @@ -408,8 +405,7 @@ class ClientRpcContextStreamingImpl : public ClientRpcContext { std::function>( BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, - void*)> - start_req, + void*)> start_req, std::function on_done) : ClientRpcContext(channel_id), context_(), @@ -461,10 +457,10 @@ class ClientRpcContextStreamingImpl : public ClientRpcContext { ResponseType response_; bool (ClientRpcContextStreamingImpl::*next_state_)(bool, Histogram*); std::function callback_; - std::function>( - BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, void*)> - start_req_; + std::function< + std::unique_ptr>( + BenchmarkService::Stub*, grpc::ClientContext*, CompletionQueue*, + void*)> start_req_; grpc::Status status_; double start_; std::unique_ptr> @@ -508,8 +504,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { int channel_id, grpc::GenericStub* stub, const ByteBuffer& req, std::function( grpc::GenericStub*, grpc::ClientContext*, - const grpc::string& method_name, CompletionQueue*, void*)> - start_req, + const grpc::string& method_name, CompletionQueue*, void*)> start_req, std::function on_done) : ClientRpcContext(channel_id), context_(), @@ -566,8 +561,7 @@ class ClientRpcContextGenericStreamingImpl : public ClientRpcContext { std::function callback_; std::function( grpc::GenericStub*, grpc::ClientContext*, const grpc::string&, - CompletionQueue*, void*)> - start_req_; + CompletionQueue*, void*)> start_req_; grpc::Status status_; double start_; std::unique_ptr stream_; diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index ddfeb8638d..ffa6226388 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -72,8 +72,7 @@ class AsyncQpsServerTest : public Server { CompletionQueue *, ServerCompletionQueue *, void *)> request_streaming_function, std::function - process_rpc) + ResponseType *)> process_rpc) : Server(config) { char *server_address = NULL; @@ -191,8 +190,7 @@ class AsyncQpsServerTest : public Server { ServerRpcContextUnaryImpl( std::function *, - void *)> - request_method, + void *)> request_method, std::function invoke_method) : srv_ctx_(new ServerContextType), @@ -389,14 +387,12 @@ static Status ProcessGenericRPC(const PayloadConfig &payload_config, } std::unique_ptr CreateAsyncServer(const ServerConfig &config) { - return std::unique_ptr( - new AsyncQpsServerTest( - config, RegisterBenchmarkService, - &BenchmarkService::AsyncService::RequestUnaryCall, - &BenchmarkService::AsyncService::RequestStreamingCall, - ProcessSimpleRPC)); + return std::unique_ptr(new AsyncQpsServerTest< + SimpleRequest, SimpleResponse, BenchmarkService::AsyncService, + grpc::ServerContext>( + config, RegisterBenchmarkService, + &BenchmarkService::AsyncService::RequestUnaryCall, + &BenchmarkService::AsyncService::RequestStreamingCall, ProcessSimpleRPC)); } std::unique_ptr CreateAsyncGenericServer(const ServerConfig &config) { return std::unique_ptr( -- cgit v1.2.3 From 5a9462339dd35de13acd44e7c8a001ac727c038e Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 27 Jan 2016 19:22:14 -0800 Subject: copyrights --- examples/cpp/helloworld/Makefile | 2 +- include/grpc++/alarm.h | 2 +- include/grpc++/impl/codegen/config_protobuf.h | 2 +- include/grpc++/impl/codegen/proto_utils.h | 2 +- include/grpc++/impl/codegen/serialization_traits.h | 2 +- include/grpc++/impl/codegen/stub_options.h | 2 +- include/grpc++/impl/grpc_library.h | 2 +- include/grpc++/impl/proto_utils.h | 2 +- include/grpc++/impl/serialization_traits.h | 2 +- include/grpc++/support/config_protobuf.h | 2 +- include/grpc++/support/stub_options.h | 2 +- include/grpc/impl/codegen/alloc.h | 2 +- include/grpc/support/alloc.h | 2 +- src/cpp/client/client_context.cc | 2 +- src/cpp/client/create_channel.cc | 2 +- src/cpp/client/credentials.cc | 2 +- src/cpp/client/secure_credentials.cc | 2 +- src/cpp/client/secure_credentials.h | 2 +- src/cpp/common/alarm.cc | 2 +- test/cpp/qps/driver.cc | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) (limited to 'test/cpp/qps') diff --git a/examples/cpp/helloworld/Makefile b/examples/cpp/helloworld/Makefile index 5964b79b83..6aa635913f 100644 --- a/examples/cpp/helloworld/Makefile +++ b/examples/cpp/helloworld/Makefile @@ -1,5 +1,5 @@ # -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/alarm.h b/include/grpc++/alarm.h index 381e8c7698..e2618195f0 100644 --- a/include/grpc++/alarm.h +++ b/include/grpc++/alarm.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/impl/codegen/config_protobuf.h b/include/grpc++/impl/codegen/config_protobuf.h index f1b6beaca7..3b9f05cdff 100644 --- a/include/grpc++/impl/codegen/config_protobuf.h +++ b/include/grpc++/impl/codegen/config_protobuf.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h index 9b81853652..ce177104e0 100644 --- a/include/grpc++/impl/codegen/proto_utils.h +++ b/include/grpc++/impl/codegen/proto_utils.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/impl/codegen/serialization_traits.h b/include/grpc++/impl/codegen/serialization_traits.h index fa99dbfa9c..83c3b64eb3 100644 --- a/include/grpc++/impl/codegen/serialization_traits.h +++ b/include/grpc++/impl/codegen/serialization_traits.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/impl/codegen/stub_options.h b/include/grpc++/impl/codegen/stub_options.h index 8e966a8dbf..3912ae2bf9 100644 --- a/include/grpc++/impl/codegen/stub_options.h +++ b/include/grpc++/impl/codegen/stub_options.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/impl/grpc_library.h b/include/grpc++/impl/grpc_library.h index 041a88f2b6..f7ff28ec15 100644 --- a/include/grpc++/impl/grpc_library.h +++ b/include/grpc++/impl/grpc_library.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/impl/proto_utils.h b/include/grpc++/impl/proto_utils.h index 7110a4d9ac..9124001e20 100644 --- a/include/grpc++/impl/proto_utils.h +++ b/include/grpc++/impl/proto_utils.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/impl/serialization_traits.h b/include/grpc++/impl/serialization_traits.h index 53538299dd..fad4398174 100644 --- a/include/grpc++/impl/serialization_traits.h +++ b/include/grpc++/impl/serialization_traits.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/support/config_protobuf.h b/include/grpc++/support/config_protobuf.h index 3e7f169652..0b466e8e44 100644 --- a/include/grpc++/support/config_protobuf.h +++ b/include/grpc++/support/config_protobuf.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc++/support/stub_options.h b/include/grpc++/support/stub_options.h index 17a13c357e..f8f4c87181 100644 --- a/include/grpc++/support/stub_options.h +++ b/include/grpc++/support/stub_options.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc/impl/codegen/alloc.h b/include/grpc/impl/codegen/alloc.h index 179a75d92e..6c3cc78730 100644 --- a/include/grpc/impl/codegen/alloc.h +++ b/include/grpc/impl/codegen/alloc.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h index 8d03af8424..649cb2ba7a 100644 --- a/include/grpc/support/alloc.h +++ b/include/grpc/support/alloc.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index a832b9a204..e0557b205e 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc index a65e1e83d6..fdaa28ffef 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/cpp/client/credentials.cc b/src/cpp/client/credentials.cc index 7efe651e7a..51b520bf83 100644 --- a/src/cpp/client/credentials.cc +++ b/src/cpp/client/credentials.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 0195a11527..bfbcc5f915 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h index ef61063d55..9e84102154 100644 --- a/src/cpp/client/secure_credentials.h +++ b/src/cpp/client/secure_credentials.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/cpp/common/alarm.cc b/src/cpp/common/alarm.cc index 79afe071fa..604e2c2967 100644 --- a/src/cpp/common/alarm.cc +++ b/src/cpp/common/alarm.cc @@ -1,5 +1,5 @@ /* - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 4741d4e327..197d1ddd96 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without -- cgit v1.2.3 From 6523391782281411cdbcf05f568a60e81f70728e Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 27 Jan 2016 20:07:36 -0800 Subject: sanity fixes --- include/grpc++/impl/codegen/async_unary_call.h | 9 +- include/grpc++/impl/codegen/client_unary_call.h | 3 +- include/grpc++/impl/codegen/method_handler_impl.h | 32 +-- include/grpc++/impl/codegen/service_type.h | 6 +- include/grpc++/impl/codegen/sync_stream.h | 3 +- include/grpc/impl/codegen/propagation_bits.h | 1 - test/cpp/qps/client_async.cc | 11 +- tools/doxygen/Doxyfile.c++ | 326 +++++++++++----------- tools/jenkins/run_portability.sh | 2 +- 9 files changed, 191 insertions(+), 202 deletions(-) (limited to 'test/cpp/qps') diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h index 39e18415ac..481b20b535 100644 --- a/include/grpc++/impl/codegen/async_unary_call.h +++ b/include/grpc++/impl/codegen/async_unary_call.h @@ -92,12 +92,10 @@ class ClientAsyncResponseReader GRPC_FINAL ClientContext* context_; Call call_; SneakyCallOpSet - init_buf_; + CallOpClientSendClose> init_buf_; CallOpSet meta_buf_; CallOpSet, - CallOpClientRecvStatus> - finish_buf_; + CallOpClientRecvStatus> finish_buf_; }; template @@ -150,8 +148,7 @@ class ServerAsyncResponseWriter GRPC_FINAL ServerContext* ctx_; CallOpSet meta_buf_; CallOpSet - finish_buf_; + CallOpServerSendStatus> finish_buf_; }; } // namespace grpc diff --git a/include/grpc++/impl/codegen/client_unary_call.h b/include/grpc++/impl/codegen/client_unary_call.h index 817a98ac1f..0134dec800 100644 --- a/include/grpc++/impl/codegen/client_unary_call.h +++ b/include/grpc++/impl/codegen/client_unary_call.h @@ -55,8 +55,7 @@ Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, Call call(channel->CreateCall(method, context, &cq)); CallOpSet, - CallOpClientSendClose, CallOpClientRecvStatus> - ops; + CallOpClientSendClose, CallOpClientRecvStatus> ops; Status status = ops.SendMessage(request); if (!status.ok()) { return status; diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index ad65ce9484..1bf9bf0549 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -43,10 +43,10 @@ namespace grpc { template class RpcMethodHandler : public MethodHandler { public: - RpcMethodHandler(std::function - func, - ServiceType* service) + RpcMethodHandler( + std::function func, + ServiceType* service) : func_(func), service_(service) {} void RunHandler(const HandlerParameter& param) GRPC_FINAL { @@ -60,8 +60,7 @@ class RpcMethodHandler : public MethodHandler { GPR_ASSERT(!param.server_context->sent_initial_metadata_); CallOpSet - ops; + CallOpServerSendStatus> ops; ops.SendInitialMetadata(param.server_context->initial_metadata_); if (status.ok()) { status = ops.SendMessage(rsp); @@ -74,8 +73,7 @@ class RpcMethodHandler : public MethodHandler { private: // Application provided rpc handler function. std::function - func_; + ResponseType*)> func_; // The class the above handler function lives in. ServiceType* service_; }; @@ -86,8 +84,7 @@ class ClientStreamingHandler : public MethodHandler { public: ClientStreamingHandler( std::function*, ResponseType*)> - func, + ServerReader*, ResponseType*)> func, ServiceType* service) : func_(func), service_(service) {} @@ -98,8 +95,7 @@ class ClientStreamingHandler : public MethodHandler { GPR_ASSERT(!param.server_context->sent_initial_metadata_); CallOpSet - ops; + CallOpServerSendStatus> ops; ops.SendInitialMetadata(param.server_context->initial_metadata_); if (status.ok()) { status = ops.SendMessage(rsp); @@ -111,8 +107,7 @@ class ClientStreamingHandler : public MethodHandler { private: std::function*, - ResponseType*)> - func_; + ResponseType*)> func_; ServiceType* service_; }; @@ -122,8 +117,7 @@ class ServerStreamingHandler : public MethodHandler { public: ServerStreamingHandler( std::function*)> - func, + ServerWriter*)> func, ServiceType* service) : func_(func), service_(service) {} @@ -148,8 +142,7 @@ class ServerStreamingHandler : public MethodHandler { private: std::function*)> - func_; + ServerWriter*)> func_; ServiceType* service_; }; @@ -180,8 +173,7 @@ class BidiStreamingHandler : public MethodHandler { private: std::function*)> - func_; + ServerReaderWriter*)> func_; ServiceType* service_; }; diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h index 9e0a6fa2f7..deb91a41d9 100644 --- a/include/grpc++/impl/codegen/service_type.h +++ b/include/grpc++/impl/codegen/service_type.h @@ -34,10 +34,10 @@ #ifndef GRPCXX_IMPL_CODEGEN_SERVICE_TYPE_H #define GRPCXX_IMPL_CODEGEN_SERVICE_TYPE_H -#include -#include -#include #include +#include +#include +#include #include namespace grpc { diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index b8cd44fb09..33d25e837c 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -122,8 +122,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { ClientContext* context, const W& request) : context_(context), call_(channel->CreateCall(method, context, &cq_)) { CallOpSet - ops; + CallOpClientSendClose> ops; ops.SendInitialMetadata(context->send_initial_metadata_); // TODO(ctiller): don't assert GPR_ASSERT(ops.SendMessage(request).ok()); diff --git a/include/grpc/impl/codegen/propagation_bits.h b/include/grpc/impl/codegen/propagation_bits.h index 9cb8788e2b..989b86f2aa 100644 --- a/include/grpc/impl/codegen/propagation_bits.h +++ b/include/grpc/impl/codegen/propagation_bits.h @@ -64,5 +64,4 @@ extern "C" { } #endif - #endif /* GRPC_IMPL_CODEGEN_H */ diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index cbb2dbe70b..4229e1956e 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -161,12 +161,11 @@ class AsyncClient : public ClientImpl { using Client::closed_loop_; using ClientImpl::channels_; using ClientImpl::request_; - AsyncClient( - const ClientConfig& config, - std::function - setup_ctx, - std::function(std::shared_ptr)> - create_stub) + AsyncClient(const ClientConfig& config, + std::function setup_ctx, + std::function(std::shared_ptr)> + create_stub) : ClientImpl(config, create_stub), num_async_threads_(NumThreads(config)), channel_lock_(new std::mutex[config.client_channels()]), diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index a2a0c914d6..cdb998d59c 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -26,7 +26,7 @@ # for the list of possible encodings. # The default value is: UTF-8. -DOXYFILE_ENCODING = UTF - 8 +DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the @@ -34,34 +34,33 @@ DOXYFILE_ENCODING = UTF - 8 # title of most generated pages and in a few other places. # The default value is: My Project. - PROJECT_NAME = "GRPC C++" +PROJECT_NAME = "GRPC C++" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. - PROJECT_NUMBER = 0.13.0.0 +PROJECT_NUMBER = 0.13.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. - PROJECT_BRIEF = +PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. - PROJECT_LOGO = +PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. - OUTPUT_DIRECTORY = - doc / ref / c++ +OUTPUT_DIRECTORY = doc/ref/c++ # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -71,7 +70,7 @@ DOXYFILE_ENCODING = UTF - 8 # performance problems for the file system. # The default value is: NO. - CREATE_SUBDIRS = NO +CREATE_SUBDIRS = NO # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII @@ -79,7 +78,7 @@ DOXYFILE_ENCODING = UTF - 8 # U+3044. # The default value is: NO. - ALLOW_UNICODE_NAMES = NO +ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this @@ -94,14 +93,14 @@ DOXYFILE_ENCODING = UTF - 8 # Ukrainian and Vietnamese. # The default value is: English. - OUTPUT_LANGUAGE = English +OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. - BRIEF_MEMBER_DESC = YES +BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description @@ -110,7 +109,7 @@ DOXYFILE_ENCODING = UTF - 8 # brief descriptions will be completely suppressed. # The default value is: YES. - REPEAT_BRIEF = YES +REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found @@ -121,14 +120,14 @@ DOXYFILE_ENCODING = UTF - 8 # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. - ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. - ALWAYS_DETAILED_SEC = NO +ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those @@ -136,14 +135,14 @@ DOXYFILE_ENCODING = UTF - 8 # operators of the base classes will not be shown. # The default value is: NO. - INLINE_INHERITED_MEMB = NO +INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. - FULL_PATH_NAMES = YES +FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand @@ -155,7 +154,7 @@ DOXYFILE_ENCODING = UTF - 8 # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. - STRIP_FROM_PATH = +STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which @@ -164,14 +163,14 @@ DOXYFILE_ENCODING = UTF - 8 # specify the list of include paths that are normally passed to the compiler # using the -I flag. - STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. - SHORT_NAMES = NO +SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief @@ -180,7 +179,7 @@ DOXYFILE_ENCODING = UTF - 8 # description.) # The default value is: NO. - JAVADOC_AUTOBRIEF = YES +JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If @@ -188,7 +187,7 @@ DOXYFILE_ENCODING = UTF - 8 # requiring an explicit \brief command for a brief description.) # The default value is: NO. - QT_AUTOBRIEF = NO +QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as @@ -200,28 +199,26 @@ DOXYFILE_ENCODING = UTF - 8 # not recognized any more. # The default value is: NO. - MULTILINE_CPP_IS_BRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. - INHERIT_DOCS = YES +INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part # of the file/class/namespace that contains it. # The default value is: NO. - SEPARATE_MEMBER_PAGES = - NO +SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. - TAB_SIZE = - 2 +TAB_SIZE = 2 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: @@ -233,13 +230,13 @@ DOXYFILE_ENCODING = UTF - 8 # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. - ALIASES = +ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. - TCL_SUBST = +TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -247,7 +244,7 @@ DOXYFILE_ENCODING = UTF - 8 # members will be omitted, etc. # The default value is: NO. - OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored @@ -255,19 +252,19 @@ DOXYFILE_ENCODING = UTF - 8 # qualified scopes will look different, etc. # The default value is: NO. - OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. - OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. - OPTIMIZE_OUTPUT_VHDL = NO +OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given @@ -286,7 +283,7 @@ DOXYFILE_ENCODING = UTF - 8 # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. - EXTENSION_MAPPING = +EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable @@ -296,7 +293,7 @@ DOXYFILE_ENCODING = UTF - 8 # case of backward compatibilities issues. # The default value is: YES. - MARKDOWN_SUPPORT = YES +MARKDOWN_SUPPORT = YES # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can @@ -304,7 +301,7 @@ DOXYFILE_ENCODING = UTF - 8 # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. - AUTOLINK_SUPPORT = YES +AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this @@ -314,13 +311,13 @@ DOXYFILE_ENCODING = UTF - 8 # diagrams that involve STL classes more complete and accurate. # The default value is: NO. - BUILTIN_STL_SUPPORT = NO +BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. - CPP_CLI_SUPPORT = NO +CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen @@ -328,7 +325,7 @@ DOXYFILE_ENCODING = UTF - 8 # of private inheritance when no explicit protection keyword is present. # The default value is: NO. - SIP_SUPPORT = NO +SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make @@ -338,7 +335,7 @@ DOXYFILE_ENCODING = UTF - 8 # should set this option to NO. # The default value is: YES. - IDL_PROPERTY_SUPPORT = YES +IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first @@ -346,7 +343,7 @@ DOXYFILE_ENCODING = UTF - 8 # all members of a group must be documented explicitly. # The default value is: NO. - DISTRIBUTE_GROUP_DOC = NO +DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that @@ -355,7 +352,7 @@ DOXYFILE_ENCODING = UTF - 8 # \nosubgrouping command. # The default value is: YES. - SUBGROUPING = YES +SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) @@ -366,7 +363,7 @@ DOXYFILE_ENCODING = UTF - 8 # SEPARATE_MEMBER_PAGES. # The default value is: NO. - INLINE_GROUPED_CLASSES = NO +INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in @@ -376,7 +373,7 @@ DOXYFILE_ENCODING = UTF - 8 # Man pages) or section (for LaTeX and RTF). # The default value is: NO. - INLINE_SIMPLE_STRUCTS = NO +INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So @@ -387,8 +384,7 @@ DOXYFILE_ENCODING = UTF - 8 # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. - TYPEDEF_HIDES_STRUCT = - NO +TYPEDEF_HIDES_STRUCT = NO # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be @@ -401,8 +397,7 @@ DOXYFILE_ENCODING = UTF - 8 # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. - LOOKUP_CACHE_SIZE = - 0 +LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options @@ -416,25 +411,25 @@ DOXYFILE_ENCODING = UTF - 8 # normally produced when WARNINGS is set to YES. # The default value is: NO. - EXTRACT_ALL = YES +EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. - EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. - EXTRACT_PACKAGE = NO +EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. - EXTRACT_STATIC = NO +EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, @@ -442,7 +437,7 @@ DOXYFILE_ENCODING = UTF - 8 # for Java sources. # The default value is: YES. - EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are @@ -450,7 +445,7 @@ DOXYFILE_ENCODING = UTF - 8 # included. # The default value is: NO. - EXTRACT_LOCAL_METHODS = NO +EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called @@ -459,7 +454,7 @@ DOXYFILE_ENCODING = UTF - 8 # are hidden. # The default value is: NO. - EXTRACT_ANON_NSPACES = NO +EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these @@ -467,7 +462,7 @@ DOXYFILE_ENCODING = UTF - 8 # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. - HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set @@ -475,28 +470,28 @@ DOXYFILE_ENCODING = UTF - 8 # has no effect if EXTRACT_ALL is enabled. # The default value is: NO. - HIDE_UNDOC_CLASSES = NO +HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # (class|struct|union) declarations. If set to NO, these declarations will be # included in the documentation. # The default value is: NO. - HIDE_FRIEND_COMPOUNDS = NO +HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. - HIDE_IN_BODY_DOCS = NO +HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. - INTERNAL_DOCS = NO +INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file # names in lower-case letters. If set to YES, upper-case letters are also @@ -505,53 +500,53 @@ DOXYFILE_ENCODING = UTF - 8 # and Mac users are advised to set this option to NO. # The default value is: system dependent. - CASE_SENSE_NAMES = NO +CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. - HIDE_SCOPE_NAMES = NO +HIDE_SCOPE_NAMES = NO # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to # YES the compound reference will be hidden. # The default value is: NO. - HIDE_COMPOUND_REFERENCE = NO +HIDE_COMPOUND_REFERENCE= NO # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. - SHOW_INCLUDE_FILES = YES +SHOW_INCLUDE_FILES = YES # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader # which file to include in order to use the member. # The default value is: NO. - SHOW_GROUPED_MEMB_INC = NO +SHOW_GROUPED_MEMB_INC = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. - FORCE_LOCAL_INCLUDES = NO +FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. - INLINE_INFO = YES +INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. # The default value is: YES. - SORT_MEMBER_DOCS = YES +SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member @@ -559,7 +554,7 @@ DOXYFILE_ENCODING = UTF - 8 # this will also influence the order of the classes in the class list. # The default value is: NO. - SORT_BRIEF_DOCS = NO +SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and @@ -571,14 +566,14 @@ DOXYFILE_ENCODING = UTF - 8 # detailed member documentation. # The default value is: NO. - SORT_MEMBERS_CTORS_1ST = NO +SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. - SORT_GROUP_NAMES = NO +SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will @@ -588,7 +583,7 @@ DOXYFILE_ENCODING = UTF - 8 # list. # The default value is: NO. - SORT_BY_SCOPE_NAME = NO +SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between @@ -598,39 +593,38 @@ DOXYFILE_ENCODING = UTF - 8 # accept a match between prototype and implementation in such cases. # The default value is: NO. - STRICT_PROTO_MATCHING = NO +STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo # list. This list is created by putting \todo commands in the documentation. # The default value is: YES. - GENERATE_TODOLIST = YES +GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test # list. This list is created by putting \test commands in the documentation. # The default value is: YES. - GENERATE_TESTLIST = YES +GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. - GENERATE_BUGLIST = YES +GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. - GENERATE_DEPRECATEDLIST = - YES +GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if ... \endif and \cond # ... \endcond blocks. - ENABLED_SECTIONS = +ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the @@ -641,29 +635,28 @@ DOXYFILE_ENCODING = UTF - 8 # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. - MAX_INITIALIZER_LINES = - 30 +MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. # The default value is: YES. - SHOW_USED_FILES = YES +SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. - SHOW_FILES = YES +SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. - SHOW_NAMESPACES = YES +SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from @@ -673,7 +666,7 @@ DOXYFILE_ENCODING = UTF - 8 # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. - FILE_VERSION_FILTER = +FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated @@ -686,7 +679,7 @@ DOXYFILE_ENCODING = UTF - 8 # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. - LAYOUT_FILE = +LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib @@ -696,7 +689,7 @@ DOXYFILE_ENCODING = UTF - 8 # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. - CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages @@ -707,7 +700,7 @@ DOXYFILE_ENCODING = UTF - 8 # messages are off. # The default value is: NO. - QUIET = NO +QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES @@ -716,14 +709,14 @@ DOXYFILE_ENCODING = UTF - 8 # Tip: Turn warnings on while writing the documentation. # The default value is: YES. - WARNINGS = YES +WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. - WARN_IF_UNDOCUMENTED = YES +WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters @@ -731,7 +724,7 @@ DOXYFILE_ENCODING = UTF - 8 # markup commands wrongly. # The default value is: YES. - WARN_IF_DOC_ERROR = YES +WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return @@ -739,7 +732,7 @@ DOXYFILE_ENCODING = UTF - 8 # parameter documentation, but not about the absence of documentation. # The default value is: NO. - WARN_NO_PARAMDOC = NO +WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which @@ -749,14 +742,13 @@ DOXYFILE_ENCODING = UTF - 8 # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. - WARN_FORMAT = - "$file:$line: $text" +WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). - WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files @@ -768,67 +760,79 @@ DOXYFILE_ENCODING = UTF - 8 # spaces. # Note: If this tag is empty the current directory is searched. - INPUT = - include / grpc++ / channel.h include / grpc++ / - client_context.h include / grpc++ / completion_queue.h include / - grpc++ / create_channel.h include / grpc++ / generic / - async_generic_service.h include / grpc++ / generic / - generic_stub.h include / grpc++ / grpc++.h include / grpc++ / impl / - call.h include / grpc++ / impl / client_unary_call.h include / - grpc++ / impl / grpc_library.h include / grpc++ / impl / - method_handler_impl.h include / grpc++ / impl / - proto_utils.h include / grpc++ / impl / rpc_method.h include / - grpc++ / impl / rpc_service_method.h include / grpc++ / impl / - serialization_traits.h include / grpc++ / impl / - server_builder_option.h include / grpc++ / impl / - service_type.h include / grpc++ / impl / sync.h include / grpc++ / - impl / sync_cxx11.h include / grpc++ / impl / - sync_no_cxx11.h include / grpc++ / impl / thd.h include / grpc++ / - impl / thd_cxx11.h include / grpc++ / impl / - thd_no_cxx11.h include / grpc++ / security / - auth_context.h include / grpc++ / security / - auth_metadata_processor.h include / grpc++ / security / - credentials.h include / grpc++ / security / - server_credentials.h include / grpc++ / server.h include / grpc++ / - server_builder.h include / grpc++ / server_context.h include / - grpc++ / support / async_stream.h include / grpc++ / support / - async_unary_call.h include / grpc++ / support / - byte_buffer.h include / grpc++ / support / - channel_arguments.h include / grpc++ / support / config.h include / - grpc++ / support / config_protobuf.h include / grpc++ / support / - slice.h include / grpc++ / support / status.h include / grpc++ / - support / status_code_enum.h include / grpc++ / support / - string_ref.h include / grpc++ / support / stub_options.h include / - grpc++ / support / sync_stream.h include / grpc++ / support / - time.h include / grpc++ / impl / codegen / async_stream.h include / - grpc++ / impl / codegen / async_unary_call.h include / grpc++ / - impl / codegen / call.h include / grpc++ / impl / codegen / - call_hook.h include / grpc++ / impl / codegen / - channel_interface.h include / grpc++ / impl / codegen / - client_context.h include / grpc++ / impl / codegen / - client_unary_call.h include / grpc++ / impl / codegen / - completion_queue.h include / grpc++ / impl / codegen / - completion_queue_tag.h include / grpc++ / impl / codegen / - config.h include / grpc++ / impl / codegen / - config_protobuf.h include / grpc++ / impl / codegen / - grpc_library.h include / grpc++ / impl / codegen / - method_handler_impl.h include / grpc++ / impl / codegen / - proto_utils.h include / grpc++ / impl / codegen / - rpc_method.h include / grpc++ / impl / codegen / - rpc_service_method.h include / grpc++ / impl / codegen / security / - auth_context.h include / grpc++ / impl / codegen / - serialization_traits.h include / grpc++ / impl / codegen / - server_context.h include / grpc++ / impl / codegen / - server_interface.h include / grpc++ / impl / codegen / - service_type.h include / grpc++ / impl / codegen / - status.h include / grpc++ / impl / codegen / - status_code_enum.h include / grpc++ / impl / codegen / - string_ref.h include / grpc++ / impl / codegen / - stub_options.h include / grpc++ / impl / codegen / sync.h include / - grpc++ / impl / codegen / sync_cxx11.h include / grpc++ / impl / - codegen / sync_no_cxx11.h include / grpc++ / impl / codegen / - sync_stream.h include / grpc++ / impl / codegen / - time.h +INPUT = include/grpc++/channel.h \ +include/grpc++/client_context.h \ +include/grpc++/completion_queue.h \ +include/grpc++/create_channel.h \ +include/grpc++/generic/async_generic_service.h \ +include/grpc++/generic/generic_stub.h \ +include/grpc++/grpc++.h \ +include/grpc++/impl/call.h \ +include/grpc++/impl/client_unary_call.h \ +include/grpc++/impl/grpc_library.h \ +include/grpc++/impl/method_handler_impl.h \ +include/grpc++/impl/proto_utils.h \ +include/grpc++/impl/rpc_method.h \ +include/grpc++/impl/rpc_service_method.h \ +include/grpc++/impl/serialization_traits.h \ +include/grpc++/impl/server_builder_option.h \ +include/grpc++/impl/service_type.h \ +include/grpc++/impl/sync.h \ +include/grpc++/impl/sync_cxx11.h \ +include/grpc++/impl/sync_no_cxx11.h \ +include/grpc++/impl/thd.h \ +include/grpc++/impl/thd_cxx11.h \ +include/grpc++/impl/thd_no_cxx11.h \ +include/grpc++/security/auth_context.h \ +include/grpc++/security/auth_metadata_processor.h \ +include/grpc++/security/credentials.h \ +include/grpc++/security/server_credentials.h \ +include/grpc++/server.h \ +include/grpc++/server_builder.h \ +include/grpc++/server_context.h \ +include/grpc++/support/async_stream.h \ +include/grpc++/support/async_unary_call.h \ +include/grpc++/support/byte_buffer.h \ +include/grpc++/support/channel_arguments.h \ +include/grpc++/support/config.h \ +include/grpc++/support/config_protobuf.h \ +include/grpc++/support/slice.h \ +include/grpc++/support/status.h \ +include/grpc++/support/status_code_enum.h \ +include/grpc++/support/string_ref.h \ +include/grpc++/support/stub_options.h \ +include/grpc++/support/sync_stream.h \ +include/grpc++/support/time.h \ +include/grpc++/impl/codegen/async_stream.h \ +include/grpc++/impl/codegen/async_unary_call.h \ +include/grpc++/impl/codegen/call.h \ +include/grpc++/impl/codegen/call_hook.h \ +include/grpc++/impl/codegen/channel_interface.h \ +include/grpc++/impl/codegen/client_context.h \ +include/grpc++/impl/codegen/client_unary_call.h \ +include/grpc++/impl/codegen/completion_queue.h \ +include/grpc++/impl/codegen/completion_queue_tag.h \ +include/grpc++/impl/codegen/config.h \ +include/grpc++/impl/codegen/config_protobuf.h \ +include/grpc++/impl/codegen/grpc_library.h \ +include/grpc++/impl/codegen/method_handler_impl.h \ +include/grpc++/impl/codegen/proto_utils.h \ +include/grpc++/impl/codegen/rpc_method.h \ +include/grpc++/impl/codegen/rpc_service_method.h \ +include/grpc++/impl/codegen/security/auth_context.h \ +include/grpc++/impl/codegen/serialization_traits.h \ +include/grpc++/impl/codegen/server_context.h \ +include/grpc++/impl/codegen/server_interface.h \ +include/grpc++/impl/codegen/service_type.h \ +include/grpc++/impl/codegen/status.h \ +include/grpc++/impl/codegen/status_code_enum.h \ +include/grpc++/impl/codegen/string_ref.h \ +include/grpc++/impl/codegen/stub_options.h \ +include/grpc++/impl/codegen/sync.h \ +include/grpc++/impl/codegen/sync_cxx11.h \ +include/grpc++/impl/codegen/sync_no_cxx11.h \ +include/grpc++/impl/codegen/sync_stream.h \ +include/grpc++/impl/codegen/time.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -837,7 +841,7 @@ DOXYFILE_ENCODING = UTF - 8 # possible encodings. # The default value is: UTF-8. - INPUT_ENCODING = UTF - 8 +INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and @@ -848,13 +852,13 @@ DOXYFILE_ENCODING = UTF - 8 # *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, # *.qsf, *.as and *.js. - FILE_PATTERNS = +FILE_PATTERNS = # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. - RECURSIVE = NO +RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a @@ -863,14 +867,14 @@ DOXYFILE_ENCODING = UTF - 8 # Note that relative paths are relative to the directory from which doxygen is # run. - EXCLUDE = +EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. - EXCLUDE_SYMLINKS = NO +EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude diff --git a/tools/jenkins/run_portability.sh b/tools/jenkins/run_portability.sh index 82aaa935c6..8d3ba2faa0 100755 --- a/tools/jenkins/run_portability.sh +++ b/tools/jenkins/run_portability.sh @@ -54,4 +54,4 @@ then USE_DOCKER_MAYBE="--use_docker" fi -python tools/run_tests/run_tests.py $USE_DOCKER_MAYBE -t -l $language -c $config --arch ${curr_arch} --compiler ${curr_compiler} -x report.xml -j 3 $@ \ No newline at end of file +python tools/run_tests/run_tests.py $USE_DOCKER_MAYBE -t -l $language -c $config --arch ${curr_arch} --compiler ${curr_compiler} -x report.xml -j 3 $@ -- cgit v1.2.3 From 269c4b98c5a7955eeb529a6f7f12317613a1b666 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 28 Jan 2016 12:18:54 -0800 Subject: Testing scenarios for various performance characteristics --- test/cpp/qps/qps-sweep.sh | 109 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 90 insertions(+), 19 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/qps-sweep.sh b/test/cpp/qps/qps-sweep.sh index 36ea974812..333f4bd7d0 100755 --- a/test/cpp/qps/qps-sweep.sh +++ b/test/cpp/qps/qps-sweep.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -37,22 +37,93 @@ fi bins=`find . .. ../.. ../../.. -name bins | head -1` -for secure in true false -do - for channels in 1 2 4 8 - do - for client in SYNC_CLIENT ASYNC_CLIENT - do - for server in SYNC_SERVER ASYNC_SERVER - do - for rpc in UNARY STREAMING - do - echo "Test $rpc $client $server, $channels channels, secure=$secure" - "$bins"/opt/qps_driver --rpc_type=$rpc \ - --client_type=$client --server_type=$server \ - --secure_test=$secure - done - done - done - done +set -x + +big=65536 +half=`echo $QPS_WORKERS | awk -F, '{print int(NF/2)}'` + +for secure in true false; do + # Scenario 1: generic async streaming ping-pong (contentionless latency) + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=1 \ + --client_channels=1 --bbuf_req_size=0 --bbuf_resp_size=0 \ + --async_client_threads=1 --async_server_threads=1 --secure_test=$secure \ + --num_servers=1 --num_clients=1 + + # Scenario 2: generic async streaming "unconstrained" (QPS) + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=64 --bbuf_req_size=0 --bbuf_resp_size=0 \ + --async_client_threads=0 --async_server_threads=0 --secure_test=$secure \ + --num_servers=1 --num_clients=0 + + # Scenario 3: Latency at near-peak load (TBD) + + # Scenario 4: Single-channel bidirectional throughput test (like TCP_STREAM). + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=1 --bbuf_req_size=$big --bbuf_resp_size=$big \ + --async_client_threads=1 --async_server_threads=1 --secure_test=$secure \ + --num_servers=1 --num_clients=1 + + # Scenario 5: Sync unary ping-pong with protobufs + "$bins"/opt/qps_driver --rpc_type=UNARY --client_type=SYNC_CLIENT \ + --server_type=SYNC_SERVER --outstanding_rpcs_per_channel=1 \ + --client_channels=1 --simple_req_size=0 --simple_resp_size=0 \ + --secure_test=$secure --num_servers=1 --num_clients=1 + + # Scenario 6: Sync streaming ping-pong with protobufs + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=SYNC_CLIENT \ + --server_type=SYNC_SERVER --outstanding_rpcs_per_channel=1 \ + --client_channels=1 --simple_req_size=0 --simple_resp_size=0 \ + --secure_test=$secure --num_servers=1 --num_clients=1 + + # Scenario 7: Async unary ping-pong with protobufs + "$bins"/opt/qps_driver --rpc_type=UNARY --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_SERVER --outstanding_rpcs_per_channel=1 \ + --client_channels=1 --simple_req_size=0 --simple_resp_size=0 \ + --async_client_threads=1 --async_server_threads=1 --secure_test=$secure \ + --num_servers=1 --num_clients=1 + + # Scenario 8: Async streaming ping-pong with protobufs + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_SERVER --outstanding_rpcs_per_channel=1 \ + --client_channels=1 --simple_req_size=0 --simple_resp_size=0 \ + --async_client_threads=1 --async_server_threads=1 --secure_test=$secure \ + --num_servers=1 --num_clients=1 + + # Scenario 9: Crossbar QPS test + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=64 --bbuf_req_size=0 --bbuf_resp_size=0 \ + --async_client_threads=0 --async_server_threads=0 --secure_test=$secure \ + --num_servers=$half --num_clients=0 + + # Scenario 10: Multi-channel bidir throughput test + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=64 --bbuf_req_size=$big --bbuf_resp_size=$big \ + --async_client_threads=0 --async_server_threads=0 --secure_test=$secure \ + --num_servers=1 --num_clients=1 + + # Scenario 11: Single-channel request throughput test + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=1 --bbuf_req_size=$big --bbuf_resp_size=0 \ + --async_client_threads=1 --async_server_threads=1 --secure_test=$secure \ + --num_servers=1 --num_clients=1 + + # Scenario 12: Single-channel response throughput test + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=1 --bbuf_req_size=0 --bbuf_resp_size=$big \ + --async_client_threads=1 --async_server_threads=1 --secure_test=$secure \ + --num_servers=1 --num_clients=1 + + # Scenario 13: Single-channel bidirectional protobuf throughput test + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=1 --simple_req_size=$big --simple_resp_size=$big \ + --async_client_threads=1 --async_server_threads=1 --secure_test=$secure \ + --num_servers=1 --num_clients=1 done -- cgit v1.2.3 From 5919e81ff18ebb5bfde89764cfff9672bebf2123 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 29 Jan 2016 01:24:05 -0800 Subject: Remove host option from ServerConfig proto since it is error-prone and may cause inter-language confusion. --- src/node/performance/worker_service_impl.js | 4 ++-- src/proto/grpc/testing/control.proto | 2 -- test/cpp/qps/async_streaming_ping_pong_test.cc | 3 +-- test/cpp/qps/async_unary_ping_pong_test.cc | 3 +-- test/cpp/qps/generic_async_streaming_ping_pong_test.cc | 1 - test/cpp/qps/qps_driver.cc | 1 - test/cpp/qps/qps_openloop_test.cc | 3 +-- test/cpp/qps/qps_test.cc | 3 +-- test/cpp/qps/qps_test_with_poll.cc | 3 +-- test/cpp/qps/secure_sync_unary_ping_pong_test.cc | 3 +-- test/cpp/qps/server_async.cc | 2 +- test/cpp/qps/server_sync.cc | 4 ++-- test/cpp/qps/sync_streaming_ping_pong_test.cc | 3 +-- test/cpp/qps/sync_unary_ping_pong_test.cc | 3 +-- 14 files changed, 13 insertions(+), 25 deletions(-) (limited to 'test/cpp/qps') diff --git a/src/node/performance/worker_service_impl.js b/src/node/performance/worker_service_impl.js index 8841ae13c3..99ae32127e 100644 --- a/src/node/performance/worker_service_impl.js +++ b/src/node/performance/worker_service_impl.js @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,7 +99,7 @@ exports.runServer = function runServer(call) { var stats; switch (request.argtype) { case 'setup': - server = new BenchmarkServer(request.setup.host, request.setup.port, + server = new BenchmarkServer('[::]', request.setup.port, request.setup.security_params); server.start(); stats = server.mark(); diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index 7ba6f9856f..2f352e652f 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -127,8 +127,6 @@ message ClientArgs { message ServerConfig { ServerType server_type = 1; SecurityParams security_params = 2; - // Host on which to listen. - string host = 3; // Port on which to listen. Zero means pick unused port. int32 port = 4; // Only for async server. Number of threads used to serve the requests. diff --git a/test/cpp/qps/async_streaming_ping_pong_test.cc b/test/cpp/qps/async_streaming_ping_pong_test.cc index 0acdf3affb..97499329c1 100644 --- a/test/cpp/qps/async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/async_streaming_ping_pong_test.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,6 @@ static void RunAsyncStreamingPingPong() { ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); - server_config.set_host("localhost"); server_config.set_async_server_threads(1); const auto result = diff --git a/test/cpp/qps/async_unary_ping_pong_test.cc b/test/cpp/qps/async_unary_ping_pong_test.cc index d21e116171..d801bddf4a 100644 --- a/test/cpp/qps/async_unary_ping_pong_test.cc +++ b/test/cpp/qps/async_unary_ping_pong_test.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,6 @@ static void RunAsyncUnaryPingPong() { ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); - server_config.set_host("localhost"); server_config.set_async_server_threads(1); const auto result = diff --git a/test/cpp/qps/generic_async_streaming_ping_pong_test.cc b/test/cpp/qps/generic_async_streaming_ping_pong_test.cc index 81c0f24103..d9166ae210 100644 --- a/test/cpp/qps/generic_async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/generic_async_streaming_ping_pong_test.cc @@ -61,7 +61,6 @@ static void RunGenericAsyncStreamingPingPong() { ServerConfig server_config; server_config.set_server_type(ASYNC_GENERIC_SERVER); - server_config.set_host("localhost"); server_config.set_async_server_threads(1); const auto result = diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 680e4b19b9..aa3cb68821 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -153,7 +153,6 @@ static void QpsDriver() { ServerConfig server_config; server_config.set_server_type(server_type); - server_config.set_host("::"); // Use the wildcard server address server_config.set_async_server_threads(FLAGS_async_server_threads); if (FLAGS_secure_test) { diff --git a/test/cpp/qps/qps_openloop_test.cc b/test/cpp/qps/qps_openloop_test.cc index 51df79ef2f..fe5f685b6e 100644 --- a/test/cpp/qps/qps_openloop_test.cc +++ b/test/cpp/qps/qps_openloop_test.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,7 +59,6 @@ static void RunQPS() { ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); - server_config.set_host("localhost"); server_config.set_async_server_threads(4); const auto result = diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc index 1f87d18137..15054db892 100644 --- a/test/cpp/qps/qps_test.cc +++ b/test/cpp/qps/qps_test.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,6 @@ static void RunQPS() { ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); - server_config.set_host("localhost"); server_config.set_async_server_threads(8); const auto result = diff --git a/test/cpp/qps/qps_test_with_poll.cc b/test/cpp/qps/qps_test_with_poll.cc index dc800092db..8340a6386a 100644 --- a/test/cpp/qps/qps_test_with_poll.cc +++ b/test/cpp/qps/qps_test_with_poll.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,7 +62,6 @@ static void RunQPS() { ServerConfig server_config; server_config.set_server_type(ASYNC_SERVER); - server_config.set_host("localhost"); server_config.set_async_server_threads(4); const auto result = diff --git a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc index ce9f02cceb..359310b856 100644 --- a/test/cpp/qps/secure_sync_unary_ping_pong_test.cc +++ b/test/cpp/qps/secure_sync_unary_ping_pong_test.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,7 +57,6 @@ static void RunSynchronousUnaryPingPong() { ServerConfig server_config; server_config.set_server_type(SYNC_SERVER); - server_config.set_host("localhost"); // Set up security params SecurityParams security; diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index b6656526b0..1302d718f0 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -76,7 +76,7 @@ class AsyncQpsServerTest : public Server { : Server(config) { char *server_address = NULL; - gpr_join_host_port(&server_address, config.host().c_str(), port()); + gpr_join_host_port(&server_address, "::", port()); ServerBuilder builder; builder.AddListeningPort(server_address, diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index 97a1ff5255..4b778820d0 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -89,7 +89,7 @@ class SynchronousServer GRPC_FINAL : public grpc::testing::Server { char* server_address = NULL; - gpr_join_host_port(&server_address, config.host().c_str(), port()); + gpr_join_host_port(&server_address, "::", port()); builder.AddListeningPort(server_address, Server::CreateServerCredentials(config)); gpr_free(server_address); diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc index dd8c682815..e02c14c926 100644 --- a/test/cpp/qps/sync_streaming_ping_pong_test.cc +++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,7 +57,6 @@ static void RunSynchronousStreamingPingPong() { ServerConfig server_config; server_config.set_server_type(SYNC_SERVER); - server_config.set_host("localhost"); const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc index 2edb33ef01..9d363c04fb 100644 --- a/test/cpp/qps/sync_unary_ping_pong_test.cc +++ b/test/cpp/qps/sync_unary_ping_pong_test.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,7 +57,6 @@ static void RunSynchronousUnaryPingPong() { ServerConfig server_config; server_config.set_server_type(SYNC_SERVER); - server_config.set_host("localhost"); const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); -- cgit v1.2.3 From c64736d852991c734938a16d58cb5861b7014c07 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 1 Feb 2016 09:33:11 -0800 Subject: Clean-up core list usage and make it possible to reset the core list --- src/proto/grpc/testing/control.proto | 3 +-- test/cpp/qps/client.h | 2 ++ test/cpp/qps/limit_cores.cc | 34 +++++++++++++++++++++------------- test/cpp/qps/limit_cores.h | 5 ++++- test/cpp/qps/qps_worker.cc | 4 ---- test/cpp/qps/server.h | 12 ++---------- 6 files changed, 30 insertions(+), 30 deletions(-) (limited to 'test/cpp/qps') diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index b2b83af3df..40e8a97471 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -134,8 +134,7 @@ message ServerConfig { int32 port = 4; // Only for async server. Number of threads used to serve the requests. int32 async_server_threads = 7; - // restrict core usage, currently unused - int32 core_limit = 8; + // payload config, used in generic server PayloadConfig payload_config = 9; // Specify the cores we should run the server on, if desired diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 576adeb256..7d5f6466f9 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -324,6 +324,8 @@ class ClientImpl : public Client { std::function(std::shared_ptr)> create_stub) : channels_(config.client_channels()), create_stub_(create_stub) { + LimitCores(config.core_list().data(), config.core_list_size()); + for (int i = 0; i < config.client_channels(); i++) { channels_[i].init(config.server_targets(i % config.server_targets_size()), config, create_stub_); diff --git a/test/cpp/qps/limit_cores.cc b/test/cpp/qps/limit_cores.cc index 0ba46d3d0a..5fd8d555a5 100644 --- a/test/cpp/qps/limit_cores.cc +++ b/test/cpp/qps/limit_cores.cc @@ -46,23 +46,31 @@ namespace testing { #define _GNU_SOURCE #endif #include -int LimitCores(std::vector cores) { - size_t num_cores = static_cast(gpr_cpu_num_cores()); - if (num_cores > cores.size()) { - cpu_set_t *cpup = CPU_ALLOC(num_cores); - GPR_ASSERT(cpup); - size_t size = CPU_ALLOC_SIZE(num_cores); - CPU_ZERO_S(size, cpup); +int LimitCores(const int *cores, int cores_size) { + int num_cores = gpr_cpu_num_cores(); + int cores_set = 0; - for (size_t i = 0; i < cores.size(); i++) { - CPU_SET_S(cores[i], size, cpup); + cpu_set_t *cpup = CPU_ALLOC(num_cores); + GPR_ASSERT(cpup); + size_t size = CPU_ALLOC_SIZE(num_cores); + CPU_ZERO_S(size, cpup); + + if (cores_size > 0) { + for (int i = 0; i < cores_size; i++) { + if (cores[i] < num_cores) { + CPU_SET_S(cores[i], size, cpup); + cores_set++; + } } - GPR_ASSERT(sched_setaffinity(0, size, cpup) == 0); - CPU_FREE(cpup); - return cores.size(); } else { - return num_cores; + for (int i = 0; i < num_cores; i++) { + CPU_SET_S(i, size, cpup); + cores_set++; + } } + GPR_ASSERT(sched_setaffinity(0, size, cpup) == 0); + CPU_FREE(cpup); + return cores_set; } #else // LimitCores is not currently supported for non-Linux platforms diff --git a/test/cpp/qps/limit_cores.h b/test/cpp/qps/limit_cores.h index 54c805216c..5467f3b881 100644 --- a/test/cpp/qps/limit_cores.h +++ b/test/cpp/qps/limit_cores.h @@ -38,7 +38,10 @@ namespace grpc { namespace testing { -int LimitCores(std::vector core_vec); +// LimitCores takes array and size arguments (instead of vector) for more direct +// conversion from repeated field of protobuf. Use a cores_size of 0 to remove +// existing limits (from an empty repeated field) +int LimitCores(const int *cores, int cores_size); } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 5cb5850fd4..6289c1a843 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -87,10 +87,6 @@ static std::unique_ptr CreateServer(const ServerConfig& config) { gpr_log(GPR_INFO, "Starting server of type %s", ServerType_Name(config.server_type()).c_str()); - if (config.core_limit() > 0) { - LimitCores(config.core_limit()); - } - switch (config.server_type()) { case ServerType::SYNC_SERVER: return CreateSynchronousServer(config); diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h index bc6f9f99e3..94a6f8acfa 100644 --- a/test/cpp/qps/server.h +++ b/test/cpp/qps/server.h @@ -51,18 +51,10 @@ namespace testing { class Server { public: explicit Server(const ServerConfig& config) : timer_(new Timer) { - int clsize = config.core_list_size(); - if (clsize > 0) { - std::vector core_list; - for (int i = 0; i < clsize; i++) { - core_list.push_back(config.core_list(i)); - } - cores_ = LimitCores(core_list); - } else { - cores_ = gpr_cpu_num_cores(); - } + cores_ = LimitCores(config.core_list().data(), config.core_list_size()); if (config.port()) { port_ = config.port(); + } else { port_ = grpc_pick_unused_port_or_die(); } -- cgit v1.2.3 From c5eec2be89bb201f84b7278da5522a205dc3620b Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 1 Feb 2016 09:46:30 -0800 Subject: Make dynamic sizing of async threads work again --- test/cpp/qps/client.h | 3 ++- test/cpp/qps/client_async.cc | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 7d5f6466f9..50b2bf2514 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -324,7 +324,7 @@ class ClientImpl : public Client { std::function(std::shared_ptr)> create_stub) : channels_(config.client_channels()), create_stub_(create_stub) { - LimitCores(config.core_list().data(), config.core_list_size()); + cores_ = LimitCores(config.core_list().data(), config.core_list_size()); for (int i = 0; i < config.client_channels(); i++) { channels_[i].init(config.server_targets(i % config.server_targets_size()), @@ -337,6 +337,7 @@ class ClientImpl : public Client { virtual ~ClientImpl() {} protected: + int cores_; RequestType request_; class ClientChannelInfo { diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 4229e1956e..f3f8f37051 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -159,6 +159,7 @@ class AsyncClient : public ClientImpl { using Client::SetupLoadTest; using Client::NextIssueTime; using Client::closed_loop_; + using ClientImpl::cores_; using ClientImpl::channels_; using ClientImpl::request_; AsyncClient(const ClientConfig& config, @@ -345,11 +346,11 @@ class AsyncClient : public ClientImpl { private: bool val_; }; - static int NumThreads(const ClientConfig& config) { + int NumThreads(const ClientConfig& config) { int num_threads = config.async_client_threads(); if (num_threads <= 0) { // Use dynamic sizing - num_threads = gpr_cpu_num_cores(); - gpr_log(GPR_INFO, "Sizing client server to %d threads", num_threads); + num_threads = cores_; + gpr_log(GPR_INFO, "Sizing async client to %d threads", num_threads); } return num_threads; } -- cgit v1.2.3 From 7d45cdb60b1f6f9cd8750f405d74362600b82c16 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 1 Feb 2016 13:00:19 -0800 Subject: Enable properly working core limits on clients and servers, and determine these dynamically if only one or the other is specified but both are running on the same host --- src/proto/grpc/testing/control.proto | 12 +++- src/proto/grpc/testing/services.proto | 3 + test/cpp/qps/driver.cc | 126 ++++++++++++++++++++++++++++++---- test/cpp/qps/qps_driver.cc | 36 ++-------- test/cpp/qps/qps_worker.cc | 7 ++ 5 files changed, 140 insertions(+), 44 deletions(-) (limited to 'test/cpp/qps') diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index 40e8a97471..c857e4d210 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -110,6 +110,7 @@ message ClientConfig { // Specify the cores we should run the client on, if desired repeated int32 core_list = 13; + int32 core_limit = 14; } message ClientStatus { ClientStats stats = 1; } @@ -139,6 +140,7 @@ message ServerConfig { // Specify the cores we should run the server on, if desired repeated int32 core_list = 10; + int32 core_limit = 11; } message ServerArgs { @@ -152,6 +154,14 @@ message ServerStatus { ServerStats stats = 1; // the port bound by the server int32 port = 2; - // Number of cores on the server. See gpr_cpu_num_cores. + // Number of cores available to the server int32 cores = 3; } + +message CoreRequest { +} + +message CoreResponse { + // Number of cores available on the server + int32 cores = 1; +} diff --git a/src/proto/grpc/testing/services.proto b/src/proto/grpc/testing/services.proto index af285ceab8..59269a23ca 100644 --- a/src/proto/grpc/testing/services.proto +++ b/src/proto/grpc/testing/services.proto @@ -62,4 +62,7 @@ service WorkerService { // and once the shutdown has finished, the OK status is sent to terminate // this RPC. rpc RunClient(stream ClientArgs) returns (stream ClientStatus); + + // Just return the core count - unary call + rpc CoreCount(CoreRequest) returns (CoreResponse); } diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 490156aec2..f3b92c8082 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -59,7 +60,42 @@ using std::vector; namespace grpc { namespace testing { -static deque get_hosts(const string& name) { +static std::string get_host(const std::string &worker) { + char *host; + char *port; + + gpr_split_host_port(worker.c_str(), &host, &port); + string s(host); + + gpr_free(host); + gpr_free(port); + return s; +} + +static std::unordered_map> + get_hosts_and_cores(const deque& workers) { + std::unordered_map> hosts; + for (auto it = workers.begin(); it != workers.end(); it++) { + string host = get_host(*it); + if (hosts.find(host) == hosts.end()) { + auto stub = WorkerService::NewStub( + CreateChannel(*it, InsecureChannelCredentials())); + grpc::ClientContext ctx; + CoreRequest dummy; + CoreResponse cores; + grpc::Status s = stub->CoreCount(&ctx, dummy, &cores); + assert(s.ok()); + std::deque dq; + for (int i=0; i get_workers(const string& name) { char* env = gpr_getenv(name.c_str()); if (!env) return deque(); @@ -105,7 +141,7 @@ struct ClientData { std::unique_ptr RunScenario( const ClientConfig& initial_client_config, size_t num_clients, - const ServerConfig& server_config, size_t num_servers, int warmup_seconds, + const ServerConfig& initial_server_config, size_t num_servers, int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count) { // ClientContext allocations (all are destroyed at scope exit) list contexts; @@ -113,10 +149,10 @@ std::unique_ptr RunScenario( // To be added to the result, containing the final configuration used for // client and config (including host, etc.) ClientConfig result_client_config; - ServerConfig result_server_config; + ServerConfig result_server_config = initial_server_config; // Get client, server lists - auto workers = get_hosts("QPS_WORKERS"); + auto workers = get_workers("QPS_WORKERS"); ClientConfig client_config = initial_client_config; // Spawn some local workers if desired @@ -143,6 +179,9 @@ std::unique_ptr RunScenario( } } + // Setup the hosts and core counts + auto hosts_cores = get_hosts_and_cores(workers); + // if num_clients is set to <=0, do dynamic sizing: all workers // except for servers are clients if (num_clients <= 0) { @@ -172,18 +211,49 @@ std::unique_ptr RunScenario( i); servers[i].stub = WorkerService::NewStub( CreateChannel(workers[i], InsecureChannelCredentials())); + + ServerConfig server_config = initial_server_config; + char* host; + char* driver_port; + char* cli_target; + gpr_split_host_port(workers[i].c_str(), &host, &driver_port); + string host_str(host); + int server_core_limit = initial_server_config.core_limit(); + int client_core_limit = initial_client_config.core_limit(); + + if (server_core_limit == 0 && client_core_limit > 0) { + // In this case, limit the server cores if it matches the + // same host as one or more clients + const auto& dq = hosts_cores[host_str]; + bool match = false; + int limit = dq.size(); + for (size_t cli = 0; cli < num_clients; cli++) { + if (host_str == get_host(workers[cli+num_servers])) { + limit -= client_core_limit; + match = true; + } + } + if (match) { + GPR_ASSERT(limit > 0); + server_core_limit = limit; + } + } + if (server_core_limit > 0) { + auto& dq = hosts_cores[host_str]; + GPR_ASSERT(dq.size() >= static_cast(server_core_limit)); + for (int core=0; core < server_core_limit; core++) { + server_config.add_core_list(dq.front()); + dq.pop_front(); + } + } + ServerArgs args; - result_server_config = server_config; *args.mutable_setup() = server_config; servers[i].stream = servers[i].stub->RunServer(runsc::AllocContext(&contexts, deadline)); GPR_ASSERT(servers[i].stream->Write(args)); ServerStatus init_status; GPR_ASSERT(servers[i].stream->Read(&init_status)); - char* host; - char* driver_port; - char* cli_target; - gpr_split_host_port(workers[i].c_str(), &host, &driver_port); gpr_join_host_port(&cli_target, host, init_status.port()); client_config.add_server_targets(cli_target); gpr_free(host); @@ -191,19 +261,49 @@ std::unique_ptr RunScenario( gpr_free(cli_target); } + // Targets are all set by now + result_client_config = client_config; // Start clients using runsc::ClientData; // clients is array rather than std::vector to avoid gcc-4.4 issues // where class contained in std::vector must have a copy constructor auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { + const auto& worker = workers[i + num_servers]; gpr_log(GPR_INFO, "Starting client on %s (worker #%d)", - workers[i + num_servers].c_str(), i + num_servers); + worker.c_str(), i + num_servers); clients[i].stub = WorkerService::NewStub( - CreateChannel(workers[i + num_servers], InsecureChannelCredentials())); + CreateChannel(worker, InsecureChannelCredentials())); + ClientConfig per_client_config = client_config; + + int server_core_limit = initial_server_config.core_limit(); + int client_core_limit = initial_client_config.core_limit(); + if ((server_core_limit > 0) || (client_core_limit > 0)) { + auto& dq = hosts_cores[get_host(worker)]; + if (client_core_limit == 0) { + // limit client cores if it matches a server host + bool match = false; + int limit = dq.size(); + for (size_t srv = 0; srv < num_servers; srv++) { + if (get_host(worker) == get_host(workers[srv])) { + match = true; + } + } + if (match) { + client_core_limit = limit; + } + } + if (client_core_limit > 0) { + GPR_ASSERT(dq.size() >= static_cast(client_core_limit)); + for (int core=0; core < client_core_limit; core++) { + per_client_config.add_core_list(dq.front()); + dq.pop_front(); + } + } + } + ClientArgs args; - result_client_config = client_config; - *args.mutable_setup() = client_config; + *args.mutable_setup() = per_client_config; clients[i].stream = clients[i].stub->RunClient(runsc::AllocContext(&contexts, deadline)); GPR_ASSERT(clients[i].stream->Write(args)); diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 6462050b6c..ffc8a83fc5 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -51,8 +51,7 @@ DEFINE_int32(local_workers, 0, "Number of local workers to start"); // Server config DEFINE_int32(async_server_threads, 1, "Number of threads for async servers"); DEFINE_string(server_type, "SYNC_SERVER", "Server type"); -// TODO (vpai): Automatically generate the core list to avoid breakage -DEFINE_string(server_core_list, "", "Comma-separated list of cores for server"); +DEFINE_int32(server_core_limit, -1, "Limit on server cores to use"); // Client config DEFINE_string(rpc_type, "UNARY", "Type of RPC: UNARY or STREAMING"); @@ -75,8 +74,7 @@ DEFINE_double(determ_load, -1.0, "Deterministic offered load (qps)"); DEFINE_double(pareto_base, -1.0, "Pareto base interarrival time (us)"); DEFINE_double(pareto_alpha, -1.0, "Pareto alpha value"); -// TODO (vpai): Automatically generate the core list to avoid breakage -DEFINE_string(client_core_list, "", "Comma-separated list of cores for client"); +DEFINE_int32(client_core_limit, -1, "Limit on client cores to use"); DEFINE_bool(secure_test, false, "Run a secure test"); @@ -91,22 +89,6 @@ using grpc::testing::SecurityParams; namespace grpc { namespace testing { -static std::vector IntParse(const std::string& s) { - size_t pos = 0; - std::vector res; - while (pos < s.size()) { - size_t comma = s.find(',', pos); - if (comma == std::string::npos) { - res.push_back(std::stoi(s.substr(pos))); - break; - } else { - res.push_back(std::stoi(s.substr(pos, comma - pos), nullptr)); - pos = comma + 1; - } - } - return res; -} - static void QpsDriver() { RpcType rpc_type; GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type)); @@ -170,22 +152,16 @@ static void QpsDriver() { client_config.mutable_histogram_params()->set_max_possible( Histogram::default_max_possible()); - if (FLAGS_client_core_list.size() > 0) { - auto v = IntParse(FLAGS_client_core_list); - for (size_t i = 0; i < v.size(); i++) { - client_config.add_core_list(v[i]); - } + if (FLAGS_client_core_limit > 0) { + client_config.set_core_limit(FLAGS_client_core_limit); } ServerConfig server_config; server_config.set_server_type(server_type); server_config.set_async_server_threads(FLAGS_async_server_threads); - if (FLAGS_server_core_list.size() > 0) { - auto v = IntParse(FLAGS_server_core_list); - for (size_t i = 0; i < v.size(); i++) { - server_config.add_core_list(v[i]); - } + if (FLAGS_server_core_limit > 0) { + server_config.set_core_limit(FLAGS_server_core_limit); } if (FLAGS_secure_test) { diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 6289c1a843..d0adbb1a54 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -133,6 +134,12 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { return ret; } + Status CoreCount(ServerContext *ctx, const CoreRequest*, + CoreResponse* resp) GRPC_OVERRIDE { + resp->set_cores(gpr_cpu_num_cores()); + return Status::OK; + } + private: // Protect against multiple clients using this worker at once. class InstanceGuard { -- cgit v1.2.3 From 6b05639ab1fbde6efe4bd702f6267230f470425b Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 1 Feb 2016 13:01:34 -0800 Subject: Make sure that client limit is valid --- test/cpp/qps/driver.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index f3b92c8082..a00d8643f4 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -290,6 +290,7 @@ std::unique_ptr RunScenario( } } if (match) { + GPR_ASSERT(limit > 0); client_core_limit = limit; } } -- cgit v1.2.3 From 595674275bbf54033bebdca9029e0df6245ee67c Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 1 Feb 2016 13:28:55 -0800 Subject: Copyright and clang-format --- src/proto/grpc/testing/services.proto | 2 +- test/cpp/qps/driver.cc | 28 ++++++++++++++-------------- test/cpp/qps/qps_worker.cc | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'test/cpp/qps') diff --git a/src/proto/grpc/testing/services.proto b/src/proto/grpc/testing/services.proto index 59269a23ca..4c8e32bb8f 100644 --- a/src/proto/grpc/testing/services.proto +++ b/src/proto/grpc/testing/services.proto @@ -1,4 +1,4 @@ -// Copyright 2015, Google Inc. +// Copyright 2015-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index a00d8643f4..57b85b107f 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -60,9 +60,9 @@ using std::vector; namespace grpc { namespace testing { -static std::string get_host(const std::string &worker) { - char *host; - char *port; +static std::string get_host(const std::string& worker) { + char* host; + char* port; gpr_split_host_port(worker.c_str(), &host, &port); string s(host); @@ -72,9 +72,9 @@ static std::string get_host(const std::string &worker) { return s; } -static std::unordered_map> - get_hosts_and_cores(const deque& workers) { - std::unordered_map> hosts; +static std::unordered_map> get_hosts_and_cores( + const deque& workers) { + std::unordered_map> hosts; for (auto it = workers.begin(); it != workers.end(); it++) { string host = get_host(*it); if (hosts.find(host) == hosts.end()) { @@ -86,7 +86,7 @@ static std::unordered_map> grpc::Status s = stub->CoreCount(&ctx, dummy, &cores); assert(s.ok()); std::deque dq; - for (int i=0; i RunScenario( const ClientConfig& initial_client_config, size_t num_clients, - const ServerConfig& initial_server_config, size_t num_servers, int warmup_seconds, - int benchmark_seconds, int spawn_local_worker_count) { + const ServerConfig& initial_server_config, size_t num_servers, + int warmup_seconds, int benchmark_seconds, int spawn_local_worker_count) { // ClientContext allocations (all are destroyed at scope exit) list contexts; @@ -228,7 +228,7 @@ std::unique_ptr RunScenario( bool match = false; int limit = dq.size(); for (size_t cli = 0; cli < num_clients; cli++) { - if (host_str == get_host(workers[cli+num_servers])) { + if (host_str == get_host(workers[cli + num_servers])) { limit -= client_core_limit; match = true; } @@ -241,7 +241,7 @@ std::unique_ptr RunScenario( if (server_core_limit > 0) { auto& dq = hosts_cores[host_str]; GPR_ASSERT(dq.size() >= static_cast(server_core_limit)); - for (int core=0; core < server_core_limit; core++) { + for (int core = 0; core < server_core_limit; core++) { server_config.add_core_list(dq.front()); dq.pop_front(); } @@ -270,8 +270,8 @@ std::unique_ptr RunScenario( auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { const auto& worker = workers[i + num_servers]; - gpr_log(GPR_INFO, "Starting client on %s (worker #%d)", - worker.c_str(), i + num_servers); + gpr_log(GPR_INFO, "Starting client on %s (worker #%d)", worker.c_str(), + i + num_servers); clients[i].stub = WorkerService::NewStub( CreateChannel(worker, InsecureChannelCredentials())); ClientConfig per_client_config = client_config; @@ -296,7 +296,7 @@ std::unique_ptr RunScenario( } if (client_core_limit > 0) { GPR_ASSERT(dq.size() >= static_cast(client_core_limit)); - for (int core=0; core < client_core_limit; core++) { + for (int core = 0; core < client_core_limit; core++) { per_client_config.add_core_list(dq.front()); dq.pop_front(); } diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index d0adbb1a54..7e9e05f7ec 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -134,7 +134,7 @@ class WorkerServiceImpl GRPC_FINAL : public WorkerService::Service { return ret; } - Status CoreCount(ServerContext *ctx, const CoreRequest*, + Status CoreCount(ServerContext* ctx, const CoreRequest*, CoreResponse* resp) GRPC_OVERRIDE { resp->set_cores(gpr_cpu_num_cores()); return Status::OK; -- cgit v1.2.3 From 0d7a070e7e51f87bbcdaf72b5a25d0430f82093b Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 1 Feb 2016 14:10:47 -0800 Subject: Add core-limited scenario and protobuf-based QPS scenario --- test/cpp/qps/qps-sweep.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/qps-sweep.sh b/test/cpp/qps/qps-sweep.sh index 333f4bd7d0..539da1d893 100755 --- a/test/cpp/qps/qps-sweep.sh +++ b/test/cpp/qps/qps-sweep.sh @@ -57,6 +57,20 @@ for secure in true false; do --async_client_threads=0 --async_server_threads=0 --secure_test=$secure \ --num_servers=1 --num_clients=0 + # Scenario 2b: QPS with a single server core + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_GENERIC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=64 --bbuf_req_size=0 --bbuf_resp_size=0 \ + --async_client_threads=0 --async_server_threads=0 --secure_test=$secure \ + --num_servers=1 --num_clients=0 --server_core_limit=1 + + # Scenario 2c: protobuf-based QPS + "$bins"/opt/qps_driver --rpc_type=STREAMING --client_type=ASYNC_CLIENT \ + --server_type=ASYNC_SERVER --outstanding_rpcs_per_channel=100 \ + --client_channels=64 --simple_req_size=0 --simple_resp_size=0 \ + --async_client_threads=0 --async_server_threads=0 --secure_test=$secure \ + --num_servers=1 --num_clients=0 + # Scenario 3: Latency at near-peak load (TBD) # Scenario 4: Single-channel bidirectional throughput test (like TCP_STREAM). -- cgit v1.2.3 From 33e51184fcb4bb021a6b2878d90a2d19c53821ff Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 1 Feb 2016 16:40:06 -0800 Subject: Address reviewer comments regarding const and shortage of comments --- test/cpp/qps/driver.cc | 10 +++++----- test/cpp/qps/limit_cores.cc | 4 ++-- test/cpp/qps/limit_cores.h | 9 ++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 57b85b107f..9eef4076d9 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -65,7 +65,7 @@ static std::string get_host(const std::string& worker) { char* port; gpr_split_host_port(worker.c_str(), &host, &port); - string s(host); + const string s(host); gpr_free(host); gpr_free(port); @@ -76,7 +76,7 @@ static std::unordered_map> get_hosts_and_cores( const deque& workers) { std::unordered_map> hosts; for (auto it = workers.begin(); it != workers.end(); it++) { - string host = get_host(*it); + const string host = get_host(*it); if (hosts.find(host) == hosts.end()) { auto stub = WorkerService::NewStub( CreateChannel(*it, InsecureChannelCredentials())); @@ -149,7 +149,7 @@ std::unique_ptr RunScenario( // To be added to the result, containing the final configuration used for // client and config (including host, etc.) ClientConfig result_client_config; - ServerConfig result_server_config = initial_server_config; + const ServerConfig result_server_config = initial_server_config; // Get client, server lists auto workers = get_workers("QPS_WORKERS"); @@ -224,7 +224,7 @@ std::unique_ptr RunScenario( if (server_core_limit == 0 && client_core_limit > 0) { // In this case, limit the server cores if it matches the // same host as one or more clients - const auto& dq = hosts_cores[host_str]; + const auto& dq = hosts_cores.at(host_str); bool match = false; int limit = dq.size(); for (size_t cli = 0; cli < num_clients; cli++) { @@ -239,7 +239,7 @@ std::unique_ptr RunScenario( } } if (server_core_limit > 0) { - auto& dq = hosts_cores[host_str]; + auto& dq = hosts_cores.at(host_str); GPR_ASSERT(dq.size() >= static_cast(server_core_limit)); for (int core = 0; core < server_core_limit; core++) { server_config.add_core_list(dq.front()); diff --git a/test/cpp/qps/limit_cores.cc b/test/cpp/qps/limit_cores.cc index 5fd8d555a5..c2f3ad8fde 100644 --- a/test/cpp/qps/limit_cores.cc +++ b/test/cpp/qps/limit_cores.cc @@ -47,12 +47,12 @@ namespace testing { #endif #include int LimitCores(const int *cores, int cores_size) { - int num_cores = gpr_cpu_num_cores(); + const int num_cores = gpr_cpu_num_cores(); int cores_set = 0; cpu_set_t *cpup = CPU_ALLOC(num_cores); GPR_ASSERT(cpup); - size_t size = CPU_ALLOC_SIZE(num_cores); + const size_t size = CPU_ALLOC_SIZE(num_cores); CPU_ZERO_S(size, cpup); if (cores_size > 0) { diff --git a/test/cpp/qps/limit_cores.h b/test/cpp/qps/limit_cores.h index 5467f3b881..5c0d1e315d 100644 --- a/test/cpp/qps/limit_cores.h +++ b/test/cpp/qps/limit_cores.h @@ -38,9 +38,12 @@ namespace grpc { namespace testing { -// LimitCores takes array and size arguments (instead of vector) for more direct -// conversion from repeated field of protobuf. Use a cores_size of 0 to remove -// existing limits (from an empty repeated field) +/// LimitCores: allow this worker to only run on the cores specified in the +/// array \a cores, which is of length \a cores_size. +/// +/// LimitCores takes array and size arguments (instead of vector) for direct +/// conversion from repeated field of protobuf. Use a cores_size of 0 to remove +/// existing limits (from an empty repeated field) int LimitCores(const int *cores, int cores_size); } // namespace testing } // namespace grpc -- cgit v1.2.3 From daadcc8f745fff4149c37a4ba9467d91694a2c8e Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 1 Feb 2016 16:49:55 -0800 Subject: at --- test/cpp/qps/driver.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 9eef4076d9..c70b0303b8 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -279,7 +279,7 @@ std::unique_ptr RunScenario( int server_core_limit = initial_server_config.core_limit(); int client_core_limit = initial_client_config.core_limit(); if ((server_core_limit > 0) || (client_core_limit > 0)) { - auto& dq = hosts_cores[get_host(worker)]; + auto& dq = hosts_cores.at(get_host(worker)); if (client_core_limit == 0) { // limit client cores if it matches a server host bool match = false; -- cgit v1.2.3