OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * |
| 3 * Copyright 2015-2016, Google Inc. |
| 4 * All rights reserved. |
| 5 * |
| 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are |
| 8 * met: |
| 9 * |
| 10 * * Redistributions of source code must retain the above copyright |
| 11 * notice, this list of conditions and the following disclaimer. |
| 12 * * Redistributions in binary form must reproduce the above |
| 13 * copyright notice, this list of conditions and the following disclaimer |
| 14 * in the documentation and/or other materials provided with the |
| 15 * distribution. |
| 16 * * Neither the name of Google Inc. nor the names of its |
| 17 * contributors may be used to endorse or promote products derived from |
| 18 * this software without specific prior written permission. |
| 19 * |
| 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 * |
| 32 */ |
| 33 |
| 34 #include <memory> |
| 35 #include <set> |
| 36 |
| 37 #include <gflags/gflags.h> |
| 38 #include <grpc/support/log.h> |
| 39 |
| 40 #include "test/cpp/qps/driver.h" |
| 41 #include "test/cpp/qps/report.h" |
| 42 #include "test/cpp/util/benchmark_config.h" |
| 43 |
| 44 DEFINE_int32(num_clients, 1, "Number of client binaries"); |
| 45 DEFINE_int32(num_servers, 1, "Number of server binaries"); |
| 46 |
| 47 DEFINE_int32(warmup_seconds, 5, "Warmup time (in seconds)"); |
| 48 DEFINE_int32(benchmark_seconds, 30, "Benchmark time (in seconds)"); |
| 49 DEFINE_int32(local_workers, 0, "Number of local workers to start"); |
| 50 |
| 51 // Server config |
| 52 DEFINE_int32(async_server_threads, 1, "Number of threads for async servers"); |
| 53 DEFINE_string(server_type, "SYNC_SERVER", "Server type"); |
| 54 DEFINE_int32(server_core_limit, -1, "Limit on server cores to use"); |
| 55 |
| 56 // Client config |
| 57 DEFINE_string(rpc_type, "UNARY", "Type of RPC: UNARY or STREAMING"); |
| 58 DEFINE_int32(outstanding_rpcs_per_channel, 1, |
| 59 "Number of outstanding rpcs per channel"); |
| 60 DEFINE_int32(client_channels, 1, "Number of client channels"); |
| 61 |
| 62 DEFINE_int32(simple_req_size, -1, "Simple proto request payload size"); |
| 63 DEFINE_int32(simple_resp_size, -1, "Simple proto response payload size"); |
| 64 DEFINE_int32(bbuf_req_size, -1, "Byte-buffer request payload size"); |
| 65 DEFINE_int32(bbuf_resp_size, -1, "Byte-buffer response payload size"); |
| 66 |
| 67 DEFINE_string(client_type, "SYNC_CLIENT", "Client type"); |
| 68 DEFINE_int32(async_client_threads, 1, "Async client threads"); |
| 69 |
| 70 DEFINE_double(poisson_load, -1.0, "Poisson offered load (qps)"); |
| 71 DEFINE_double(uniform_lo, -1.0, "Uniform low interarrival time (us)"); |
| 72 DEFINE_double(uniform_hi, -1.0, "Uniform high interarrival time (us)"); |
| 73 DEFINE_double(determ_load, -1.0, "Deterministic offered load (qps)"); |
| 74 DEFINE_double(pareto_base, -1.0, "Pareto base interarrival time (us)"); |
| 75 DEFINE_double(pareto_alpha, -1.0, "Pareto alpha value"); |
| 76 |
| 77 DEFINE_int32(client_core_limit, -1, "Limit on client cores to use"); |
| 78 |
| 79 DEFINE_bool(secure_test, false, "Run a secure test"); |
| 80 |
| 81 DEFINE_bool(quit, false, "Quit the workers"); |
| 82 |
| 83 using grpc::testing::ClientConfig; |
| 84 using grpc::testing::ServerConfig; |
| 85 using grpc::testing::ClientType; |
| 86 using grpc::testing::ServerType; |
| 87 using grpc::testing::RpcType; |
| 88 using grpc::testing::ResourceUsage; |
| 89 using grpc::testing::SecurityParams; |
| 90 |
| 91 namespace grpc { |
| 92 namespace testing { |
| 93 |
| 94 static void QpsDriver() { |
| 95 if (FLAGS_quit) { |
| 96 RunQuit(); |
| 97 return; |
| 98 } |
| 99 |
| 100 RpcType rpc_type; |
| 101 GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type)); |
| 102 |
| 103 ClientType client_type; |
| 104 ServerType server_type; |
| 105 GPR_ASSERT(ClientType_Parse(FLAGS_client_type, &client_type)); |
| 106 GPR_ASSERT(ServerType_Parse(FLAGS_server_type, &server_type)); |
| 107 |
| 108 ClientConfig client_config; |
| 109 client_config.set_client_type(client_type); |
| 110 client_config.set_outstanding_rpcs_per_channel( |
| 111 FLAGS_outstanding_rpcs_per_channel); |
| 112 client_config.set_client_channels(FLAGS_client_channels); |
| 113 |
| 114 // Decide which type to use based on the response type |
| 115 if (FLAGS_simple_resp_size >= 0) { |
| 116 auto params = |
| 117 client_config.mutable_payload_config()->mutable_simple_params(); |
| 118 params->set_resp_size(FLAGS_simple_resp_size); |
| 119 if (FLAGS_simple_req_size >= 0) { |
| 120 params->set_req_size(FLAGS_simple_req_size); |
| 121 } |
| 122 } else if (FLAGS_bbuf_resp_size >= 0) { |
| 123 auto params = |
| 124 client_config.mutable_payload_config()->mutable_bytebuf_params(); |
| 125 params->set_resp_size(FLAGS_bbuf_resp_size); |
| 126 if (FLAGS_bbuf_req_size >= 0) { |
| 127 params->set_req_size(FLAGS_bbuf_req_size); |
| 128 } |
| 129 } else { |
| 130 // set a reasonable default: proto but no payload |
| 131 client_config.mutable_payload_config()->mutable_simple_params(); |
| 132 } |
| 133 |
| 134 client_config.set_async_client_threads(FLAGS_async_client_threads); |
| 135 client_config.set_rpc_type(rpc_type); |
| 136 |
| 137 // set up the load parameters |
| 138 if (FLAGS_poisson_load > 0.0) { |
| 139 auto poisson = client_config.mutable_load_params()->mutable_poisson(); |
| 140 poisson->set_offered_load(FLAGS_poisson_load); |
| 141 } else if (FLAGS_uniform_lo > 0.0) { |
| 142 auto uniform = client_config.mutable_load_params()->mutable_uniform(); |
| 143 uniform->set_interarrival_lo(FLAGS_uniform_lo / 1e6); |
| 144 uniform->set_interarrival_hi(FLAGS_uniform_hi / 1e6); |
| 145 } else if (FLAGS_determ_load > 0.0) { |
| 146 auto determ = client_config.mutable_load_params()->mutable_determ(); |
| 147 determ->set_offered_load(FLAGS_determ_load); |
| 148 } else if (FLAGS_pareto_base > 0.0) { |
| 149 auto pareto = client_config.mutable_load_params()->mutable_pareto(); |
| 150 pareto->set_interarrival_base(FLAGS_pareto_base / 1e6); |
| 151 pareto->set_alpha(FLAGS_pareto_alpha); |
| 152 } else { |
| 153 client_config.mutable_load_params()->mutable_closed_loop(); |
| 154 // No further load parameters to set up for closed loop |
| 155 } |
| 156 |
| 157 client_config.mutable_histogram_params()->set_resolution( |
| 158 Histogram::default_resolution()); |
| 159 client_config.mutable_histogram_params()->set_max_possible( |
| 160 Histogram::default_max_possible()); |
| 161 |
| 162 if (FLAGS_client_core_limit > 0) { |
| 163 client_config.set_core_limit(FLAGS_client_core_limit); |
| 164 } |
| 165 |
| 166 ServerConfig server_config; |
| 167 server_config.set_server_type(server_type); |
| 168 server_config.set_async_server_threads(FLAGS_async_server_threads); |
| 169 |
| 170 if (FLAGS_server_core_limit > 0) { |
| 171 server_config.set_core_limit(FLAGS_server_core_limit); |
| 172 } |
| 173 |
| 174 if (FLAGS_secure_test) { |
| 175 // Set up security params |
| 176 SecurityParams security; |
| 177 security.set_use_test_ca(true); |
| 178 security.set_server_host_override("foo.test.google.fr"); |
| 179 client_config.mutable_security_params()->CopyFrom(security); |
| 180 server_config.mutable_security_params()->CopyFrom(security); |
| 181 } |
| 182 |
| 183 // Make sure that if we are performing a generic (bytebuf) test |
| 184 // that we are also using async streaming |
| 185 GPR_ASSERT(!client_config.payload_config().has_bytebuf_params() || |
| 186 (client_config.client_type() == ASYNC_CLIENT && |
| 187 client_config.rpc_type() == STREAMING && |
| 188 server_config.server_type() == ASYNC_GENERIC_SERVER)); |
| 189 |
| 190 const auto result = RunScenario( |
| 191 client_config, FLAGS_num_clients, server_config, FLAGS_num_servers, |
| 192 FLAGS_warmup_seconds, FLAGS_benchmark_seconds, FLAGS_local_workers); |
| 193 |
| 194 GetReporter()->ReportQPS(*result); |
| 195 GetReporter()->ReportQPSPerCore(*result); |
| 196 GetReporter()->ReportLatency(*result); |
| 197 GetReporter()->ReportTimes(*result); |
| 198 } |
| 199 |
| 200 } // namespace testing |
| 201 } // namespace grpc |
| 202 |
| 203 int main(int argc, char** argv) { |
| 204 grpc::testing::InitBenchmark(&argc, &argv, true); |
| 205 |
| 206 grpc::testing::QpsDriver(); |
| 207 |
| 208 return 0; |
| 209 } |
OLD | NEW |