Skip to content

Commit

Permalink
Lithium upgrade (TechEmpower#5850)
Browse files Browse the repository at this point in the history
* Update lithium.

* Lithim cleanup dockerfile.

* Lithium update.

* Add ssl and crypto libs.

* Lithium: fix benchmark config.

* Fix postgresql include.

* Update lithium.

* Lithium update.
  • Loading branch information
matt-42 authored Jul 8, 2020
1 parent a75053c commit 83c76ae
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 100 deletions.
47 changes: 1 addition & 46 deletions frameworks/C++/lithium/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}

}
]
}
15 changes: 0 additions & 15 deletions frameworks/C++/lithium/lithium-mysql-1t.dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions frameworks/C++/lithium/lithium-postgres-1t.dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions frameworks/C++/lithium/lithium-postgres.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 4 additions & 20 deletions frameworks/C++/lithium/lithium.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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());

Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions frameworks/C++/lithium/lithium.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 83c76ae

Please sign in to comment.