Browse Source

Lithium: async postgres connect. (#5365)

* Lithium: async postgres connect.

* Lithium: One thread for postgres.

* Lithium: Fix mysql.

* Lithium: Fix multithread on postgresql.
Matthieu Garrigues 5 years ago
parent
commit
d50ac6b1ba

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

@@ -1,12 +1,11 @@
 FROM buildpack-deps:focal
 
 RUN apt update -yqq
-RUN apt install -yqq g++-9 libboost-dev libmariadb-dev wget
-RUN apt install -yqq libboost-context-dev
+RUN apt install -yqq libboost-dev libmariadb-dev wget  libboost-context-dev g++-9 
 
 COPY ./ ./
 
-ENV COMMIT=e8dc32136a1a5b766dc7626101cf5b64e2510af5
+ENV COMMIT=0a02d05e4c9eab883d9031aabee01017027db8de
 
 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

+ 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 ./ ./
 
-ENV COMMIT=e8dc32136a1a5b766dc7626101cf5b64e2510af5
+ENV COMMIT=0a02d05e4c9eab883d9031aabee01017027db8de
 
 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

+ 2 - 0
frameworks/C++/lithium/lithium.cc

@@ -41,6 +41,7 @@ int main(int argc, char* argv[]) {
                    s::password = "benchmarkdbpass", s::port = 3306, s::charset = "utf8");
   int mysql_max_connection = sql_db.connect()("SELECT @@GLOBAL.max_connections;").read<int>() * 0.75;
   li::max_mysql_connections_per_thread = (mysql_max_connection / nprocs);
+  std::cout << "Using " << li::max_mysql_connections_per_thread << " connections per thread. " << nprocs << " threads." << std::endl; 
 
 #elif TFB_PGSQL
   auto sql_db =
@@ -48,6 +49,7 @@ int main(int argc, char* argv[]) {
                    s::password = "benchmarkdbpass", s::port = 5432, s::charset = "utf8");
   int pgsql_max_connection = atoi(sql_db.connect()("SHOW max_connections;").read<std::string>().c_str()) * 0.75;
   li::max_pgsql_connections_per_thread = (pgsql_max_connection / nprocs);
+  std::cout << "Using " << li::max_pgsql_connections_per_thread << " connections per thread. " << nprocs << " threads." << std::endl; 
 #endif
 
   auto fortunes = sql_orm_schema(sql_db, "Fortune").fields(