|
@@ -33,7 +33,7 @@ void set_max_sql_connections_per_thread(int max)
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
-float tune_n_sql_connections(int& nc_to_tune, std::string http_req, int port, int min, int max) {
|
|
|
|
|
|
+void tune_n_sql_connections(int& nc_to_tune, std::string http_req, int port, int min, int max) {
|
|
|
|
|
|
std::cout << std::endl << "Benchmark " << http_req << std::endl;
|
|
std::cout << std::endl << "Benchmark " << http_req << std::endl;
|
|
|
|
|
|
@@ -46,6 +46,8 @@ float tune_n_sql_connections(int& nc_to_tune, std::string http_req, int port, in
|
|
int nc = min + (max - min) * i / 7;
|
|
int nc = min + (max - min) * i / 7;
|
|
nc_to_tune = nc;
|
|
nc_to_tune = nc;
|
|
|
|
|
|
|
|
+ // Warmup.
|
|
|
|
+ http_benchmark(sockets, 4, 200, http_req);
|
|
float req_per_s = http_benchmark(sockets, 4, 1000, http_req);
|
|
float req_per_s = http_benchmark(sockets, 4, 1000, http_req);
|
|
std::cout << nc << " -> " << req_per_s << " req/s." << std::endl;
|
|
std::cout << nc << " -> " << req_per_s << " req/s." << std::endl;
|
|
if (req_per_s > max_req_per_s)
|
|
if (req_per_s > max_req_per_s)
|
|
@@ -59,7 +61,6 @@ float tune_n_sql_connections(int& nc_to_tune, std::string http_req, int port, in
|
|
|
|
|
|
std::cout << "best: " << best_nconn << " (" << max_req_per_s << " req/s)."<< std::endl;
|
|
std::cout << "best: " << best_nconn << " (" << max_req_per_s << " req/s)."<< std::endl;
|
|
nc_to_tune = best_nconn;
|
|
nc_to_tune = best_nconn;
|
|
- return best_nconn;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
int main(int argc, char* argv[]) {
|
|
@@ -94,10 +95,10 @@ int main(int argc, char* argv[]) {
|
|
s::randomNumber = int());
|
|
s::randomNumber = int());
|
|
|
|
|
|
|
|
|
|
- int db_nconn = 64;
|
|
|
|
- int queries_nconn = 64;
|
|
|
|
- int fortunes_nconn = 64;
|
|
|
|
- int updates_nconn = 64;
|
|
|
|
|
|
+ int db_nconn = 128/nprocs;
|
|
|
|
+ int queries_nconn = 2;
|
|
|
|
+ int fortunes_nconn = 128/nprocs;
|
|
|
|
+ int updates_nconn = 2;
|
|
|
|
|
|
http_api my_api;
|
|
http_api my_api;
|
|
|
|
|
|
@@ -191,23 +192,21 @@ int main(int argc, char* argv[]) {
|
|
response.write(ss.to_string_view());
|
|
response.write(ss.to_string_view());
|
|
};
|
|
};
|
|
|
|
|
|
-#ifndef PLAINTEXT_ONLY
|
|
|
|
- // Tune the number of sql connections.
|
|
|
|
- int tunning_port = port+1;
|
|
|
|
- std::thread server_thread([&] {
|
|
|
|
- http_serve(my_api, tunning_port, s::nthreads = nprocs);
|
|
|
|
- });
|
|
|
|
- usleep(3e5);
|
|
|
|
-
|
|
|
|
- tune_n_sql_connections(db_nconn, "GET /db HTTP/1.1\r\n\r\n", tunning_port, 1, sql_max_connection/nprocs);
|
|
|
|
- tune_n_sql_connections(queries_nconn, "GET /queries?N=20 HTTP/1.1\r\n\r\n", tunning_port, 1, std::min(sql_max_connection/nprocs, 20));
|
|
|
|
- tune_n_sql_connections(fortunes_nconn, "GET /fortunes HTTP/1.1\r\n\r\n", tunning_port, 1, sql_max_connection/nprocs);
|
|
|
|
- tune_n_sql_connections(updates_nconn, "GET /updates?N=20 HTTP/1.1\r\n\r\n", tunning_port, 1, std::min(sql_max_connection/nprocs, 20));
|
|
|
|
|
|
+ // // Tune the number of sql connections.
|
|
|
|
+ // int tunning_port = port+1;
|
|
|
|
+ // std::thread server_thread([&] {
|
|
|
|
+ // http_serve(my_api, tunning_port, s::nthreads = nprocs);
|
|
|
|
+ // });
|
|
|
|
+ // usleep(3e5);
|
|
|
|
+
|
|
|
|
+ // tune_n_sql_connections(db_nconn, "GET /db HTTP/1.1\r\n\r\n", tunning_port, 1, sql_max_connection/nprocs);
|
|
|
|
+ // tune_n_sql_connections(queries_nconn, "GET /queries?N=20 HTTP/1.1\r\n\r\n", tunning_port, 1, std::min(sql_max_connection/nprocs, 14));
|
|
|
|
+ // tune_n_sql_connections(fortunes_nconn, "GET /fortunes HTTP/1.1\r\n\r\n", tunning_port, 1, sql_max_connection/nprocs);
|
|
|
|
+ // tune_n_sql_connections(updates_nconn, "GET /updates?N=20 HTTP/1.1\r\n\r\n", tunning_port, 1, std::min(sql_max_connection/nprocs, 7));
|
|
|
|
|
|
- li::quit_signal_catched = true;
|
|
|
|
- server_thread.join();
|
|
|
|
- li::quit_signal_catched = false;
|
|
|
|
-#endif
|
|
|
|
|
|
+ // li::quit_signal_catched = true;
|
|
|
|
+ // server_thread.join();
|
|
|
|
+ // li::quit_signal_catched = false;
|
|
|
|
|
|
// Start the server for the Techempower benchmark.
|
|
// Start the server for the Techempower benchmark.
|
|
http_serve(my_api, port, s::nthreads = nprocs);
|
|
http_serve(my_api, port, s::nthreads = nprocs);
|