Browse Source

Less mysql connections. Use gdb to debug plaintext. (#5445)

Matthieu Garrigues 5 years ago
parent
commit
33bf3e8e06

+ 2 - 0
frameworks/C++/lithium/gdb.cmds

@@ -0,0 +1,2 @@
+run
+bt

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

@@ -1,7 +1,7 @@
 FROM buildpack-deps:focal
 
 RUN apt update -yqq
-RUN apt install -yqq libboost-dev libmariadb-dev wget  libboost-context-dev g++-9 
+RUN apt install -yqq libboost-dev libmariadb-dev wget  libboost-context-dev g++-9 gdb
 
 COPY ./ ./
 
@@ -10,6 +10,6 @@ ENV COMMIT=c63fddba232e490e151d2446e9ea20b189b15693
 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 g++ -DTFB_MYSQL -O3 -march=native -std=c++17 ./lithium.cc -I /usr/include/mariadb -lpthread -lmariadbclient -lboost_context -o /lithium_tbf
+RUN g++ -g -DTFB_MYSQL -O3 -march=native -std=c++17 ./lithium.cc -I /usr/include/mariadb -lpthread -lmariadbclient -lboost_context -o /lithium_tbf
 
-CMD /lithium_tbf tfb-database 8080
+CMD gdb -batch -x ./gdb.cmds --args /lithium_tbf tfb-database 8080

+ 4 - 4
frameworks/C++/lithium/lithium.cc

@@ -80,12 +80,12 @@ int main(int argc, char* argv[]) {
     response.write_json(s::message = "Hello, World!");
   };
   my_api.get("/db") = [&](http_request& request, http_response& response) {
-    set_max_sql_connections_per_thread(128 / nprocs);
+    set_max_sql_connections_per_thread(64 / nprocs);
     response.write_json(random_numbers.connect(request.yield).find_one(s::id = 1234).value());
   };
 
   my_api.get("/queries") = [&](http_request& request, http_response& response) {
-    set_max_sql_connections_per_thread(2);
+    set_max_sql_connections_per_thread(1);
     std::string N_str = request.get_parameters(s::N = std::optional<std::string>()).N.value_or("1");
     int N = atoi(N_str.c_str());
     
@@ -100,7 +100,7 @@ int main(int argc, char* argv[]) {
   };
 
   my_api.get("/updates") = [&](http_request& request, http_response& response) {
-    set_max_sql_connections_per_thread(2);
+    set_max_sql_connections_per_thread(1);
     std::string N_str = request.get_parameters(s::N = std::optional<std::string>()).N.value_or("1");
     int N = atoi(N_str.c_str());
     N = std::max(1, std::min(N, 500));
@@ -144,7 +144,7 @@ int main(int argc, char* argv[]) {
   };
 
   my_api.get("/fortunes") = [&](http_request& request, http_response& response) {
-    set_max_sql_connections_per_thread(128 / nprocs);
+    set_max_sql_connections_per_thread(64 / nprocs);
 
     typedef decltype(fortunes.all_fields()) fortune;
     std::vector<fortune> table;