Skip to content

Commit 6ec3752

Browse files
committed
2 parents 42f4243 + 33e0326 commit 6ec3752

File tree

445 files changed

+12437
-3667
lines changed

Some content is hidden

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

445 files changed

+12437
-3667
lines changed

frameworks/C/h2o/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.18.0)
2-
project(h2o_app)
2+
project(h2o-app)
33
find_library(CRYPTO_LIB crypto REQUIRED)
44
find_library(H2O_LIB h2o-evloop REQUIRED)
55
find_library(MUSTACHE_C_LIB mustache_c REQUIRED)
@@ -19,7 +19,7 @@ include_directories(${PQ_INCLUDE} ${YAJL_INCLUDE})
1919
set(CMAKE_C_STANDARD 11)
2020
set(CMAKE_C_STANDARD_REQUIRED ON)
2121
add_compile_definitions(H2O_USE_LIBUV=0)
22-
set(COMMON_OPTIONS -flto -pthread)
22+
set(COMMON_OPTIONS -flto=auto -pthread)
2323
add_compile_options(-pedantic -Wall -Wextra ${COMMON_OPTIONS})
2424
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_FORTIFY_SOURCE=2")
2525
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")

frameworks/C/h2o/h2o.dockerfile

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
1-
ARG UBUNTU_VERSION=24.04
1+
ARG UBUNTU_VERSION=25.10
22

3-
ARG H2O_APP_PREFIX=/opt/h2o_app
3+
ARG H2O_APP_PREFIX=/opt/h2o-app
44

55
FROM "ubuntu:${UBUNTU_VERSION}" AS compile
66

77
ARG DEBIAN_FRONTEND=noninteractive
88
RUN apt-get -yqq update && \
9-
apt-get -yqq install \
10-
ca-certificates \
11-
curl \
12-
lsb-release && \
13-
install -dm755 /usr/share/postgresql-common/pgdg && \
14-
curl --fail -LSso /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \
15-
"https://www.postgresql.org/media/keys/ACCC4CF8.asc" && \
16-
sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] \
17-
https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > \
18-
/etc/apt/sources.list.d/pgdg.list' && \
19-
apt-get -yqq update && \
209
apt-get -yqq install \
2110
autoconf \
2211
bison \
2312
cmake \
13+
curl \
2414
flex \
2515
g++ \
2616
libbpfcc-dev \
@@ -50,7 +40,7 @@ RUN curl -LSs "https://github.com/h2o/h2o/archive/${H2O_VERSION}.tar.gz" | \
5040
cmake \
5141
-B build \
5242
-DCMAKE_AR=/usr/bin/gcc-ar \
53-
-DCMAKE_C_FLAGS="-flto -march=native -mtune=native" \
43+
-DCMAKE_C_FLAGS="-flto=auto -march=native -mtune=native" \
5444
-DCMAKE_RANLIB=/usr/bin/gcc-ranlib \
5545
-DWITH_MRUBY=on \
5646
-G Ninja \
@@ -63,7 +53,8 @@ ARG MUSTACHE_C_REVISION=7fe52392879d0188c172d94bb4fde7c513d6b929
6353
WORKDIR /tmp/mustache-c-build
6454
RUN curl -LSs "https://github.com/x86-64/mustache-c/archive/${MUSTACHE_C_REVISION}.tar.gz" | \
6555
tar --strip-components=1 -xz && \
66-
CFLAGS="-flto -march=native -mtune=native -O3" ./autogen.sh && \
56+
CFLAGS="-flto=auto -march=native -mtune=native -O3 -Wno-implicit-function-declaration" \
57+
./autogen.sh && \
6758
make -j "$(nproc)" install
6859

6960
ARG H2O_APP_PREFIX
@@ -82,25 +73,12 @@ RUN cmake \
8273

8374
FROM "ubuntu:${UBUNTU_VERSION}"
8475

