mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
835bc39b03
Updated Upstream (Bukkit/CraftBukkit/Spigot) Bukkit Changes: 2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields e0fc6572 SPIGOT-4309: Add "forced" display of particles efeeab2f Add index to README.md for easier navigation f502bc6f Update to Minecraft 1.13.1 CraftBukkit Changes:d0bb0a1d
Fix some tests randomly failing997d378d
Fix client stall in specific teleportation scenariosb3dc2366
SPIGOT-4307: Fix hacky API for banners on shields2a271162
SPIGOT-4301: Fix more invalid enchants5d0d83bb
SPIGOT-4309: Add "forced" display of particlesa6772578
Add additional tests for CraftBlockDatace1af0c3
Update to Minecraft 1.13.1 Spigot Changes: 2440e189 Rebuild patches 4ecffced Update to Minecraft 1.13.1
112 lines
5.0 KiB
Diff
112 lines
5.0 KiB
Diff
From d687cd8f13cfca085b63b6e13c73ecf1f97d2998 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 9188e49b71..a225b55853 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -380,4 +380,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 3f4a8f21c0..f8d8a44a88 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
|
@@ -28,6 +28,7 @@ public class PlayerChunk {
|
|
// CraftBukkit start - add fields
|
|
// You know the drill, https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse
|
|
// All may seem good at first, but there's deeper issues if you play for a bit
|
|
+ boolean chunkExists; // Paper
|
|
private boolean loadInProgress = false;
|
|
private Runnable loadedRunnable = new Runnable() {
|
|
public void run() {
|
|
@@ -52,6 +53,7 @@ public class PlayerChunk {
|
|
|
|
chunkproviderserver.a(i, j);
|
|
this.chunk = chunkproviderserver.getChunkAt(i, j, true, false);
|
|
+ this.chunkExists = this.chunk != null || 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 9fd07f8596..e29aaab2da 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
@@ -140,6 +140,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();
|
|
@@ -149,6 +150,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 9aaca21a79..f50d55c8ee 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
|
|
@@ -35,4 +35,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 193c3621c6..cf1258c559 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.18.0
|
|
|