Skip to content

Commit

Permalink
Merge pull request #25 from TechEmpower/master
Browse files Browse the repository at this point in the history
aa
  • Loading branch information
smthing authored Nov 21, 2022
2 parents 77905da + 288381e commit 66beba8
Show file tree
Hide file tree
Showing 807 changed files with 18,980 additions and 7,012 deletions.
52 changes: 27 additions & 25 deletions frameworks/C++/cutelyst/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
"versus": ""
},
"pf-apg": {
"db_url": "/dbp",
"query_url": "/queriesp?queries=",
"db_url": "/pg",
"query_url": "/querAPG?queries=",
"update_url": "/updatep?queries=",
"fortune_url": "/fortunes_raw_p",
"fortune_url": "/f_RW_APG",
"cached_query_url": "/cached_queries?count=",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand Down Expand Up @@ -57,10 +58,10 @@
"versus": ""
},
"pf-pg": {
"db_url": "/db_postgres",
"query_url": "/query_postgres?queries=",
"update_url": "/updates_postgres?queries=",
"fortune_url": "/fortunes_raw_postgres",
"db_url": "/PG",
"query_url": "/queryPG?queries=",
"update_url": "/ups_QPG?queries=",
"fortune_url": "/f_RW_QPG",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand All @@ -77,10 +78,10 @@
"versus": ""
},
"pf-my": {
"db_url": "/db_mysql",
"query_url": "/query_mysql?queries=",
"update_url": "/updates_mysql?queries=",
"fortune_url": "/fortunes_raw_mysql",
"db_url": "/MY",
"query_url": "/queryMY?queries=",
"update_url": "/ups_QMY?queries=",
"fortune_url": "/f_RW_QMY",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand Down Expand Up @@ -132,10 +133,11 @@
"versus": ""
},
"thread-apg": {
"db_url": "/dbp",
"query_url": "/queriesp?queries=",
"db_url": "/pg",
"query_url": "/querAPG?queries=",
"update_url": "/updatep?queries=",
"fortune_url": "/fortunes_raw_p",
"fortune_url": "/f_RW_APG",
"cached_query_url": "/cached_queries?count=",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand Down Expand Up @@ -169,10 +171,10 @@
"versus": ""
},
"thread-pg": {
"db_url": "/db_postgres",
"query_url": "/query_postgres?queries=",
"update_url": "/updates_postgres?queries=",
"fortune_url": "/fortunes_raw_postgres",
"db_url": "/PG",
"query_url": "/queryPG?queries=",
"update_url": "/ups_QPG?queries=",
"fortune_url": "/f_RW_QPG",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand All @@ -189,7 +191,7 @@
"versus": ""
},
"thread-pg-cutelee": {
"fortune_url": "/fortunes_cutelee_postgres",
"fortune_url": "/f_CL_QPG",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand All @@ -206,7 +208,7 @@
"versus": ""
},
"t-apg-cutelee": {
"fortune_url": "/fortunes_c_p",
"fortune_url": "/f_CL_APG",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand All @@ -223,10 +225,10 @@
"versus": ""
},
"thread-my": {
"db_url": "/db_mysql",
"query_url": "/query_mysql?queries=",
"update_url": "/updates_mysql?queries=",
"fortune_url": "/fortunes_raw_mysql",
"db_url": "/MY",
"query_url": "/queryMY?queries=",
"update_url": "/ups_QMY?queries=",
"fortune_url": "/f_RW_QMY",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand All @@ -243,7 +245,7 @@
"versus": ""
},
"thread-my-cutelee": {
"fortune_url": "/fortunes_cutelee_mysql",
"fortune_url": "/f_CL_QMY",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
Expand Down
26 changes: 13 additions & 13 deletions frameworks/C++/cutelyst/build.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
#!/bin/bash

export ASQL_VER=0.46.0
export CUTELEE_VER=6.0.0
export CUTELYST_VER=3.1.0
export ASQL_VER=0.74.0
export CUTELEE_VER=6.1.0
export CUTELYST_VER=3.7.0

apt update -qq && \
apt install -yqq --no-install-recommends \
cmake \
git \
pkg-config \
qtbase5-dev \
libqt5sql5-mysql \
libqt5sql5-psql \
qtdeclarative5-dev \
qt6-base-dev \
libqt6sql6-mysql \
libqt6sql6-psql \
libegl1-mesa-dev \
postgresql-server-dev-all

wget -q https://github.com/cutelyst/cutelee/releases/download/v${CUTELEE_VER}/cutelee_${CUTELEE_VER}_amd64.deb && \
apt install -yqq ./cutelee_${CUTELEE_VER}_amd64.deb
wget -q https://github.com/cutelyst/cutelee/releases/download/v${CUTELEE_VER}/cutelee6-qt6_${CUTELEE_VER}_amd64.deb && \
apt install -yqq ./cutelee6-qt6_${CUTELEE_VER}_amd64.deb

wget -q https://github.com/cutelyst/asql/releases/download/v${ASQL_VER}/libasql_${ASQL_VER}_amd64.deb && \
apt install -yqq ./libasql_${ASQL_VER}_amd64.deb
wget -q https://github.com/cutelyst/asql/releases/download/v${ASQL_VER}/libasql0-qt6_${ASQL_VER}_amd64.deb && \
apt install -yqq ./libasql0-qt6_${ASQL_VER}_amd64.deb

wget -q https://github.com/cutelyst/cutelyst/releases/download/v${CUTELYST_VER}/cutelyst_${CUTELYST_VER}_amd64.deb && \
apt install -yqq ./cutelyst_${CUTELYST_VER}_amd64.deb
wget -q https://github.com/cutelyst/cutelyst/releases/download/v${CUTELYST_VER}/cutelyst3-qt6_${CUTELYST_VER}_amd64.deb && \
apt install -yqq ./cutelyst3-qt6_${CUTELYST_VER}_amd64.deb

cd ${TROOT} && \
mkdir -p build && \
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-nginx-my.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-nginx-pg.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-nginx.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-pf-apg-batch.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-pf-apg.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-pf-my.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-pf-pg.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-t-apg-cutelee.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-thread-apg.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-thread-my.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-thread-pg.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-thread-pico.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst-thread.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C++/cutelyst/cutelyst.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN apt-get update -qq && \
apt-get install -yqq locales wget build-essential
Expand Down
30 changes: 16 additions & 14 deletions frameworks/C++/cutelyst/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(mimalloc)

find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core Network Sql)
find_package(ASqlQt5 0.43.0 REQUIRED)
find_package(Cutelyst3Qt5 3.1 REQUIRED)
find_package(Cutelee6Qt5 6.0.0 REQUIRED)
find_package(Qt6 6.2.0 REQUIRED COMPONENTS Core Network Sql)
find_package(ASqlQt6 0.74 REQUIRED)
find_package(Cutelyst3Qt6 3.6 REQUIRED)
find_package(Cutelee6Qt6 6.1.0 REQUIRED)
find_package(PostgreSQL REQUIRED)

