Skip to content

Commit 587111e

Browse files
authored
Merge branch 'TechEmpower:master' into tio-server
2 parents 5b97544 + 526fcef commit 587111e

1,047 files changed

Lines changed: 28955 additions & 13301 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ jobs:
155155
# run-ci.py runs the diffing to see if github actions needs to test this framework. Ideally/eventually,
156156
# we'd like to try and do the diffing before github_actions_clean & setup.
157157
# This will run the tests exactly as you would in your own vm:
158-
docker network create tfb > /dev/null 2>&1 && docker run --network=tfb -e USER_ID=$(id -u) -e CI=true -v /var/run/docker.sock:/var/run/docker.sock --mount type=bind,source=`pwd`,target=/FrameworkBenchmarks techempower/tfb --mode verify --test-dir $RUN_TESTS --results-environment Github-Actions;
158+
docker network create tfb > /dev/null 2>&1 && docker run --network=tfb -e USER_ID=$(id -u) -e CI=true -v /var/run/docker.sock:/var/run/docker.sock --mount type=bind,source=`pwd`,target=/FrameworkBenchmarks techempower/tfb --mode verify --force-rm --test-dir $RUN_TESTS --results-environment Github-Actions;
159159
dependabot:
160160
needs: verify
161161
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ benchmark.cfg
6969

7070
# python
7171
.venv/
72+
frameworks/CSharp/akazawayun.pro/Dockerfile

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ ARG DEBIAN_FRONTEND=noninteractive
44
# WARNING: DON'T PUT A SPACE AFTER ANY BACKSLASH OR APT WILL BREAK
55
# One -q produces output suitable for logging (mostly hides
66
# progress indicators)
7-
RUN apt-get -yqq update && \
8-
apt-get -yqq install \
7+
RUN apt-get install \
8+
--no-install-recommends \
99
-o Dpkg::Options::="--force-confdef" \
1010
-o Dpkg::Options::="--force-confold" \
11+
-qqUy \
1112
cloc \
1213
curl \
1314
gcc \

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -eo pipefail -u
44

55
chown -LR "$USER_ID" /var/run
66
# Drop permissions of user to match those of the host system
7-
gosu "$USER_ID" python3 "${FWROOT}/toolset/run-tests.py" "$@"
7+
exec gosu "$USER_ID" python3 "${FWROOT}/toolset/run-tests.py" "$@"

frameworks/C++/ffead-cpp/benchmark_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
"display_name": "ffead-cpp [pg-raw-async-prof-pool-m]",
199199
"notes": "async memory profiled",
200200
"versus": "",
201-
"tags": []
201+
"tags": ["broken"]
202202
},
203203
"postgresql-raw-async-clibpqb-profiled": {
204204
"db_url": "/t4/d",
@@ -301,7 +301,7 @@
301301
"display_name": "ffead-cpp [pg-raw-async-qw-prof-pool-m]",
302302
"notes": "async memory profiled",
303303
"versus": "",
304-
"tags": []
304+
"tags": ["broken"]
305305
}
306306
}]
307307
}

frameworks/C++/paozhu/paozhu_benchmark/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
197197

198198