85-
ARG POSTGRESQL_VERSION=17
86-
8776
ARG DEBIAN_FRONTEND=noninteractive
8877
RUN apt-get -yqq update && \
89-
apt-get -yqq install \
90-
ca-certificates \
91-
curl \
92-
lsb-release && \
93-
install -dm755 /usr/share/postgresql-common/pgdg && \
94-
curl --fail -LSso /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \
95-
"https://www.postgresql.org/media/keys/ACCC4CF8.asc" && \
96-
sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] \
97-
https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > \
98-
/etc/apt/sources.list.d/pgdg.list' && \
99-
apt-get -yqq update && \
10078
apt-get -yqq install \
10179
libnuma1 \
102-
libyajl2 \
103-
"postgresql-client-${POSTGRESQL_VERSION}"
80+
libpq5 \
81+
libyajl2
10482
ARG H2O_APP_PREFIX
10583
COPY --from=compile "${H2O_APP_PREFIX}" "${H2O_APP_PREFIX}/"
10684
COPY --from=compile /usr/local/lib/libmustache_c.so "${H2O_APP_PREFIX}/lib/"
@@ -113,10 +91,10 @@ ARG TFB_TEST_NAME
11391
CMD ["taskset", \
11492
"-c", \
11593
"0", \
116-
"/opt/h2o_app/bin/h2o_app", \
94+
"/opt/h2o-app/bin/h2o-app", \
11795
"-a20", \
11896
"-d", \
11997
"dbname=hello_world host=tfb-database password=benchmarkdbpass sslmode=disable user=benchmarkdbuser", \
12098
"-f", \
121-
"/opt/h2o_app/share/h2o_app/template", \
99+
"/opt/h2o-app/share/h2o-app/template", \
122100
"-m1"]

frameworks/C/h2o/src/database.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static int flush_connection(h2o_socket_cb cb, db_conn_t *conn)
186186

187187
if (send_status < 0)
188188
LIBRARY_ERROR("PQflush", PQerrorMessage(conn->conn));
189-
else if (send_status)
189+
else if (send_status && !h2o_socket_is_writing(conn->sock))
190190
h2o_socket_notify_write(conn->sock, cb);
191191

