Skip to content

Commit eca7315

Browse files
authored
Merge branch 'TechEmpower:master' into master
2 parents 23924c3 + 2b00b28 commit eca7315

Some content is hidden

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

65 files changed

+295
-224
lines changed

.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) -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 --test-dir $RUN_TESTS --results-environment Github-Actions;
159159
dependabot:
160160
needs: verify
161161
runs-on: ubuntu-latest

frameworks/Java/tio-boot/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<java.version>1.8</java.version>
1212
<maven.compiler.source>${java.version}</maven.compiler.source>
1313
<maven.compiler.target>${java.version}</maven.compiler.target>
14-
<tio-boot.version>1.9.3</tio-boot.version>
14+
<tio-boot.version>1.9.4</tio-boot.version>
1515

1616

1717
<main.class>com.litongjava.tio.http.server.MainApp</main.class>

frameworks/Java/tio-http-server/pom.xml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
42
<modelVersion>4.0.0</modelVersion>
53
<groupId>com.litongjava</groupId>
64
<artifactId>tio-http-server-benchmark</artifactId>
@@ -18,17 +16,18 @@
1816
<dependency>
1917
<groupId>com.litongjava</groupId>
2018
<artifactId>tio-http-server</artifactId>
21-
<version>3.7.3.v20250301-RELEASE</version>
19+
<version>3.7.3.v20250401-RELEASE</version>
2220
</dependency>
23-
<dependency>
21+
22+
<dependency>
2423
<groupId>com.litongjava</groupId>
25-
<artifactId>tio-core</artifactId>
26-
<version>3.7.3.v20250305-RELEASE</version>
24+
<artifactId>tio-utils</artifactId>
25+
<version>3.7.3.v20250401-RELEASE</version>
2726
</dependency>
2827
<dependency>
2928
<groupId>com.litongjava</groupId>
3029
<artifactId>java-db</artifactId>
31-
<version>1.5.0</version>
30+
<version>1.5.1</version>
3231
</dependency>
3332
<dependency>
3433
<groupId>junit</groupId>
@@ -62,6 +61,12 @@
6261
<version>4.0.3</version>
6362
</dependency>
6463

64+
<dependency>
65+
<groupId>ch.qos.logback</groupId>
66+
<artifactId>logback-classic</artifactId>
67+
<version>1.2.13</version>
68+
</dependency>
69+
6570
</dependencies>
6671
<repositories>
6772
<repository>

frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/MainApp.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import com.litongjava.tio.http.server.config.EhCachePluginConfig;
66
import com.litongjava.tio.http.server.config.EnjoyEngineConfig;
77
import com.litongjava.tio.http.server.config.MysqlDbConfig;
8-
import com.litongjava.tio.http.server.controller.CacheController;
9-
import com.litongjava.tio.http.server.controller.DbController;
10-
import com.litongjava.tio.http.server.controller.IndexController;
8+
import com.litongjava.tio.http.server.handler.CacheHandler;
9+
import com.litongjava.tio.http.server.handler.DbHandler;
1110
import com.litongjava.tio.http.server.handler.DefaultHttpRequestDispatcher;
11+
import com.litongjava.tio.http.server.handler.IndexHandler;
1212
import com.litongjava.tio.http.server.router.DefaultHttpRequestRouter;
1313
import com.litongjava.tio.http.server.router.HttpRequestRouter;
1414
import com.litongjava.tio.server.ServerTioConfig;
@@ -21,20 +21,20 @@ public static void main(String[] args) {
2121
EnvUtils.buildCmdArgsMap(args);
2222
EnvUtils.load();
2323
// add route
24-
IndexController controller = new IndexController();
24+
IndexHandler controller = new IndexHandler();
2525

2626
HttpRequestRouter simpleHttpRoutes = new DefaultHttpRequestRouter();
2727
simpleHttpRoutes.add("/", controller::index);
2828
simpleHttpRoutes.add("/plaintext", controller::plaintext);
2929
simpleHttpRoutes.add("/json", controller::json);
3030

31-
DbController dbQueryController = new DbController();
31+
DbHandler dbQueryController = new DbHandler();
3232
simpleHttpRoutes.add("/db", dbQueryController::db);
3333
simpleHttpRoutes.add("/queries", dbQueryController::queries);
3434
simpleHttpRoutes.add("/updates", dbQueryController::updates);
3535
simpleHttpRoutes.add("/fortunes", dbQueryController::fortunes);
3636

37-
CacheController cacheController = new CacheController();
37+
CacheHandler cacheController = new CacheHandler();
3838
simpleHttpRoutes.add("/cachedQuery", cacheController::cachedQuery);
3939

4040
// config server

frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/CacheController.java renamed to frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/handler/CacheHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.litongjava.tio.http.server.controller;
1+
package com.litongjava.tio.http.server.handler;
22

33
import java.util.List;
44
import java.util.Map;
@@ -14,7 +14,7 @@
1414
import com.litongjava.tio.http.common.HttpResponse;
1515
import com.litongjava.tio.http.server.utils.RandomUtils;
1616

17-
public class CacheController {
17+
public class CacheHandler {
1818
// private Logger log = LoggerFactory.getLogger(this.getClass());
1919

2020
public HttpResponse cachedQuery(HttpRequest request) {

frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/DbController.java renamed to frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/handler/DbHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.litongjava.tio.http.server.controller;
1+
package com.litongjava.tio.http.server.handler;
22

33
import java.util.ArrayList;
44
import java.util.Comparator;
@@ -22,7 +22,7 @@
2222
import com.litongjava.tio.http.server.util.Resps;
2323
import com.litongjava.tio.http.server.utils.RandomUtils;
2424

25-
public class DbController {
25+
public class DbHandler {
2626

2727
public HttpResponse db(HttpRequest request) {
2828
Integer id = request.getInt("id");

frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/controller/IndexController.java renamed to frameworks/Java/tio-http-server/src/main/java/com/litongjava/tio/http/server/handler/IndexHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.litongjava.tio.http.server.controller;
1+
package com.litongjava.tio.http.server.handler;
22

33
import com.alibaba.fastjson2.JSON;
44
import com.litongjava.tio.http.common.HeaderName;
@@ -12,7 +12,7 @@
1212
* ab -k -n1000000 -c10 http://127.0.0.1:8080/json
1313
* ab -k -n1000000 -c10 http://127.0.0.1:8080/plaintext
1414
*/
15-
public class IndexController {
15+
public class IndexHandler {
1616
private static final String HELLO_WORLD = "Hello, World!";
1717

1818
private static final byte[] HELLO_WORLD_BYTES = HELLO_WORLD.getBytes();

frameworks/Kotlin/ktor/ktor-r2dbc/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<name>org.jetbrains.ktor tech-empower-framework-benchmark</name>
1313

1414
<properties>
15-
<kotlin.version>2.0.21</kotlin.version>
15+
<kotlin.version>2.1.20</kotlin.version>
1616
<kotlin.coroutines.version>1.10.1</kotlin.coroutines.version>
1717
<ktor.version>3.1.1</ktor.version>
1818
<serialization.version>1.8.0</serialization.version>

frameworks/Kotlin/ktor/ktor-r2dbc/src/main/kotlin/org/jetbrains/ktor/benchmarks/Hello.kt

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ import org.jetbrains.ktor.benchmarks.models.World
3232
import reactor.core.publisher.Flux
3333
import reactor.core.publisher.Mono
3434
import kotlin.random.Random
35+
import java.time.Duration
36+
37+
private val json = Json {
38+
prettyPrint = false
39+
isLenient = true
40+
ignoreUnknownKeys = true
41+
coerceInputValues = true
42+
}
3543

3644
fun Application.main() {
3745
val config = ApplicationConfig("application.conf")
@@ -40,22 +48,23 @@ fun Application.main() {
4048
install(DefaultHeaders)
4149

4250
val helloWorldContent = TextContent("Hello, World!", ContentType.Text.Plain)
51+
val helloWorldMsg = Message("Hello, world!")
4352

4453
routing {
4554
get("/plaintext") {
4655
call.respond(helloWorldContent)
4756
}
4857

4958
get("/json") {
50-
call.respondText(Json.encodeToString(Message("Hello, world!")), ContentType.Application.Json)
59+
call.respondText(json.encodeToString(helloWorldMsg), ContentType.Application.Json)
5160
}
5261

5362
get("/db") {
5463
val random = Random.Default
5564
val request = getWorld(dbConnFactory, random)
5665
val result = request.awaitFirstOrNull()
5766

58-
call.respondText(Json.encodeToString(result), ContentType.Application.Json)
67+
call.respondText(json.encodeToString(result), ContentType.Application.Json)
5968
}
6069

6170
fun selectWorlds(queries: Int, random: Random): Flow<World> = flow {
@@ -74,7 +83,7 @@ fun Application.main() {
7483
}
7584
}
7685

77-
call.respondText(Json.encodeToString(result), ContentType.Application.Json)
86+
call.respondText(json.encodeToString(result), ContentType.Application.Json)
7887
}
7988

8089
get("/fortunes") {
@@ -135,21 +144,28 @@ fun Application.main() {
135144
}
136145
}
137146

138-
call.respondText(Json.encodeToString(worldsUpdated), ContentType.Application.Json)
147+
call.respondText(json.encodeToString(worldsUpdated), ContentType.Application.Json)
139148
}
140149
}
141150
}
142151

143152
private fun getWorld(
144153
dbConnFactory: ConnectionFactory, random: Random
145154
): Mono<World> = Mono.usingWhen(dbConnFactory.create(), { connection ->
146-
Mono.from(connection.createStatement(WORLD_QUERY).bind(0, random.nextInt(DB_ROWS) + 1).execute()).flatMap { r ->
147-
Mono.from(r.map { row, _ ->
148-
World(
149-
row.get(0, Int::class.java)!!, row.get(1, Int::class.java)!!
150-
)
151-
})
152-
}
155+
Mono.from(connection.createStatement(WORLD_QUERY)
156+
.bind("$1", random.nextInt(DB_ROWS) + 1)
157+
.execute())
158+
.flatMap { r ->
159+
Mono.from(r.map { row, _ ->
160+
val id = row.get(0, Int::class.java)
161+
val randomNumber = row.get(1, Int::class.java)
162+
if (id != null && randomNumber != null) {
163+
World(id, randomNumber)
164+
} else {
165+
throw IllegalStateException("Database returned null values for required fields")
166+
}
167+
})
168+
}
153169
}, Connection::close)
154170

155171
private fun configurePostgresR2DBC(config: ApplicationConfig): ConnectionFactory {
@@ -170,6 +186,9 @@ private fun configurePostgresR2DBC(config: ApplicationConfig): ConnectionFactory
170186
val cp = ConnectionPoolConfiguration.builder(cf)
171187
.initialSize(config.property("db.initPoolSize").getString().toInt())
172188
.maxSize(config.property("db.maxPoolSize").getString().toInt())
189+
.maxIdleTime(Duration.ofSeconds(30))
190+
.maxAcquireTime(Duration.ofSeconds(5))
191+
.validationQuery("SELECT 1")
173192
.build()
174193

175194
return ConnectionPool(cp)

frameworks/Kotlin/ktor/ktor-r2dbc/src/main/kotlin/org/jetbrains/ktor/benchmarks/models/Fortune.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ package org.jetbrains.ktor.benchmarks.models
33
import kotlinx.serialization.Serializable
44

55
@Serializable
6-
class Fortune(val id: Int, var message: String)
6+
data class Fortune(val id: Int, var message: String)

0 commit comments

Comments
 (0)