Browse Source

Lithium upgrade (#5850)

* Update lithium.

* Lithim cleanup dockerfile.

* Lithium update.

* Add ssl and crypto libs.

* Lithium: fix benchmark config.

* Fix postgresql include.

* Update lithium.

* Lithium update.
Matthieu Garrigues 5 years ago
parent
commit
83c76ae704

+ 1 - 46
frameworks/C++/lithium/benchmark_config.json

@@ -25,29 +25,7 @@
         "notes": "",
         "versus": "None"
       },
-      "mysql-1t": {
-        "json_url"       : "/json",
-        "db_url"         : "/db",
-        "query_url"      : "/queries?N=",
-        "fortune_url"    : "/fortunes",
-        "update_url"     : "/updates?N=",
-        "plaintext_url"  : "/plaintext",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "Micro",
-        "database": "mysql",
-        "framework": "Lithium",
-        "language": "C++",
-        "flavor": "None",
-        "orm": "Full",
-        "platform": "None",
-        "webserver": "None",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "Lithium-mysql-1t",
-        "notes": "",
-        "versus": "None"
-      },
+      
       "postgres": {
         "json_url"       : "/json",
         "db_url"         : "/db",
@@ -70,30 +48,7 @@
         "display_name": "Lithium-postgres",
         "notes": "",
         "versus": "None"
-      },
-
-      "postgres-1t": {
-        "db_url"         : "/db",
-        "query_url"      : "/queries?N=",
-        "fortune_url"    : "/fortunes",
-        "update_url"     : "/updates?N=",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "Micro",
-        "database": "Postgres",
-        "framework": "Lithium",
-        "language": "C++",
-        "flavor": "None",
-        "orm": "Full",
-        "platform": "None",
-        "webserver": "None",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "Lithium-postgres-1t",
-        "notes": "",
-        "versus": "None"
       }
-
     }
   ]
 }

+ 0 - 15
frameworks/C++/lithium/lithium-mysql-1t.dockerfile

@@ -1,15 +0,0 @@
-FROM buildpack-deps:focal
-
-RUN apt-get update -yqq
-RUN apt-get install -yqq libboost-dev libmariadb-dev wget  libboost-context-dev g++-9
-
-COPY ./ ./
-
-ENV COMMIT=062c167b61ba14292d54bade9534adca33a8d19e
-
-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++ -DNDEBUG -DTFB_MYSQL -DMONOTHREAD -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

+ 0 - 15
frameworks/C++/lithium/lithium-postgres-1t.dockerfile

@@ -1,15 +0,0 @@
-FROM buildpack-deps:focal
-
-RUN apt-get update -yqq
-RUN apt-get install -yqq g++-9 libboost-dev postgresql-server-dev-all libpq-dev wget libboost-context-dev
-
-COPY ./ ./
-
-ENV COMMIT=062c167b61ba14292d54bade9534adca33a8d19e
-
-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 g++ -DTFB_PGSQL -DMONOTHREAD -O3 -DNDEBUG -march=native -std=c++17 ./lithium.cc -I/usr/include/postgresql -lpthread -lpq -lboost_context -o /lithium_tbf
-
-CMD /lithium_tbf tfb-database 8080

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

@@ -5,11 +5,11 @@ RUN apt-get install -yqq g++-9 libboost-dev postgresql-server-dev-all libpq-dev
 
 COPY ./ ./
 
-ENV COMMIT=062c167b61ba14292d54bade9534adca33a8d19e
+ENV COMMIT=c9de812a119f1c585a613953d956ab61b9ffa197
 
 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 g++ -DTFB_PGSQL -O3 -DNDEBUG -march=native -std=c++17 ./lithium.cc -I/usr/include/postgresql -lpthread -lpq -lboost_context -o /lithium_tbf
+RUN g++ -DTFB_PGSQL -O3 -DNDEBUG -march=native -std=c++17 ./lithium.cc -I/usr/include/postgresql -I /usr/include/postgresql/12/server -lpthread -lpq -lboost_context -lssl -lcrypto -o /lithium_tbf
 
 CMD /lithium_tbf tfb-database 8080

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

@@ -24,15 +24,6 @@ void escape_html_entities(B& buffer, const std::string& data)
     }
 }
 
-void set_max_sql_connections_per_thread(int max)
-{
-#if TFB_MYSQL
-  li::max_mysql_connections_per_thread = max;
-#elif TFB_PGSQL
-  li::max_pgsql_connections_per_thread = max;
-#endif
-}
-
 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;
@@ -109,13 +100,6 @@ int main(int argc, char* argv[]) {
   int updates_nconn = 3;
 #endif
 
-#if MONOTHREAD
-  db_nconn *= nprocs;
-  queries_nconn *= nprocs;
-  fortunes_nconn *= nprocs;
-  updates_nconn *= nprocs;
-#endif
-
   http_api my_api;
 
   my_api.get("/plaintext") = [&](http_request& request, http_response& response) {
@@ -127,12 +111,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(db_nconn);
+    sql_db.max_async_connections_per_thread_ = db_nconn;
     response.write_json(random_numbers.connect(request.fiber).find_one(s::id = 1 + rand() % 10000).value());
   };
 
   my_api.get("/queries") = [&](http_request& request, http_response& response) {
-    set_max_sql_connections_per_thread(queries_nconn);
+    sql_db.max_async_connections_per_thread_ = queries_nconn;
     std::string N_str = request.get_parameters(s::N = std::optional<std::string>()).N.value_or("1");
     int N = atoi(N_str.c_str());
     
@@ -147,7 +131,7 @@ int main(int argc, char* argv[]) {
   };
 
   my_api.get("/updates") = [&](http_request& request, http_response& response) {
-    set_max_sql_connections_per_thread(updates_nconn);
+    sql_db.max_async_connections_per_thread_ = updates_nconn;
     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));
@@ -180,7 +164,7 @@ int main(int argc, char* argv[]) {
   };
 
   my_api.get("/fortunes") = [&](http_request& request, http_response& response) {
-    set_max_sql_connections_per_thread(fortunes_nconn);
+    sql_db.max_async_connections_per_thread_ = fortunes_nconn;
 
     typedef decltype(fortunes.all_fields()) fortune;
     std::vector<fortune> table;

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

@@ -5,11 +5,11 @@ RUN apt-get install -yqq libboost-dev libmariadb-dev wget  libboost-context-dev
 
 COPY ./ ./
 
-ENV COMMIT=062c167b61ba14292d54bade9534adca33a8d19e
+ENV COMMIT=c9de812a119f1c585a613953d956ab61b9ffa197
 
 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++ -DNDEBUG -DTFB_MYSQL -O3 -march=native -std=c++17 ./lithium.cc -I /usr/include/mariadb -lpthread -lmariadbclient -lboost_context -o /lithium_tbf
+RUN g++ -DNDEBUG -DTFB_MYSQL -O3 -march=native -std=c++17 ./lithium.cc -I /usr/include/mariadb -lpthread -lmariadbclient -lboost_context -lssl -lcrypto -o /lithium_tbf
 
 CMD /lithium_tbf tfb-database 8080