Skip to content

Commit 41647af

Browse files
committed
Do not use worldgen executor for api profile completions
We cannot put blocking network I/O onto the worldgen threads, this will crash the server if it stalls
1 parent ed79fc9 commit 41647af

File tree

590 files changed

+175
-162
lines changed

Some content is hidden

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

590 files changed

+175
-162
lines changed

patches/server/0727-Do-not-submit-profile-lookups-to-worldgen-threads.patch renamed to patches/server/0138-Do-not-submit-profile-lookups-to-worldgen-threads.patch

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ out due to a sync load, as the worldgen threads will be
1010
stalling on profile lookups.
1111

1212
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
13-
index 5f9e3d37c3ba79d26806374d73f87328cebb562d..206c6ce227ba19620185ac835af28d67caa76c40 100644
13+
index d7e22ddf89619b58516ccef1d75a4c33df61b73c..33ec7786cdf8c32e905d192fc8364418e47404d5 100644
1414
--- a/src/main/java/net/minecraft/Util.java
1515
+++ b/src/main/java/net/minecraft/Util.java
1616
@@ -80,6 +80,22 @@ public class Util {
1717
private static final AtomicInteger WORKER_COUNT = new AtomicInteger(1);
18-
private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap", -2); // Paper - add -2 priority
19-
private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - add -1 priority
18+
private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap");
19+
private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main");
2020
+ // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
2121
+ public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() {
2222
+
@@ -37,10 +37,10 @@ index 5f9e3d37c3ba79d26806374d73f87328cebb562d..206c6ce227ba19620185ac835af28d67
3737
public static LongSupplier timeSource = System::nanoTime;
3838
public static final Ticker TICKER = new Ticker() {
3939
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
40-
index 8d86645ef264287d01203afd7bba516e78be5743..4dff88bdf14675718572e4b3720c0250ce6e730e 100644
40+
index c7edbd12361cfd3dcf1359917d579fae4c3cc8a7..6c8a1d9c7696fa55dae6ba5e4ea50a0ffc7ea543 100644
4141
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
4242
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
43-
@@ -207,7 +207,7 @@ public class GameProfileCache {
43+
@@ -181,7 +181,7 @@ public class GameProfileCache {
4444
} else {
4545
this.requests.put(username, CompletableFuture.supplyAsync(() -> {
4646
return this.get(username);
@@ -62,3 +62,16 @@ index 0c7e29b589ab106013d979a20edc415b4b32a677..c5d5d90d10b30f30d1262367b3d75df4
6262
Util.ifElse(profile, (profilex) -> {
6363
Property property = Iterables.getFirst(profilex.getProperties().get("textures"), (Property)null);
6464
if (property == null) {
65+
diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
66+
index 2d49bd6f3f017d43dfaa23cedf35040b64bcdcf8..9edc5e73819e0b55372f77c5e292eece74d837c7 100644
67+
--- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
68+
+++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
69+
@@ -121,7 +121,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
70+
71+
@Override
72+
public CompletableFuture<PlayerProfile> update() {
73+
- return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.backgroundExecutor());
74+
+ return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.PROFILE_EXECUTOR); // Paper - not a good idea to use BLOCKING OPERATIONS on the worldgen executor
75+
}
76+
77+
private CraftPlayerProfile getUpdatedProfile() {

patches/server/0138-Add-UnknownCommandEvent.patch renamed to patches/server/0139-Add-UnknownCommandEvent.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Add UnknownCommandEvent
55

66

77
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
8-
index 49d0e5e5cf1c529cbd0f4c58c88acf802f42a5bd..cf913f0678178d03c63eaa2b7a67e18abe17a7c5 100644
8+
index 20d1fafc33f207f5e922df9fa5e152e003717a1c..c55a18eadc2bef0c98abd46898e10a5110212c68 100644
99
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
1010
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
1111
@@ -888,7 +888,13 @@ public final class CraftServer implements Server {

patches/server/0139-Basic-PlayerProfile-API.patch renamed to patches/server/0140-Basic-PlayerProfile-API.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Establishes base extension of profile systems for future edits too
77

88
diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
99
new file mode 100644
10-
index 0000000000000000000000000000000000000000..d945ea3484d0350096046d43112490b94e3b9bcd
10+
index 0000000000000000000000000000000000000000..7a5b24419507d00817aa3e8950d89f5174823387
1111
--- /dev/null
1212
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
1313
@@ -0,0 +1,399 @@
@@ -185,7 +185,7 @@ index 0000000000000000000000000000000000000000..d945ea3484d0350096046d43112490b9
185185
+ final CraftPlayerProfile clone = clone();
186186
+ clone.complete(true);
187187
+ return clone;
188-
+ }, Util.backgroundExecutor());
188+
+ }, Util.PROFILE_EXECUTOR);
189189
+ }
190190
+
191191
+ @Override
@@ -599,7 +599,7 @@ index a48a12a31a3d09a9373b688dcc093035f8f8a300..97b29bcb20e199c2d02457f8025e67e2
599599
String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
600600
LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath());
601601
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
602-
index c7edbd12361cfd3dcf1359917d579fae4c3cc8a7..2a4f8aa6697ed6144440970c9abaf9f6e1a2c2ce 100644
602+
index 6c8a1d9c7696fa55dae6ba5e4ea50a0ffc7ea543..2347c7b44793aabe431b57bb1b44935fefbda6fe 100644
603603
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
604604
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
605605
@@ -136,6 +136,17 @@ public class GameProfileCache {
@@ -621,7 +621,7 @@ index c7edbd12361cfd3dcf1359917d579fae4c3cc8a7..2a4f8aa6697ed6144440970c9abaf9f6
621621
String s1 = name.toLowerCase(Locale.ROOT);
622622
GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1);
623623
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
624-
index cf913f0678178d03c63eaa2b7a67e18abe17a7c5..c334fa4dcd0ecab1a1cdfe7ebb0b6615e710f164 100644
624+
index c55a18eadc2bef0c98abd46898e10a5110212c68..e66595c24210ed3f2daab2add7e8acc8cf881fdc 100644
625625
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
626626
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
627627
@@ -241,6 +241,9 @@ import org.yaml.snakeyaml.error.MarkedYAMLException;
@@ -681,7 +681,7 @@ index cf913f0678178d03c63eaa2b7a67e18abe17a7c5..c334fa4dcd0ecab1a1cdfe7ebb0b6615
681681
// Paper end
682682
}
683683
diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
684-
index 2d49bd6f3f017d43dfaa23cedf35040b64bcdcf8..661d8e9882509700faa9bc10a2e3074c5553af44 100644
684+
index 9edc5e73819e0b55372f77c5e292eece74d837c7..9001c9dc68dc05944eb839c3354bea29249daa92 100644
685685
--- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
686686
+++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
687687
@@ -27,7 +27,7 @@ import org.bukkit.profile.PlayerProfile;

patches/server/0140-Shoulder-Entities-Release-API.patch renamed to patches/server/0141-Shoulder-Entities-Release-API.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ index 9aa134e56d661d033bb7229e6ab662534bf9cba9..794081610e52b7b8e04403510d1ad05f
5858
@Override
5959
public abstract boolean isSpectator();
6060
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
61-
index 2099056896954c700840f3c598f147e4983b86a1..ea024ec921a382e40c982cc529f13d08101ca131 100644
61+
index 2c934b7a2142a4d1ae21feeb95d23f22cfda3be0..3954ed194388c6487c6cd0303aea9e1b65a0f8ee 100644
6262
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
6363
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
6464
@@ -504,6 +504,32 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)