199199
if(${mode} AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
200-
add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/test/testbenchmark.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
200+
add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/startup/main_docker.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
201201
else()
202-
add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
202+
add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/startup/main_dev.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
203203
endif()
204204

205205
if (ENABLE_WIN_VCPKG STREQUAL "ON")

frameworks/C/h2o/CMakeLists.txt

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cmake_minimum_required(VERSION 3.18.0)
22
project(h2o-app)
3+
find_library(BPF_LIB bpf REQUIRED)
34
find_library(CRYPTO_LIB crypto REQUIRED)
45
find_library(H2O_LIB h2o-evloop REQUIRED)
56
find_library(MUSTACHE_C_LIB mustache_c REQUIRED)
@@ -8,27 +9,56 @@ find_library(PQ_LIB pq REQUIRED)
89
find_library(SSL_LIB ssl REQUIRED)
910
find_library(YAJL_LIB yajl REQUIRED)
1011
find_library(Z_LIB z REQUIRED)
12+
find_path(ASM_INCLUDE asm/types.h REQUIRED)
13+
find_path(BPF_INCLUDE bpf/libbpf.h REQUIRED)
1114
find_path(H2O_INCLUDE h2o.h REQUIRED)
1215
find_path(MUSTACHE_C_INCLUDE mustache.h REQUIRED)
1316
find_path(NUMA_INCLUDE numaif.h REQUIRED)
1417
find_path(OPENSSL_INCLUDE openssl/ssl.h REQUIRED)
1518
find_path(PQ_INCLUDE postgresql/libpq-fe.h REQUIRED)
1619
find_path(YAJL_INCLUDE yajl/yajl_gen.h REQUIRED)
17-
include_directories(src ${H2O_INCLUDE} ${MUSTACHE_C_INCLUDE} ${NUMA_INCLUDE} ${OPENSSL_INCLUDE})
18-
include_directories(${PQ_INCLUDE} ${YAJL_INCLUDE})
20+
find_program(BPFTOOL_BIN bpftool REQUIRED)
21+
find_program(CLANG_BIN clang REQUIRED)
22+
include_directories(src ${CMAKE_BINARY_DIR} ${BPF_INCLUDE} ${H2O_INCLUDE} ${MUSTACHE_C_INCLUDE})
23+
include_directories(${NUMA_INCLUDE} ${OPENSSL_INCLUDE} ${PQ_INCLUDE} ${YAJL_INCLUDE})
1924
set(CMAKE_C_STANDARD 11)
2025
set(CMAKE_C_STANDARD_REQUIRED ON)
2126
add_compile_definitions(H2O_USE_LIBUV=0)
2227
set(COMMON_OPTIONS -flto=auto -pthread)
23-
add_compile_options(-pedantic -Wall -Wextra ${COMMON_OPTIONS})
28+
set(WARNING_OPTIONS -pedantic -Wall -Wextra)
29+
add_compile_options(${COMMON_OPTIONS} ${WARNING_OPTIONS})
2430
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_FORTIFY_SOURCE=2")
2531
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
2632
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3")
27-
file(GLOB_RECURSE SOURCES "src/*.c")
28-
add_executable(${PROJECT_NAME} ${SOURCES})
33+
add_custom_command(
34+
OUTPUT ${CMAKE_BINARY_DIR}/socket_load_balancer.h
35+
COMMAND ${CLANG_BIN}
36+
-c
37+
-DNDEBUG
38+
-g
39+
-I ${ASM_INCLUDE}
40+
-I ${BPF_INCLUDE}
41+
-mcpu=v3
42+
-o ${CMAKE_BINARY_DIR}/socket_load_balancer.o
43+
-O3
44+
-std=gnu11
45+
-target bpf
46+
${WARNING_OPTIONS}
47+
${CMAKE_CURRENT_SOURCE_DIR}/src/bpf/socket_load_balancer.c
48+
COMMAND ${BPFTOOL_BIN} gen skeleton ${CMAKE_BINARY_DIR}/socket_load_balancer.o >
49+
${CMAKE_BINARY_DIR}/socket_load_balancer.h
50+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/bpf/socket_load_balancer.c
51+
VERBATIM)
52+
add_custom_target(
53+
generated_headers
54+
DEPENDS ${CMAKE_BINARY_DIR}/socket_load_balancer.h)
55+
file(GLOB_RECURSE HANDLER_SOURCES "src/handlers/*.c")
56+
file(GLOB SOURCES "src/*.c")
57+
add_executable(${PROJECT_NAME} ${HANDLER_SOURCES} ${SOURCES})
58+
add_dependencies(${PROJECT_NAME} generated_headers)
2959
target_link_libraries(${PROJECT_NAME} ${COMMON_OPTIONS})
30-
target_link_libraries(${PROJECT_NAME} ${H2O_LIB} m ${MUSTACHE_C_LIB} ${NUMA_LIB} ${PQ_LIB})
31-
target_link_libraries(${PROJECT_NAME} ${SSL_LIB} ${CRYPTO_LIB} ${YAJL_LIB} ${Z_LIB})
60+
target_link_libraries(${PROJECT_NAME} ${BPF_LIB} ${H2O_LIB} m ${MUSTACHE_C_LIB} ${NUMA_LIB})
61+
target_link_libraries(${PROJECT_NAME} ${PQ_LIB} ${SSL_LIB} ${CRYPTO_LIB} ${YAJL_LIB} ${Z_LIB})
3262
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
3363
file(GLOB TEMPLATES "template/*")
3464
install(FILES ${TEMPLATES} DESTINATION share/${PROJECT_NAME}/template)

frameworks/C/h2o/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
# h2o
1+
# h2o-app
22

33
This is a framework implementation using the [H2O](https://h2o.examp1e.net) HTTP server. It
44
builds directly on top of `libh2o` instead of running the standalone server.
55

66
## Requirements
77

8-
[CMake](https://cmake.org), [H2O](https://h2o.examp1e.net), [libpq](https://www.postgresql.org),
9-
[mustache-c](https://github.com/x86-64/mustache-c), [numactl](https://github.com/numactl/numactl),
10-
[OpenSSL](https://www.openssl.org), [YAJL](https://lloyd.github.io/yajl)
8+
[bpftool](https://bpftool.dev/),
9+
[Clang](https://clang.llvm.org/),
10+
[CMake](https://cmake.org/),
11+
[GNU C Library](https://www.gnu.org/software/libc),
12+
[H2O](https://h2o.examp1e.net/),
13+
[libbpf](https://github.com/libbpf/libbpf),
14+
[libpq](https://www.postgresql.org/),
15+
[Linux](https://kernel.org/),
16+
[mustache-c](https://github.com/x86-64/mustache-c),
17+
[numactl](https://github.com/numactl/numactl),
18+
[OpenSSL](https://www.openssl.org/),
19+
[YAJL](https://lloyd.github.io/yajl)
1120

1221
## Test implementations
1322

@@ -30,4 +39,4 @@ options respectively.
3039

3140
## Contact
3241

33-
Anton Kirilov <antonvkirilov@gmail.com>
42+
Anton Kirilov <antonvkirilov@proton.me>

frameworks/C/h2o/h2o.dockerfile

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,53 @@ ARG UBUNTU_VERSION=25.10
22

33
ARG H2O_APP_PREFIX=/opt/h2o-app
44

5-
FROM "ubuntu:${UBUNTU_VERSION}" AS compile
5+
FROM "buildpack-deps:${UBUNTU_VERSION}" AS compile
66

7+
RUN echo "[timing] Installing system packages: $(date)"
78
ARG DEBIAN_FRONTEND=noninteractive
8-
RUN apt-get -yqq update && \
9-
apt-get -yqq install \
9+
RUN apt-get install \
10+
--no-install-recommends \
11+
-qqUy \
1012
autoconf \
13+
automake \
1114
bison \
15+
bpftool \
16+
clang \
1217
cmake \
1318
curl \
1419
flex \
15-
g++ \
16-
libbpfcc-dev \
20+
gcc \
21+
libbpf-dev \
1722
libbrotli-dev \
1823
libcap-dev \
1924
libnuma-dev \
2025
libpq-dev \
2126
libssl-dev \
2227
libtool \
28+
liburing-dev \
2329
libuv1-dev \
24-
libwslay-dev \
2530
libyajl-dev \
2631
libz-dev \
27-
llvm-dev \
2832
make \
29-
ninja-build \
3033
pkg-config \
31-
rsync \
3234
ruby \
3335
systemtap-sdt-dev
3436

35-
ARG H2O_VERSION=c54c63285b52421da2782f028022647fc2ea3dd1
37+
RUN echo "[timing] Building H2O: $(date)"
38+
ARG H2O_VERSION=3b9b6a53cac8bcc6a25fb28df81ad295fc5f9402
3639

3740
WORKDIR /tmp/h2o-build
3841
RUN curl -LSs "https://github.com/h2o/h2o/archive/${H2O_VERSION}.tar.gz" | \
3942
tar --strip-components=1 -xz && \
4043
cmake \
4144
-B build \
42-
-DCMAKE_AR=/usr/bin/gcc-ar \
4345
-DCMAKE_C_FLAGS="-flto=auto -march=native -mtune=native" \
44-
-DCMAKE_RANLIB=/usr/bin/gcc-ranlib \
4546
-DWITH_MRUBY=on \
46-
-G Ninja \
4747
-S . && \
4848
cmake --build build -j && \
4949
cmake --install build
5050

51+
RUN echo "[timing] Building mustache-c: $(date)"
5152
ARG MUSTACHE_C_REVISION=7fe52392879d0188c172d94bb4fde7c513d6b929
5253

5354
WORKDIR /tmp/mustache-c-build
@@ -57,6 +58,7 @@ RUN curl -LSs "https://github.com/x86-64/mustache-c/archive/${MUSTACHE_C_REVISIO
5758
./autogen.sh && \
5859
make -j "$(nproc)" install
5960

61+
RUN echo "[timing] Building h2o-app: $(date)"
6062
ARG H2O_APP_PREFIX
6163
WORKDIR /tmp/build
6264
COPY CMakeLists.txt ../
@@ -66,19 +68,24 @@ RUN cmake \
6668
-DCMAKE_BUILD_TYPE=Release \
6769
-DCMAKE_C_FLAGS="-march=native -mtune=native" \
6870
-DCMAKE_INSTALL_PREFIX="${H2O_APP_PREFIX}" \
69-
-G Ninja \
7071
-S .. && \
7172
cmake --build . -j && \
7273
cmake --install .
74+
RUN echo "[timing] Finished compiling: $(date)"
7375

7476
FROM "ubuntu:${UBUNTU_VERSION}"
7577

78+
RUN echo "[timing] Installing final system packages: $(date)"
7679
ARG DEBIAN_FRONTEND=noninteractive
77-
RUN apt-get -yqq update && \
78-
apt-get -yqq install \
80+
RUN apt-get install \
81+
--no-install-recommends \
82+
-qqUy \
83+
libbpf1 \
7984
libnuma1 \
8085
libpq5 \
86+
liburing2 \
8187
libyajl2
88+
RUN echo "[timing] Copying h2o-app to its final location: $(date)"
8289
ARG H2O_APP_PREFIX
8390
COPY --from=compile "${H2O_APP_PREFIX}" "${H2O_APP_PREFIX}/"
8491
COPY --from=compile /usr/local/lib/libmustache_c.so "${H2O_APP_PREFIX}/lib/"
@@ -87,6 +94,7 @@ EXPOSE 8080
8794
ARG BENCHMARK_ENV
8895
ARG TFB_TEST_DATABASE
8996
ARG TFB_TEST_NAME
97+
RUN echo "[timing] Running h2o-app: $(date)"
9098

9199
CMD ["taskset", \
92100
"-c", \
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
Copyright (c) 2025 Anton Valentinov Kirilov
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5+
associated documentation files (the "Software"), to deal in the Software without restriction,
6+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
7+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or
11+
substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
17+
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18+
*/
19+
20+
// TODO: Switch to the standard atomics (<stdatomic.h>) after
21+
// the system header file mess gets sorted for eBPF.
22+
#include <stdbool.h>
23+
#include <stddef.h>
24+
#include <linux/bpf.h>
25+
#include <bpf/bpf_helpers.h>
26+
27+
// We need a finite number of iterations to keep the eBPF verifier happy.
28+
#define MAX_ITERATIONS 42
29+
30+
static size_t thread_idx;
31+
size_t thread_num = 1;
32+
33+
SEC("socket") int socket_load_balancer(void *skb)
34+
{
35+
(void) skb;
36+
37+
// TODO: Use __atomic_load_n() after LLVM starts supporting it for eBPF.
38+
size_t idx = *(const volatile size_t *) &thread_idx;
39+
int ret = thread_num;
40+
41+
__atomic_thread_fence(__ATOMIC_RELAXED);
42+
43+
for (size_t i = 0; i < MAX_ITERATIONS; i++) {
44+
const size_t new_idx = (idx + 1) % thread_num;
45+
46+
if (__atomic_compare_exchange_n(&thread_idx,
47+
&idx,
48+
new_idx,
49+
false,
50+
__ATOMIC_RELAXED,
51+
__ATOMIC_RELAXED)) {
52+
ret = idx;
53+
break;
54+
}
55+
}
56+
57+
return ret;
58+
}

0 commit comments

Comments
 (0)