Browse Source

Add the lithium-postgres test. (#5319)

* [new c++ framework] Lithium.

* Some cleanup.

* [lithium ] Add test to travis.

* Update lithium.

* Update lithium.

* Update lithium.

* Update Lithium. Tune the number of mysql connections.

* Update Lithium. Tune the number of mysql connections.

* Add the lithium-postgres test.

* 512 postgres connections.

* Add the lithium-postgres test.

* 512 postgres connections.

* Update lithium.
Matthieu Garrigues 5 years ago
parent
commit
6ef4867921

+ 26 - 2
frameworks/C++/lithium/benchmark_config.json

@@ -2,7 +2,7 @@
   "framework": "lithium",
   "tests": [
     {
-      "default": {
+      "mysql": {
         "json_url"       : "/json",
         "db_url"         : "/db",
         "query_url"      : "/queries?N=",
@@ -21,10 +21,34 @@
         "webserver": "None",
         "os": "Linux",
         "database_os": "Linux",
-        "display_name": "Lithium",
+        "display_name": "Lithium-mysql",
+        "notes": "",
+        "versus": "None"
+      },
+      "postgres": {
+        "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": "Postgres",
+        "framework": "Lithium",
+        "language": "C++",
+        "flavor": "None",
+        "orm": "Full",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "Lithium-postgres",
         "notes": "",
         "versus": "None"
       }
+      
     }
   ]
 }

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

@@ -6,11 +6,11 @@ RUN apt install -yqq libboost-context-dev
 
 COPY ./ ./
 
-ENV COMMIT=8399f065741cbf2060f8f91b451fe8391b852664
+ENV COMMIT=454e0a04a9c4ceb85764437e9b5ea28730f6d2d9
 
 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++ -O3 -DNDEBUG -march=native -std=c++17 ./lithium.cc -I /usr/include/mariadb -lpthread -lmariadbclient -lboost_context -o /lithium_tbf
+RUN g++ -DTFB_MYSQL -O3 -DNDEBUG -march=native -std=c++17 ./lithium.cc -I /usr/include/mariadb -lpthread -lmariadbclient -lboost_context -o /lithium_tbf
 
 CMD /lithium_tbf tfb-database 8080 $(nproc)

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

@@ -0,0 +1,15 @@
+FROM buildpack-deps:focal
+
+RUN apt update -yqq
+RUN apt install -yqq g++-9 libboost-dev postgresql-server-dev-all libpq-dev wget libboost-context-dev
+
+COPY ./ ./
+
+ENV COMMIT=454e0a04a9c4ceb85764437e9b5ea28730f6d2d9
+
+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
+
+CMD /lithium_tbf tfb-database 8080 $(nproc)

+ 22 - 9
frameworks/C++/lithium/lithium.cc

@@ -1,5 +1,10 @@
 #include "lithium_http_backend.hh"
-#include "lithium_mysql.hh"
+
+#if TFB_MYSQL
+  #include "lithium_mysql.hh"
+#elif TFB_PGSQL
+  #include "lithium_pgsql.hh"
+#endif
 
 #include "symbols.hh"
 using namespace li;
@@ -26,25 +31,33 @@ int main(int argc, char* argv[]) {
 
   if (argc != 4)
   {
-    std::cerr << "Usage: " << argv[0] << " mysql_host port nprocs" << std::endl;
+    std::cerr << "Usage: " << argv[0] << " sql_host port nprocs" << std::endl;
     return 1;
   }
 
   int port = atoi(argv[2]);
   int nprocs = atoi(argv[3]);
-  
-  auto mysql_db =
-      mysql_database(s::host = argv[1], s::database = "hello_world", s::user = "benchmarkdbuser",
-                     s::password = "benchmarkdbpass", s::port = 3306, s::charset = "utf8");
 
-  int mysql_max_connection = mysql_db.connect()("SELECT @@GLOBAL.max_connections;").read<int>() * 0.75;
+#if TFB_MYSQL
+  auto sql_db =
+    mysql_database(s::host = argv[1], s::database = "hello_world", s::user = "benchmarkdbuser",
+                   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);
 
-  auto fortunes = sql_orm_schema(mysql_db, "Fortune").fields(
+#elif TFB_PGSQL
+  auto sql_db =
+    pgsql_database(s::host = argv[1], s::database = "hello_world", s::user = "benchmarkdbuser",
+                   s::password = "benchmarkdbpass", s::port = 5432, s::charset = "utf8");
+  int pgsql_max_connection = 512;
+  li::max_pgsql_connections_per_thread = (pgsql_max_connection / nprocs);
+#endif
+
+  auto fortunes = sql_orm_schema(sql_db, "Fortune").fields(
     s::id(s::auto_increment, s::primary_key) = int(),
     s::message = std::string());
 
-  auto random_numbers = sql_orm_schema(mysql_db, "World").fields(
+  auto random_numbers = sql_orm_schema(sql_db, "World").fields(
     s::id(s::auto_increment, s::primary_key) = int(),
     s::randomNumber = int());