mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
ea855e2b46
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Developers!: You will need to clean up your work/Minecraft/1.13.2 folder for this Also, restore a patch that was dropped in the last upstream Bukkit Changes: 279eeab3 Fix command description not being set 96e2bb18 Remove debug print from SyntheticEventTest CraftBukkit Changes:d3ed1516
Fix dangerously threaded beacons217a293d
Don't relocate joptsimple to allow --help to work.1be05a21
Prepare for imminent Java 12 releasea49270b2
Mappings Update5259d80c
SPIGOT-4669: Fix PlayerTeleportEvent coordinates for relative teleports Spigot Changes: e6eb36f2 Rebuild patches
111 lines
4.8 KiB
Diff
111 lines
4.8 KiB
Diff
From 6a576fd91e6c21dca0af32180d32e465909b6440 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Mon, 1 Jan 2018 16:10:24 -0500
|
|
Subject: [PATCH] Configurable Max Chunk Gens per Tick
|
|
|
|
Limit the number of generations that can occur in a single tick, forcing them
|
|
to be spread out more.
|
|
|
|
Defaulting to 10 as an average generation is going to be 3-6ms, which means 10 will
|
|
likely cause the server to lose TPS, but constrain how much.
|
|
|
|
This should result in no noticeable speed reduction in generation for servers not
|
|
lagging, and let larger servers reduce this value according to their own desires.
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
index 29cb718fb..695bdf2e6 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -393,4 +393,15 @@ public class PaperWorldConfig {
|
|
}
|
|
log("Max Chunk Sends Per Tick: " + maxChunkSendsPerTick);
|
|
}
|
|
+
|
|
+ public int maxChunkGensPerTick = 10;
|
|
+ private void maxChunkGensPerTick() {
|
|
+ maxChunkGensPerTick = getInt("max-chunk-gens-per-tick", maxChunkGensPerTick);
|
|
+ if (maxChunkGensPerTick <= 0) {
|
|
+ maxChunkGensPerTick = Integer.MAX_VALUE;
|
|
+ log("Max Chunk Gens Per Tick: Unlimited (NOT RECOMMENDED)");
|
|
+ } else {
|
|
+ log("Max Chunk Gens Per Tick: " + maxChunkGensPerTick);
|
|
+ }
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
|
index b9d90c4fb..7d3f846a1 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
|
@@ -21,6 +21,7 @@ public class PlayerChunk {
|
|
private int h;
|
|
private long i;
|
|
private boolean done;
|
|
+ boolean chunkExists; // Paper
|
|
|
|
public PlayerChunk(PlayerChunkMap playerchunkmap, int i, int j) {
|
|
this.playerChunkMap = playerchunkmap;
|
|
@@ -29,6 +30,7 @@ public class PlayerChunk {
|
|
|
|
chunkproviderserver.a(i, j);
|
|
this.chunk = chunkproviderserver.getChunkAt(i, j, true, false);
|
|
+ this.chunkExists = this.chunk != null || org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.hasQueuedChunkLoad(playerChunkMap.getWorld(), i, j); // Paper
|
|
markChunkUsed(); // Paper - delay chunk unloads
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
index f481e5a4f..679488a3c 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
@@ -132,6 +132,7 @@ public class PlayerChunkMap {
|
|
// Spigot start
|
|
org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant;
|
|
activityAccountant.startActivity(0.5);
|
|
+ int chunkGensAllowed = world.paperConfig.maxChunkGensPerTick; // Paper
|
|
// Spigot end
|
|
|
|
Iterator iterator1 = this.h.iterator();
|
|
@@ -141,6 +142,11 @@ public class PlayerChunkMap {
|
|
|
|
if (playerchunk1.f() == null) {
|
|
boolean flag = playerchunk1.a(PlayerChunkMap.b);
|
|
+ // Paper start
|
|
+ if (flag && !playerchunk1.chunkExists && chunkGensAllowed-- <= 0) {
|
|
+ continue;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
if (playerchunk1.a(flag)) {
|
|
iterator1.remove();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
|
|
index 7ffb8f617..33d5fc7d5 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
|
|
@@ -34,4 +34,10 @@ public class ChunkIOExecutor {
|
|
public static void tick() {
|
|
instance.finishActive();
|
|
}
|
|
+
|
|
+ // Paper start
|
|
+ public static boolean hasQueuedChunkLoad(World world, int x, int z) {
|
|
+ return instance.hasTask(new QueuedChunk(x, z, null, world, null));
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java b/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java
|
|
index 193c3621c..cf1258c55 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java
|
|
@@ -351,4 +351,10 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
|
|
public void setActiveThreads(final int coreSize) {
|
|
pool.setCorePoolSize(coreSize);
|
|
}
|
|
+
|
|
+ // Paper start
|
|
+ public boolean hasTask(P parameter) throws IllegalStateException {
|
|
+ return tasks.get(parameter) != null;
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
--
|
|
2.21.0
|
|
|