# Auto generate moc files
Expand Down Expand Up @@ -44,10 +44,10 @@ set(cutelyst_benchmarks_SRCS
multipledatabasequeriestest.h
plaintexttest.cpp
plaintexttest.h
root.cpp
root.h
singledatabasequerytest.cpp
singledatabasequerytest.h
cachedqueries.h
cachedqueries.cpp
${TEMPLATES_SRC}
)

Expand All @@ -60,10 +60,11 @@ target_link_libraries(cutelyst_benchmarks
Cutelyst::Core
Cutelyst::Utils::Sql
Cutelyst::View::Cutelee
Qt5::Core
Qt5::Network
Qt5::Sql
ASqlQt5::Core
Qt::Core
Qt::Network
Qt::Sql
ASql::Core
ASql::Pg
)

add_executable(cutelyst-benchmarks ${cutelyst_benchmarks_SRCS} main.cpp)
Expand All @@ -73,10 +74,11 @@ target_link_libraries(cutelyst-benchmarks
Cutelyst::Server
Cutelyst::Utils::Sql
Cutelyst::View::Cutelee
Qt5::Core
Qt5::Network
Qt5::Sql
ASqlQt5::Core
Qt::Core
Qt::Network
Qt::Sql
ASql::Core
ASql::Pg
mimalloc
)
if (mimalloc_FOUND)
Expand Down
70 changes: 70 additions & 0 deletions frameworks/C++/cutelyst/src/cachedqueries.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "cachedqueries.h"

#include <apool.h>
#include <aresult.h>
#include <apreparedquery.h>

#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>

#include <QCache>

using namespace ASql;

CachedQueries::CachedQueries(QObject *parent)
: Controller{parent}
{

}

void CachedQueries::cached_queries(Context *c)
{
int queries = c->request()->queryParam(QStringLiteral("count")).toInt();
if (queries < 1) {
queries = 1;
} else if (queries > 500) {
queries = 500;
}

static thread_local QCache<int, QJsonObject> cache(1024);

auto array = std::shared_ptr<QJsonArray>(new QJsonArray);

ASync async(c);
static thread_local auto db = APool::database();
for (int i = 0; i < queries; ++i) {
const int id = (rand() % 10000) + 1;

QJsonObject *obj = cache[id];
if (obj) {
array->append(*obj);
continue;
}

db.exec(APreparedQueryLiteral(u8"SELECT id, randomNumber FROM world WHERE id=$1"),
{id}, c, [c, async, i, queries, array] (AResult &result) {
if (Q_LIKELY(!result.error() && result.size())) {
auto it = result.begin();
int id = it[0].toInt();
auto obj = new QJsonObject({
{QStringLiteral("id"), id},
{QStringLiteral("randomNumber"), it[1].toInt()}
});
array->append(*obj);
cache.insert(id, obj, 1);

if (array->size() == queries) {
c->response()->setJsonArrayBody(*array);
}
return;
}

c->res()->setStatus(Response::InternalServerError);
});
}

if (array->size() == queries) {
c->response()->setJsonArrayBody(*array);
}
}
Loading

0 comments on commit 66beba8

Please sign in to comment.