Browse Source

Lithium: fix memory leak. (#5526)

* Lithium: fix memory leak.

* Lithium: more benchmarking threads.

* Lithium: disable sql benchmark for plaintext-g.
Matthieu Garrigues 5 years ago
parent
commit
a2091b5f9e

+ 1 - 1
frameworks/C++/lithium/lithium-mysql.dockerfile

@@ -5,7 +5,7 @@ RUN apt install -yqq libboost-dev libmariadb-dev wget  libboost-context-dev g++-
 
 
 COPY ./ ./
 COPY ./ ./
 
 
-ENV COMMIT=7d5ffc3e3439dc5657348adef7f805bcb74beddd
+ENV COMMIT=d66c2fcf52606587601032124cf8a08d47aebaed
 
 
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_mysql.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_mysql.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_http_backend.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_http_backend.hh

+ 2 - 2
frameworks/C++/lithium/lithium-plaintext-g.dockerfile

@@ -5,11 +5,11 @@ RUN apt install -yqq libboost-dev libmariadb-dev wget  libboost-context-dev g++-
 
 
 COPY ./ ./
 COPY ./ ./
 
 
-ENV COMMIT=7d5ffc3e3439dc5657348adef7f805bcb74beddd
+ENV COMMIT=d66c2fcf52606587601032124cf8a08d47aebaed
 
 
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_mysql.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_mysql.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_http_backend.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_http_backend.hh
 
 
-RUN g++ -O3 -g -DTFB_MYSQL -std=c++17 ./lithium.cc -I /usr/include/mariadb -lpthread -lmariadbclient -lboost_context -o /lithium_tbf
+RUN g++ -O3 -g -DTFB_MYSQL -DPLAINTEXT_ONLY -std=c++17 ./lithium.cc -I /usr/include/mariadb -lpthread -lmariadbclient -lboost_context -o /lithium_tbf
 
 
 CMD gdb -batch -x ./gdb.cmds --args /lithium_tbf tfb-database 8080
 CMD gdb -batch -x ./gdb.cmds --args /lithium_tbf tfb-database 8080

+ 1 - 1
frameworks/C++/lithium/lithium-postgres.dockerfile

@@ -5,7 +5,7 @@ RUN apt install -yqq g++-9 libboost-dev postgresql-server-dev-all libpq-dev wget
 
 
 COPY ./ ./
 COPY ./ ./
 
 
-ENV COMMIT=7d5ffc3e3439dc5657348adef7f805bcb74beddd
+ENV COMMIT=d66c2fcf52606587601032124cf8a08d47aebaed
 
 
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_pgsql.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_pgsql.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_http_backend.hh
 RUN wget https://raw.githubusercontent.com/matt-42/lithium/$COMMIT/single_headers/lithium_http_backend.hh

+ 3 - 1
frameworks/C++/lithium/lithium.cc

@@ -46,7 +46,7 @@ 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;
 
 
-    float req_per_s = http_benchmark(sockets, 1, 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)
     {
     {
@@ -191,6 +191,7 @@ 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.
   // Tune the number of sql connections.
   int tunning_port = port+1;
   int tunning_port = port+1;
   std::thread server_thread([&] {
   std::thread server_thread([&] {
@@ -206,6 +207,7 @@ int main(int argc, char* argv[]) {
   li::quit_signal_catched = true;
   li::quit_signal_catched = true;
   server_thread.join();
   server_thread.join();
   li::quit_signal_catched = false;
   li::quit_signal_catched = false;
+#endif
 
 
   // 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);