192192
return send_status < 0;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AkazawaYun.PRO(https://akazawayun.cn/#akzLearning#%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 生成
2+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS publish
3+
WORKDIR /app
4+
COPY src .
5+
RUN dotnet publish -c Release -o /app/publish
6+
7+
# 运行
8+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS runtime
9+
WORKDIR /app
10+
COPY --from=publish /app/publish .
11+
12+
EXPOSE 2022
13+
ENTRYPOINT ["dotnet", "AkazawaYun.FrameworkBenchmarks.dll"]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"framework": "akazawayun.pro",
3+
"tests": [
4+
{
5+
"default": {
6+
"display_name": "akazawayun.pro",
7+
"framework": "akazawayun.pro",
8+
"webserver": "akazawayun.pro",
9+
"plaintext_url": "/post/plaintext",
10+
"json_url": "/post/json",
11+
"db_url": "/post/db",
12+
"query_url": "/post/queries?queries=",
13+
"update_url": "/post/updates?queries=",
14+
"port": 2022,
15+
"classification": "Micro",
16+
"approach": "Realistic",
17+
"platform": ".NET",
18+
"language": "C#",
19+
"flavor": "CoreCLR",
20+
"os": "Linux",
21+
"database_os": "Linux",
22+
"database": "MySQL",
23+
"orm": "Micro",
24+
"notes": ""
25+
}
26+
}
27+
]
28+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<EnableSourceGenerator>true</EnableSourceGenerator>
9+
<PublishAot>false</PublishAot>
10+
</PropertyGroup>
11+
12+
<PropertyGroup>
13+
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
14+
<ServerGarbageCollection>true</ServerGarbageCollection>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<PackageReference Include="AkazawaYun.PRO" Version="1.13.25.816" />
19+
<PackageReference Include="MySql.Data" Version="9.4.0" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma warning disable IDE1006,CS8981
2+
using AkazawaYun.AOT;
3+
using System.Text.Json.Serialization;
4+
5+
namespace AkazawaYun.FrameworkBenchmarks;
6+
7+
8+
[JsonSerializable(typeof(JsonModel))]
9+
[JsonSerializable(typeof(world[]))]
10+
public partial class AotJsonContext : JsonSerializerContext { }
11+
12+
13+
public class JsonModel
14+
{
15+
public string? message { get; set; }
16+
}
17+
public class world : IAotModel
18+
{
19+
public int id { get; set; }
20+
public int randomNumber { get; set; }
21+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using AkazawaYun.PRO7;
2+
using MySql.Data.MySqlClient;
3+
using System.Data.Common;
4+
5+
namespace AkazawaYun.FrameworkBenchmarks;
6+
7+
class Mysql : akzDbFactory
8+
{
9+
protected override DbConnection NewConnection() => new MySqlConnection(ConString);
10+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#pragma warning disable IDE1006,IL2026
2+
3+
using AkazawaYun.AOT;
4+
using AkazawaYun.PRO7;
5+
using AkazawaYun.PRO7.AkazawaYunWebFunctionAOP;
6+
using AkazawaYun.PRO7.AkazawaYunWebInterceptor;
7+
using System.Diagnostics.CodeAnalysis;
8+
9+
namespace AkazawaYun.FrameworkBenchmarks;
10+
11+
class Program : IPostFunctionWrapper
12+
{
13+
static readonly akzWebBuilder builder;
14+
static readonly akzDbFactory mysql;
15+
16+
17+
static Program()
18+
{
19+
akzJson.Config(null, AotJsonContext.Default);
20+
builder = akzWebBuilder.Shared.SetDefault()
21+
.Build()
22+
.Config<IWebReceptor, akzWebInterceptor>(itc =>
23+
{
24+
itc.ClearInterceptor();
25+
itc.AddInterceptor(new akzWebInterceptorNotOnlyPost());
26+
});
27+
mysql = new akzDbBuilderII()
28+
.SetServer("tfb-database:3306")
29+
//.SetServer("localhost:3306")
30+
.SetUser("benchmarkdbuser")
31+
.SetPwd("benchmarkdbpass")
32+
.SetDatabase("hello_world")
33+
.SetCharset()
34+
.SetOtherset()
35+
.Build<Mysql>();
36+
}
37+
static async Task Main()
38+
{
39+
await builder.Launch();
40+
akzLog.Default = akzLog.Output.None;
41+
await Task.Delay(-1);
42+
}
43+
44+
45+
public static HttpRes plaintext() => HttpRes.HttpOK("Hello, World!", ".txt");
46+
public static JsonModel json() => new()
47+
{
48+
message = "Hello, World!"
49+
};
50+
51+
//[WebFunctionAopTry]
52+
public static async Task<world> db()
53+
{
54+
await using IDb con = await mysql.Connect();
55+
world obj = await WorldService.GetRandomWorld(con);
56+
return obj;
57+
}
58+
//[WebFunctionAopTry]
59+
public static async Task<world[]> queries(string queries)
60+
{
61+
int count = ParseCount(queries);
62+
63+
await using IDb con = await mysql.Connect();
64+
world[] lst = await WorldService.GetWorlds(con, count);
65+
return lst;
66+
}
67+
//[WebFunctionAopTry]
68+
public static async Task<world[]> updates(string queries)
69+
{
70+
int count = ParseCount(queries);
71+
72+
await using IDb con = await mysql.Connect();
73+
world[] lst = await WorldService.GetWorlds(con, count);
74+
75+
foreach (world obj in lst)
76+
obj.randomNumber = Random.Shared.Next(1, 10001);
77+
78+
await WorldService.SaveWorlds(con, lst);
79+
80+
return lst;
81+
}
82+
83+
84+
static int ParseCount(string queries)
85+
{
86+
if (!int.TryParse(queries, out int count))
87+
return 1;
88+
89+
count = Math.Clamp(count, 1, 500);
90+
return count;
91+
}
92+
93+
}

0 commit comments

Comments
 (0)