Do not submit profile lookups to worldgen threads
They block. On network I/O. If enough tasks are submitted the server will eventually stall out due to a sync load, as the worldgen threads will be stalling on profile lookups.
This commit is contained in:
@@ -1,6 +1,29 @@
|
|||||||
--- a/net/minecraft/Util.java
|
--- a/net/minecraft/Util.java
|
||||||
+++ b/net/minecraft/Util.java
|
+++ b/net/minecraft/Util.java
|
||||||
@@ -136,7 +136,7 @@
|
@@ -95,6 +95,22 @@
|
||||||
|
private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main");
|
||||||
|
private static final TracingExecutor IO_POOL = makeIoExecutor("IO-Worker-", false);
|
||||||
|
private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true);
|
||||||
|
+ // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
|
||||||
|
+ public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() {
|
||||||
|
+
|
||||||
|
+ private final AtomicInteger count = new AtomicInteger();
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public Thread newThread(Runnable run) {
|
||||||
|
+ Thread ret = new Thread(run);
|
||||||
|
+ ret.setName("Profile Lookup Executor #" + this.count.getAndIncrement());
|
||||||
|
+ ret.setUncaughtExceptionHandler((Thread thread, Throwable throwable) -> {
|
||||||
|
+ LOGGER.error("Uncaught exception in thread " + thread.getName(), throwable);
|
||||||
|
+ });
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ // Paper end - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
|
||||||
|
private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT);
|
||||||
|
public static final int LINEAR_LOOKUP_THRESHOLD = 8;
|
||||||
|
private static final Set<String> ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https");
|
||||||
|
@@ -136,7 +152,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getNanos() {
|
public static long getNanos() {
|
||||||
@@ -9,7 +32,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long getEpochMillis() {
|
public static long getEpochMillis() {
|
||||||
@@ -537,7 +537,7 @@
|
@@ -537,7 +553,7 @@
|
||||||
public static <K extends Enum<K>, V> EnumMap<K, V> makeEnumMap(Class<K> enumClass, Function<K, V> mapper) {
|
public static <K extends Enum<K>, V> EnumMap<K, V> makeEnumMap(Class<K> enumClass, Function<K, V> mapper) {
|
||||||
EnumMap<K, V> enumMap = new EnumMap<>(enumClass);
|
EnumMap<K, V> enumMap = new EnumMap<>(enumClass);
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return optional;
|
return optional;
|
||||||
|
@@ -167,7 +169,7 @@
|
||||||
|
} else {
|
||||||
|
CompletableFuture<Optional<GameProfile>> completablefuture1 = CompletableFuture.supplyAsync(() -> {
|
||||||
|
return this.get(username);
|
||||||
|
- }, Util.backgroundExecutor().forName("getProfile")).whenCompleteAsync((optional, throwable) -> {
|
||||||
|
+ }, Util.PROFILE_EXECUTOR).whenCompleteAsync((optional, throwable) -> { // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
|
||||||
|
this.requests.remove(username);
|
||||||
|
}, this.executor);
|
||||||
|
|
||||||
@@ -208,7 +210,7 @@
|
@@ -208,7 +210,7 @@
|
||||||
|
|
||||||
label54:
|
label54:
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
--- a/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||||
|
+++ b/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||||
|
@@ -105,7 +105,7 @@
|
||||||
|
ProfileResult profileResult = apiServices.sessionService().fetchProfile(uuid, true);
|
||||||
|
return Optional.ofNullable(profileResult).map(ProfileResult::profile);
|
||||||
|
}
|
||||||
|
- }, Util.backgroundExecutor().forName("fetchProfile"));
|
||||||
|
+ }, Util.PROFILE_EXECUTOR); // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
@@ -161,7 +161,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<PlayerProfile> update() {
|
public CompletableFuture<PlayerProfile> update() {
|
||||||
return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.backgroundExecutor());
|
return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.PROFILE_EXECUTOR); // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
|
||||||
}
|
}
|
||||||
|
|
||||||
private CraftPlayerProfile getUpdatedProfile() {
|
private CraftPlayerProfile getUpdatedProfile() {
|
||||||
|
|||||||
Reference in New Issue
Block a user