24 #include "absl/flags/flag.h"
39 "JSON file containing an array of Scenario objects");
41 "JSON string containing an array of Scenario objects");
44 "The parameter, whose value is to be searched for to achieve "
45 "targeted cpu load. For now, we have 'offered_load'. Later, "
46 "'num_channels', 'num_outstanding_requests', etc. shall be "
49 double, initial_search_value, 0.0,
50 "initial parameter value to start the search with (i.e. lower bound)");
51 ABSL_FLAG(
double, targeted_cpu_load, 70.0,
52 "Targeted cpu load (unit: %, range [0,100])");
54 "Defines each stride of the search. The larger the stride is, "
55 "the coarser the result will be, but will also be faster.");
57 "Defines threshold for stopping the search. When current search "
58 "range is narrower than the error_tolerance computed range, we "
62 "Override QPS server target to configure in client configs."
63 "Only applicable if there is a single benchmark server.");
68 "Credential type for communication with workers");
71 "A map of QPS worker addresses to credential types. When creating a "
72 "channel to a QPS worker's driver port, the qps_json_driver first checks "
73 "if the 'name:port' string is in the map, and it uses the corresponding "
74 "credential type if so. If the QPS worker's 'name:port' string is not "
75 "in the map, then the driver -> worker channel will be created with "
76 "the credentials specified in --credential_type. The value of this flag "
77 "is a semicolon-separated list of map entries, where each map entry is "
78 "a comma-separated pair.");
79 ABSL_FLAG(
bool, run_inproc,
false,
"Perform an in-process transport test");
81 int32_t, median_latency_collection_interval_millis, 0,
82 "Specifies the period between gathering latency medians in "
83 "milliseconds. The medians will be logged out on the client at the "
84 "end of the benchmark run. If 0, this periodic collection is disabled.");
89 static std::map<std::string, std::string>
94 std::map<std::string, std::string>
out;
95 while (!remaining.empty()) {
96 size_t next_semicolon = remaining.find(
';');
97 std::string next_entry = remaining.substr(0, next_semicolon);
98 if (next_semicolon == std::string::npos) {
101 remaining = remaining.substr(next_semicolon + 1, std::string::npos);
103 size_t comma = next_entry.find(
',');
104 if (comma == std::string::npos) {
106 "Expectd --per_worker_credential_types to be a list "
107 "of the form: 'addr1,cred_type1;addr2,cred_type2;...' "
112 std::string cred_type = next_entry.substr(comma + 1, std::string::npos);
115 "Found duplicate addr in per_worker_credential_types.");
125 const std::map<std::string, std::string>& per_worker_credential_types,
127 std::cerr <<
"RUNNING SCENARIO: " <<
scenario.
name() <<
"\n";
135 absl::GetFlag(FLAGS_credential_type), per_worker_credential_types,
137 absl::GetFlag(FLAGS_median_latency_collection_interval_millis));
151 for (
int i = 0; *success &&
i <
result->client_success_size();
i++) {
152 *success =
result->client_success(
i);
154 for (
int i = 0; *success &&
i <
result->server_success_size();
i++) {
155 *success =
result->server_success(
i);
159 std::ofstream json_outfile;
161 json_outfile <<
"{\"qps\": " <<
result->summary().qps() <<
"}\n";
162 json_outfile.close();
170 const std::map<std::string, std::string>& per_worker_credential_types,
173 ->mutable_load_params()
175 ->set_offered_load(offered_load);
177 return result->summary().server_cpu_usage();
182 const std::map<std::string, std::string>& per_worker_credential_types,
184 while (low <= high * (1 -
absl::GetFlag(FLAGS_error_tolerance))) {
185 double mid = low + (high - low) / 2;
186 double current_cpu_load =
193 if (targeted_cpu_load <= current_cpu_load) {
205 const std::map<std::string, std::string>& per_worker_credential_types,
207 std::cerr <<
"RUNNING SCENARIO: " <<
scenario->
name() <<
"\n";
208 double current_offered_load = initial_offered_load;
210 per_worker_credential_types, success);
211 if (current_cpu_load > targeted_cpu_load) {
216 while (*success && (current_cpu_load < targeted_cpu_load)) {
217 current_offered_load *= 2;
219 per_worker_credential_types, success);
221 current_offered_load);
224 double targeted_offered_load =
226 current_offered_load, per_worker_credential_types, success);
228 return targeted_offered_load;
234 bool scfile = (!
absl::GetFlag(FLAGS_scenarios_file).empty());
235 bool scjson = (!
absl::GetFlag(FLAGS_scenarios_json).empty());
240 "Exactly one of --scenarios_file, --scenarios_json, "
241 "or --quit must be set");
251 long len = ftell(json_file);
262 per_worker_credential_types);
280 double targeted_offered_load =
283 per_worker_credential_types, &success);
298 int main(
int argc,
char** argv) {