geforkt von Mirrors/Paper
1358d1e914
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 881e06e5 PR-725: Add Item Unlimited Lifetime APIs CraftBukkit Changes: 74c08312 SPIGOT-6962: Call EntityChangeBlockEvent when when FallingBlockEntity starts to fall 64db5126 SPIGOT-6959: Make /loot command ignore empty items for spawn 2d760831 Increase outdated build delay 9ed7e4fb SPIGOT-6138, SPIGOT-6415: Don't call CreatureSpawnEvent after cross-dimensional travel fc4ad813 SPIGOT-6895: Trees grown with applyBoneMeal() don't fire the StructureGrowthEvent 59733a2e SPIGOT-6961: Actually return a copy of the ItemMeta Spigot Changes: ffceeae3 SPIGOT-6956: Drop unload queue patch as attempt at fixing stop issue e19ddabd PR-1011: Add Item Unlimited Lifetime APIs 34d40b0e SPIGOT-2942: give command fires PlayerDropItemEvent, cancelling it causes Item Duplication
82 Zeilen
4.4 KiB
Diff
82 Zeilen
4.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Fri, 29 May 2020 23:32:14 -0400
|
|
Subject: [PATCH] Improve Chunk Status Transition Speed
|
|
|
|
When a chunk is loaded from disk that has already been generated,
|
|
the server has to promote the chunk through the system to reach
|
|
it's current desired status level.
|
|
|
|
This results in every single status transition going from the main thread
|
|
to the world gen threads, only to discover it has no work it actually
|
|
needs to do.... and then it returns back to main.
|
|
|
|
This back and forth costs a lot of time and can really delay chunk loads
|
|
when the server is under high TPS due to their being a lot of time in
|
|
between chunk load times, as well as hogs up the chunk threads from doing
|
|
actual generation and light work.
|
|
|
|
Additionally, the whole task system uses a lot of CPU on the server threads anyways.
|
|
|
|
So by optimizing status transitions for status's that are already complete,
|
|
we can run them to the desired level while on main thread (where it has
|
|
to happen anyways) instead of ever jumping to world gen thread.
|
|
|
|
This will improve chunk loading effeciency to be reduced down to the following
|
|
scenario / path:
|
|
|
|
1) MAIN: Chunk Requested, Load Request sent to ChunkTaskManager / IO Queue
|
|
2) IO: Once position in queue comes, submit read IO data and schedule to chunk task thread
|
|
3) CHUNK: Once IO is loaded and position in queue comes, deserialize the chunk data, process conversions, submit to main queue
|
|
4) MAIN: next Chunk Task process (Mid Tick or End Of Tick), load chunk data into world (POI, main thread tasks)
|
|
5) MAIN: process status transitions all the way to LIGHT, light schedules Threaded task
|
|
6) SERVER: Light tasks register light enablement for chunk and any lighting needing to be done
|
|
7) MAIN: Task returns to main, finish processing to FULL/TICKING status
|
|
|
|
Previously would have hopped to SERVER around 12+ times there extra.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
|
index 6ba7e2713452c4c6f48a1a825ef27b500140aa16..cd4328bd606d778ebb45f36af8cf23d88edef881 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
|
@@ -95,6 +95,13 @@ public class ChunkHolder {
|
|
// Paper end - optimise anyPlayerCloseEnoughForSpawning
|
|
long lastAutoSaveTime; // Paper - incremental autosave
|
|
long inactiveTimeStart; // Paper - incremental autosave
|
|
+ // Paper start - optimize chunk status progression without jumping through thread pool
|
|
+ public boolean canAdvanceStatus() {
|
|
+ ChunkStatus status = getChunkHolderStatus();
|
|
+ ChunkAccess chunk = getAvailableChunkNow();
|
|
+ return chunk != null && (status == null || chunk.getStatus().isOrAfter(getNextStatus(status)));
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
|
|
this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size());
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
index c6ea30c9e91382297a5340096540f1ebc914fc35..104e7d0c18b032ee8198c4de25a57676d0f64745 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -691,7 +691,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
return either.mapLeft((list) -> {
|
|
return (LevelChunk) list.get(list.size() / 2);
|
|
});
|
|
- }, this.mainThreadExecutor);
|
|
+ }, this.mainInvokingExecutor); // Paper
|
|
}
|
|
|
|
@Nullable
|
|
@@ -1087,6 +1087,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
return "chunkGenerate " + requiredStatus.getName();
|
|
});
|
|
Executor executor = (runnable) -> {
|
|
+ // Paper start - optimize chunk status progression without jumping through thread pool
|
|
+ if (holder.canAdvanceStatus()) {
|
|
+ this.mainInvokingExecutor.execute(runnable);
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
this.worldgenMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable));
|
|
};
|
|
|