Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
01a13871de
Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
78 Zeilen
5.2 KiB
Diff
78 Zeilen
5.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Sun, 8 Aug 2021 16:26:46 -0700
|
|
Subject: [PATCH] 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.
|
|
|
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
|
index 168ab805ecc48dd55db90eb7fe1c56fda3f2776c..336a26733b5bf73455f8ec10347c1e08b8e866f7 100644
|
|
--- a/src/main/java/net/minecraft/Util.java
|
|
+++ b/src/main/java/net/minecraft/Util.java
|
|
@@ -81,6 +81,22 @@ public class Util {
|
|
private static final AtomicInteger WORKER_COUNT = new AtomicInteger(1);
|
|
private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap");
|
|
private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main");
|
|
+ // 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 ExecutorService IO_POOL = makeIoExecutor();
|
|
private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT);
|
|
public static TimeSource.NanoTimeSource timeSource = System::nanoTime;
|
|
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
|
index 376845f5a25a348e76193fac5c047b0ba2fb080f..2a0cf0a8a79c09566c598197fc6f8c447d4bbd72 100644
|
|
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
|
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
|
@@ -181,7 +181,7 @@ public class GameProfileCache {
|
|
} else {
|
|
this.requests.put(username, CompletableFuture.supplyAsync(() -> {
|
|
return this.get(username);
|
|
- }, Util.backgroundExecutor()).whenCompleteAsync((optional, throwable) -> {
|
|
+ }, Util.PROFILE_EXECUTOR).whenCompleteAsync((optional, throwable) -> { // Paper - not a good idea to use BLOCKING OPERATIONS on the worldgen executor
|
|
this.requests.remove(username);
|
|
}, this.executor).whenCompleteAsync((optional, throwable) -> {
|
|
consumer.accept(optional);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
|
index 0c7e29b589ab106013d979a20edc415b4b32a677..c5d5d90d10b30f30d1262367b3d75df43fbdb231 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
|
@@ -120,7 +120,7 @@ public class SkullBlockEntity extends BlockEntity {
|
|
public static void updateGameprofile(@Nullable GameProfile owner, Consumer<GameProfile> callback) {
|
|
if (owner != null && !StringUtil.isNullOrEmpty(owner.getName()) && (!owner.isComplete() || !owner.getProperties().containsKey("textures")) && profileCache != null && sessionService != null) {
|
|
profileCache.getAsync(owner.getName(), (profile) -> {
|
|
- Util.backgroundExecutor().execute(() -> {
|
|
+ Util.PROFILE_EXECUTOR.execute(() -> { // Paper - not a good idea to use BLOCKING OPERATIONS on the worldgen executor
|
|
Util.ifElse(profile, (profilex) -> {
|
|
Property property = Iterables.getFirst(profilex.getProperties().get("textures"), (Property)null);
|
|
if (property == null) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
|
|
index 2d49bd6f3f017d43dfaa23cedf35040b64bcdcf8..9edc5e73819e0b55372f77c5e292eece74d837c7 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
|
|
@@ -121,7 +121,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
|
|
|
|
@Override
|
|
public CompletableFuture<PlayerProfile> update() {
|
|
- return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.backgroundExecutor());
|
|
+ return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.PROFILE_EXECUTOR); // Paper - not a good idea to use BLOCKING OPERATIONS on the worldgen executor
|
|
}
|
|
|
|
private CraftPlayerProfile getUpdatedProfile() {
|