Browse Source

Update lithium. Correctly set the number of posgres connections. (#5333)

* [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.

* Lithium optimization.

* Lithium optimization.

* Update lithium.

* Lithium: use emplace_back to avoid useless extra copies.
Matthieu Garrigues 5 years ago
parent
commit
1fee14bb2d

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

@@ -6,7 +6,7 @@ RUN apt install -yqq libboost-context-dev
 
 COPY ./ ./
 
-ENV COMMIT=454e0a04a9c4ceb85764437e9b5ea28730f6d2d9
+ENV COMMIT=5f409d2f995f8e8b1998f4e1a914a18c09109e4b
 
 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=454e0a04a9c4ceb85764437e9b5ea28730f6d2d9
+ENV COMMIT=5f409d2f995f8e8b1998f4e1a914a18c09109e4b
 
 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

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

@@ -49,7 +49,7 @@ int main(int argc, char* argv[]) {
   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;
+  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);
 #endif
 
@@ -112,8 +112,8 @@ int main(int argc, char* argv[]) {
     std::vector<fortune> table;
 
     auto c = fortunes.connect(request.yield);
-    c.forall([&] (auto f) { table.push_back(f); });
-    table.push_back(fortune(0, std::string("Additional fortune added at request time.")));
+    c.forall([&] (auto f) { table.emplace_back(f); });
+    table.emplace_back(0, "Additional fortune added at request time.");
 
     std::sort(table.begin(), table.end(),
               [] (const fortune& a, const fortune& b) { return a.message < b.message; });