mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
[ci skip] Update patch comment for Use faster and thread-safe ban list date format parsing
This commit is contained in:
@@ -3,16 +3,25 @@ From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|||||||
Date: Mon, 11 Nov 2024 02:46:39 -0500
|
Date: Mon, 11 Nov 2024 02:46:39 -0500
|
||||||
Subject: [PATCH] Use faster and thread-safe ban list date format parsing
|
Subject: [PATCH] Use faster and thread-safe ban list date format parsing
|
||||||
|
|
||||||
Use DateTimeFormatter since the original java SimpleDateFormat is not thread-safe
|
Dreeam TODO: check is there need to use more accurate benchmark using jmh?
|
||||||
If store StoredUserList asynchronously, one data format may pollute another
|
|
||||||
|
|
||||||
Some performance test only for reference
|
Use DateTimeFormatter since the original java SimpleDateFormat is not thread-safe
|
||||||
|
If calls DateTimeFormatter asynchronously, one data format may pollute another
|
||||||
|
|
||||||
|
This can fix the server crash on loading according to the user report.
|
||||||
|
The server crashed during initing the IP ban list, probably caused by calls in off-main.
|
||||||
|
|
||||||
|
Some performance test **only for reference**
|
||||||
Single thread, 10,000,000 times loop, java 21 (graalvm / zulu)
|
Single thread, 10,000,000 times loop, java 21 (graalvm / zulu)
|
||||||
|
|
||||||
SimpleDateFormat: ~29,446ms
|
SimpleDateFormat: ~29,446ms
|
||||||
DateTimeFormatter: ~13,128ms
|
DateTimeFormatter: ~13,128ms
|
||||||
apache commons-lang's FastDateFormat: ~23,514ms
|
apache commons-lang's FastDateFormat: ~23,514ms
|
||||||
|
|
||||||
|
In the end, DateTimeFormatter is also fastest in three implementations in any ways,
|
||||||
|
Wether there is a high frequnently calls or not. And also thread-safe. So there is
|
||||||
|
a better solution, why not using it?
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/players/BanListEntry.java b/src/main/java/net/minecraft/server/players/BanListEntry.java
|
diff --git a/src/main/java/net/minecraft/server/players/BanListEntry.java b/src/main/java/net/minecraft/server/players/BanListEntry.java
|
||||||
index 8b1da1fb5ca27432a39aff6dbc452b793268dab5..46188a8b8598c36ccb0f5e037a80eb1741c68491 100644
|
index 8b1da1fb5ca27432a39aff6dbc452b793268dab5..46188a8b8598c36ccb0f5e037a80eb1741c68491 100644
|
||||||
--- a/src/main/java/net/minecraft/server/players/BanListEntry.java
|
--- a/src/main/java/net/minecraft/server/players/BanListEntry.java
|
||||||
|
|||||||
Reference in New Issue
Block a user