2019-04-06 05:08:45 +02:00
|
|
|
From b85bbfb42e8b12aa8e73894b0ad478c734d12f1d Mon Sep 17 00:00:00 2001
|
2018-10-06 06:56:20 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
2016-03-25 07:38:38 +01:00
|
|
|
Date: Wed, 2 Mar 2016 00:52:31 -0600
|
|
|
|
Subject: [PATCH] Lighting Queue
|
|
|
|
|
2016-07-16 00:36:53 +02:00
|
|
|
This provides option to queue lighting updates to ensure they do not cause the server lag
|
2016-03-25 07:38:38 +01:00
|
|
|
|
2016-05-16 00:48:39 +02:00
|
|
|
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
2019-04-06 05:08:45 +02:00
|
|
|
index 145cb274b0..eff9dcf54f 100644
|
2016-05-16 00:48:39 +02:00
|
|
|
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
|
|
|
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
2018-07-15 03:53:17 +02:00
|
|
|
@@ -50,6 +50,8 @@ public class WorldTimingsHandler {
|
2017-08-12 23:32:01 +02:00
|
|
|
public final Timing worldSaveLevel;
|
2016-10-21 22:42:49 +02:00
|
|
|
public final Timing chunkSaveData;
|
2016-03-25 07:38:38 +01:00
|
|
|
|
2016-05-16 00:48:39 +02:00
|
|
|
+ public final Timing lightingQueueTimer;
|
|
|
|
+
|
|
|
|
public WorldTimingsHandler(World server) {
|
|
|
|
String name = server.worldData.getName() +" - ";
|
|
|
|
|
2018-07-15 03:53:17 +02:00
|
|
|
@@ -96,6 +98,8 @@ public class WorldTimingsHandler {
|
2016-05-16 00:48:39 +02:00
|
|
|
tracker2 = Timings.ofSafe(name + "tracker stage 2");
|
|
|
|
doTick = Timings.ofSafe(name + "doTick");
|
|
|
|
tickEntities = Timings.ofSafe(name + "tickEntities");
|
|
|
|
+
|
|
|
|
+ lightingQueueTimer = Timings.ofSafe(name + "Lighting Queue");
|
|
|
|
}
|
2018-07-15 03:53:17 +02:00
|
|
|
|
|
|
|
public static Timing getTickList(WorldServer worldserver, String timingsType) {
|
2018-09-26 06:57:59 +02:00
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2019-04-06 05:08:45 +02:00
|
|
|
index 7691409f6c..cfcc244672 100644
|
2018-09-26 06:57:59 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2018-10-19 02:44:59 +02:00
|
|
|
@@ -191,6 +191,13 @@ public class PaperConfig {
|
2018-09-26 06:57:59 +02:00
|
|
|
return config.getString(path, config.getString(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public static int maxTickMsLostLightQueue;
|
|
|
|
+ private static void lightQueue() {
|
2018-10-06 06:56:20 +02:00
|
|
|
+ int badSetting = config.getInt("queue-light-updates-max-loss", 10);
|
|
|
|
+ config.set("queue-light-updates-max-loss", null);
|
|
|
|
+ maxTickMsLostLightQueue = getInt("settings.queue-light-updates-max-loss", badSetting);
|
2018-09-26 06:57:59 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
private static void timings() {
|
|
|
|
boolean timings = getBoolean("timings.enabled", true);
|
|
|
|
boolean verboseTimings = getBoolean("timings.verbose", true);
|
2016-03-25 07:38:38 +01:00
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2019-04-06 05:08:45 +02:00
|
|
|
index a797a57671..59d82fa4fb 100644
|
2016-03-25 07:38:38 +01:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2019-04-05 07:27:37 +02:00
|
|
|
@@ -139,4 +139,12 @@ public class PaperWorldConfig {
|
2019-04-05 06:52:02 +02:00
|
|
|
}
|
|
|
|
}
|
2016-03-25 07:38:38 +01:00
|
|
|
}
|
2016-03-31 02:50:23 +02:00
|
|
|
+
|
2018-09-26 06:57:59 +02:00
|
|
|
+ public boolean queueLightUpdates;
|
2016-03-25 07:38:38 +01:00
|
|
|
+ private void queueLightUpdates() {
|
2018-09-26 06:57:59 +02:00
|
|
|
+ queueLightUpdates = getBoolean("queue-light-updates", false);
|
|
|
|
+ log("Lighting Queue enabled: " + queueLightUpdates);
|
|
|
|
+ log("Warning: This feature may help reduce TPS loss from light, but comes at the cost of buggy light data");
|
|
|
|
+ log("We are working to improve this feature.");
|
2016-03-25 07:38:38 +01:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
2019-04-06 05:08:45 +02:00
|
|
|
index e15ed21f67..a9aa13fbf8 100644
|
2016-03-25 07:38:38 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -94,6 +94,7 @@ public class Chunk implements IChunkAccess {
|
2018-07-04 09:55:24 +02:00
|
|
|
return removed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ final PaperLightingQueue.LightingQueue lightingQueue = new PaperLightingQueue.LightingQueue(this);
|
|
|
|
// Paper end
|
2018-07-15 03:53:17 +02:00
|
|
|
public boolean areNeighborsLoaded(final int radius) {
|
|
|
|
switch (radius) {
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -284,7 +285,7 @@ public class Chunk implements IChunkAccess {
|
Improve Light Queue and force enable it for all
There is no reason for the light queue to even be an option. This
enables the light queue for everyone.
This also improves the "can we still tick" time logic to always
check before running a light operation.
previously, we always executed at least 10 on the first world
(but not other worlds...), but we are seeing light take up some
heavy time, so improving that for now.
I've now also improved recheck gaps logic to happen at the end of all single block updates
This also prevents multiple gap checks, as previously if a tick skipped
the gaps check, the next tick would end up re-adding the entry again,
resulting in multiple gap checks.
This now just sets a marker "We need to recheck gaps" and will only occur
once.
This also should reduce chunk loads, as previously, we checked if
the neighbor chunks were loaded for the gap check, however those
neighbor chunks might of unloaded before the light queue operation
actually ran. Now, the neighbor chunk is done when the gap check
is being done, so it should avoid loading chunks.
Fixes #1466
Fixes #1431
2018-09-22 17:46:31 +02:00
|
|
|
|
2018-07-15 03:53:17 +02:00
|
|
|
private void g(boolean flag) {
|
2018-12-17 06:18:06 +01:00
|
|
|
this.world.methodProfiler.enter("recheckGaps");
|
2018-09-26 06:57:59 +02:00
|
|
|
- if (this.world.areChunksLoaded(new BlockPosition(this.locX * 16 + 8, 0, this.locZ * 16 + 8), 16)) {
|
|
|
|
+ if (this.areNeighborsLoaded(1)) { // Paper
|
|
|
|
for (int i = 0; i < 16; ++i) {
|
|
|
|
for (int j = 0; j < 16; ++j) {
|
|
|
|
if (this.g[i + j * 16]) {
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -335,7 +336,7 @@ public class Chunk implements IChunkAccess {
|
2018-09-26 06:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void a(int i, int j, int k, int l) {
|
|
|
|
- if (l > k && this.world.areChunksLoaded(new BlockPosition(i, 0, j), 16)) {
|
|
|
|
+ if (l > k && this.areNeighborsLoaded(1)) { // Paper
|
|
|
|
for (int i1 = k; i1 < l; ++i1) {
|
|
|
|
this.world.c(EnumSkyBlock.SKY, new BlockPosition(i, i1, j));
|
|
|
|
}
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -535,6 +536,7 @@ public class Chunk implements IChunkAccess {
|
2018-07-15 03:53:17 +02:00
|
|
|
if (flag1) {
|
2016-03-25 07:38:38 +01:00
|
|
|
this.initLighting();
|
2017-12-22 22:25:01 +01:00
|
|
|
} else {
|
|
|
|
+ this.runOrQueueLightUpdate(() -> { // Paper - Queue light update
|
2018-07-15 03:53:17 +02:00
|
|
|
int i1 = iblockdata.b(this.world, blockposition);
|
|
|
|
int j1 = iblockdata1.b(this.world, blockposition);
|
2016-03-25 07:38:38 +01:00
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -542,6 +544,7 @@ public class Chunk implements IChunkAccess {
|
2018-07-15 03:53:17 +02:00
|
|
|
if (i1 != j1 && (i1 < j1 || this.getBrightness(EnumSkyBlock.SKY, blockposition) > 0 || this.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 0)) {
|
|
|
|
this.c(i, k);
|
2016-03-25 07:38:38 +01:00
|
|
|
}
|
2016-05-16 00:48:39 +02:00
|
|
|
+ }); // Paper
|
2016-03-25 07:38:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TileEntity tileentity;
|
2019-04-06 05:08:45 +02:00
|
|
|
@@ -1358,6 +1361,16 @@ public class Chunk implements IChunkAccess {
|
2018-08-26 20:11:49 +02:00
|
|
|
return this.D == 8;
|
2017-12-22 22:25:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ public void runOrQueueLightUpdate(Runnable runnable) {
|
|
|
|
+ if (this.world.paperConfig.queueLightUpdates) {
|
|
|
|
+ lightingQueue.add(runnable);
|
|
|
|
+ } else {
|
|
|
|
+ runnable.run();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
public static enum EnumTileEntityState {
|
|
|
|
|
|
|
|
IMMEDIATE, QUEUED, CHECK;
|
2016-03-25 07:38:38 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
2019-04-06 05:08:45 +02:00
|
|
|
index eb83e20d50..c2ecc034e8 100644
|
2016-03-25 07:38:38 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
2019-01-04 20:19:36 +01:00
|
|
|
@@ -313,6 +313,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
2016-06-23 04:18:41 +02:00
|
|
|
return false;
|
|
|
|
}
|
2016-07-13 06:22:58 +02:00
|
|
|
save = event.isSaveChunk();
|
2016-06-23 04:18:41 +02:00
|
|
|
+ chunk.lightingQueue.processUnload(); // Paper
|
2016-03-25 07:38:38 +01:00
|
|
|
|
2016-06-23 04:18:41 +02:00
|
|
|
// Update neighbor counts
|
|
|
|
for (int x = -2; x < 3; x++) {
|
2016-03-25 07:38:38 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2019-04-06 05:08:45 +02:00
|
|
|
index 7ca7b9f3ac..00f1c36e99 100644
|
2016-03-25 07:38:38 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2019-01-06 18:15:21 +01:00
|
|
|
@@ -890,7 +890,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
2018-08-26 20:11:49 +02:00
|
|
|
protected void a(BooleanSupplier booleansupplier) {
|
2016-05-16 00:48:39 +02:00
|
|
|
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
|
2017-01-31 05:33:54 +01:00
|
|
|
this.slackActivityAccountant.tickStarted(); // Spigot
|
2018-12-17 06:18:06 +01:00
|
|
|
- long i = SystemUtils.getMonotonicNanos();
|
|
|
|
+ long i = SystemUtils.getMonotonicNanos(); long startTime = i; // Paper
|
2016-03-25 07:38:38 +01:00
|
|
|
|
2016-05-16 00:48:39 +02:00
|
|
|
++this.ticks;
|
2018-07-15 03:53:17 +02:00
|
|
|
if (this.S) {
|
2019-01-06 18:15:21 +01:00
|
|
|
@@ -948,6 +948,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
2018-12-17 06:18:06 +01:00
|
|
|
this.methodProfiler.exit();
|
|
|
|
this.methodProfiler.exit();
|
2016-05-16 00:48:39 +02:00
|
|
|
org.spigotmc.WatchdogThread.tick(); // Spigot
|
|
|
|
+ PaperLightingQueue.processQueue(startTime); // Paper
|
2018-07-15 03:53:17 +02:00
|
|
|
this.slackActivityAccountant.tickEnded(l); // Spigot
|
2016-05-16 00:48:39 +02:00
|
|
|
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PaperLightingQueue.java b/src/main/java/net/minecraft/server/PaperLightingQueue.java
|
|
|
|
new file mode 100644
|
2019-04-06 05:08:45 +02:00
|
|
|
index 0000000000..9783f3a0d9
|
2016-05-16 00:48:39 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PaperLightingQueue.java
|
2018-10-06 06:56:20 +02:00
|
|
|
@@ -0,0 +1,98 @@
|
2016-05-16 00:48:39 +02:00
|
|
|
+package net.minecraft.server;
|
|
|
|
+
|
|
|
|
+import co.aikar.timings.Timing;
|
2018-09-26 06:57:59 +02:00
|
|
|
+import com.destroystokyo.paper.PaperConfig;
|
2017-01-02 20:08:55 +01:00
|
|
|
+import it.unimi.dsi.fastutil.objects.ObjectCollection;
|
|
|
|
+
|
2016-05-16 00:48:39 +02:00
|
|
|
+import java.util.ArrayDeque;
|
2016-03-25 07:38:38 +01:00
|
|
|
+
|
2016-05-16 00:48:39 +02:00
|
|
|
+class PaperLightingQueue {
|
2018-09-26 06:57:59 +02:00
|
|
|
+ private static final long MAX_TIME = (long) (1000000 * (50 + PaperConfig.maxTickMsLostLightQueue));
|
2016-05-16 00:48:39 +02:00
|
|
|
+
|
|
|
|
+ static void processQueue(long curTime) {
|
|
|
|
+ final long startTime = System.nanoTime();
|
|
|
|
+ final long maxTickTime = MAX_TIME - (startTime - curTime);
|
|
|
|
+
|
2018-09-22 18:28:38 +02:00
|
|
|
+ if (maxTickTime <= 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
2016-05-16 00:48:39 +02:00
|
|
|
+ START:
|
2018-08-26 20:11:49 +02:00
|
|
|
+ for (World world : MinecraftServer.getServer().getWorlds()) {
|
2016-05-16 00:48:39 +02:00
|
|
|
+ if (!world.paperConfig.queueLightUpdates) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
2018-12-17 06:18:06 +01:00
|
|
|
+ ObjectCollection<Chunk> loadedChunks = ((WorldServer) world).getChunkProvider().chunks.values();
|
Improve Light Queue and force enable it for all
There is no reason for the light queue to even be an option. This
enables the light queue for everyone.
This also improves the "can we still tick" time logic to always
check before running a light operation.
previously, we always executed at least 10 on the first world
(but not other worlds...), but we are seeing light take up some
heavy time, so improving that for now.
I've now also improved recheck gaps logic to happen at the end of all single block updates
This also prevents multiple gap checks, as previously if a tick skipped
the gaps check, the next tick would end up re-adding the entry again,
resulting in multiple gap checks.
This now just sets a marker "We need to recheck gaps" and will only occur
once.
This also should reduce chunk loads, as previously, we checked if
the neighbor chunks were loaded for the gap check, however those
neighbor chunks might of unloaded before the light queue operation
actually ran. Now, the neighbor chunk is done when the gap check
is being done, so it should avoid loading chunks.
Fixes #1466
Fixes #1431
2018-09-22 17:46:31 +02:00
|
|
|
+ for (Chunk chunk : loadedChunks.toArray(new Chunk[0])) {
|
2016-05-16 00:48:39 +02:00
|
|
|
+ if (chunk.lightingQueue.processQueue(startTime, maxTickTime)) {
|
|
|
|
+ break START;
|
2016-03-25 07:38:38 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2016-05-16 00:48:39 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
2016-03-25 07:38:38 +01:00
|
|
|
+
|
2016-05-16 00:48:39 +02:00
|
|
|
+ static class LightingQueue extends ArrayDeque<Runnable> {
|
|
|
|
+ final private Chunk chunk;
|
|
|
|
+
|
|
|
|
+ LightingQueue(Chunk chunk) {
|
|
|
|
+ super();
|
|
|
|
+ this.chunk = chunk;
|
2016-03-25 07:38:38 +01:00
|
|
|
+ }
|
|
|
|
+
|
2016-05-16 00:48:39 +02:00
|
|
|
+ /**
|
|
|
|
+ * Processes the lighting queue for this chunk
|
|
|
|
+ *
|
|
|
|
+ * @param startTime If start Time is 0, we will not limit execution time
|
|
|
|
+ * @param maxTickTime Maximum time to spend processing lighting updates
|
|
|
|
+ * @return true to abort processing furthur lighting updates
|
|
|
|
+ */
|
|
|
|
+ private boolean processQueue(long startTime, long maxTickTime) {
|
|
|
|
+ if (this.isEmpty()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
2018-09-22 18:28:38 +02:00
|
|
|
+ if (isOutOfTime(maxTickTime, startTime)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
2016-05-16 00:48:39 +02:00
|
|
|
+ try (Timing ignored = chunk.world.timings.lightingQueueTimer.startTiming()) {
|
|
|
|
+ Runnable lightUpdate;
|
|
|
|
+ while ((lightUpdate = this.poll()) != null) {
|
2018-09-22 18:28:38 +02:00
|
|
|
+ lightUpdate.run();
|
|
|
|
+ if (isOutOfTime(maxTickTime, startTime)) {
|
Improve Light Queue and force enable it for all
There is no reason for the light queue to even be an option. This
enables the light queue for everyone.
This also improves the "can we still tick" time logic to always
check before running a light operation.
previously, we always executed at least 10 on the first world
(but not other worlds...), but we are seeing light take up some
heavy time, so improving that for now.
I've now also improved recheck gaps logic to happen at the end of all single block updates
This also prevents multiple gap checks, as previously if a tick skipped
the gaps check, the next tick would end up re-adding the entry again,
resulting in multiple gap checks.
This now just sets a marker "We need to recheck gaps" and will only occur
once.
This also should reduce chunk loads, as previously, we checked if
the neighbor chunks were loaded for the gap check, however those
neighbor chunks might of unloaded before the light queue operation
actually ran. Now, the neighbor chunk is done when the gap check
is being done, so it should avoid loading chunks.
Fixes #1466
Fixes #1431
2018-09-22 17:46:31 +02:00
|
|
|
+ return true;
|
2016-05-16 00:48:39 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Flushes lighting updates to unload the chunk
|
|
|
|
+ */
|
|
|
|
+ void processUnload() {
|
|
|
|
+ if (!chunk.world.paperConfig.queueLightUpdates) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ processQueue(0, 0); // No timeout
|
|
|
|
+
|
2018-09-22 18:28:38 +02:00
|
|
|
+ final int radius = 1;
|
2016-05-16 00:48:39 +02:00
|
|
|
+ for (int x = chunk.locX - radius; x <= chunk.locX + radius; ++x) {
|
|
|
|
+ for (int z = chunk.locZ - radius; z <= chunk.locZ + radius; ++z) {
|
|
|
|
+ if (x == chunk.locX && z == chunk.locZ) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
2018-10-05 05:18:46 +02:00
|
|
|
+ Chunk neighbor = chunk.world.getChunkIfLoaded(x, z);
|
2016-05-16 00:48:39 +02:00
|
|
|
+ if (neighbor != null) {
|
|
|
|
+ neighbor.lightingQueue.processQueue(0, 0); // No timeout
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
Improve Light Queue and force enable it for all
There is no reason for the light queue to even be an option. This
enables the light queue for everyone.
This also improves the "can we still tick" time logic to always
check before running a light operation.
previously, we always executed at least 10 on the first world
(but not other worlds...), but we are seeing light take up some
heavy time, so improving that for now.
I've now also improved recheck gaps logic to happen at the end of all single block updates
This also prevents multiple gap checks, as previously if a tick skipped
the gaps check, the next tick would end up re-adding the entry again,
resulting in multiple gap checks.
This now just sets a marker "We need to recheck gaps" and will only occur
once.
This also should reduce chunk loads, as previously, we checked if
the neighbor chunks were loaded for the gap check, however those
neighbor chunks might of unloaded before the light queue operation
actually ran. Now, the neighbor chunk is done when the gap check
is being done, so it should avoid loading chunks.
Fixes #1466
Fixes #1431
2018-09-22 17:46:31 +02:00
|
|
|
+
|
2018-09-22 18:28:38 +02:00
|
|
|
+ private static boolean isOutOfTime(long maxTickTime, long startTime) {
|
|
|
|
+ return startTime > 0 && System.nanoTime() - startTime > maxTickTime;
|
Improve Light Queue and force enable it for all
There is no reason for the light queue to even be an option. This
enables the light queue for everyone.
This also improves the "can we still tick" time logic to always
check before running a light operation.
previously, we always executed at least 10 on the first world
(but not other worlds...), but we are seeing light take up some
heavy time, so improving that for now.
I've now also improved recheck gaps logic to happen at the end of all single block updates
This also prevents multiple gap checks, as previously if a tick skipped
the gaps check, the next tick would end up re-adding the entry again,
resulting in multiple gap checks.
This now just sets a marker "We need to recheck gaps" and will only occur
once.
This also should reduce chunk loads, as previously, we checked if
the neighbor chunks were loaded for the gap check, however those
neighbor chunks might of unloaded before the light queue operation
actually ran. Now, the neighbor chunk is done when the gap check
is being done, so it should avoid loading chunks.
Fixes #1466
Fixes #1431
2018-09-22 17:46:31 +02:00
|
|
|
+ }
|
2016-05-16 00:48:39 +02:00
|
|
|
+}
|
2016-03-25 07:38:38 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2019-04-06 05:08:45 +02:00
|
|
|
index b10e4c409d..f3755fcfbe 100644
|
2016-03-25 07:38:38 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2019-02-03 16:34:04 +01:00
|
|
|
@@ -329,7 +329,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-15 03:53:17 +02:00
|
|
|
|
|
|
|
if (iblockdata2.b(this, blockposition) != iblockdata1.b(this, blockposition) || iblockdata2.e() != iblockdata1.e()) {
|
2018-12-17 06:18:06 +01:00
|
|
|
this.methodProfiler.enter("checkLight");
|
2018-07-15 03:53:17 +02:00
|
|
|
- this.r(blockposition);
|
|
|
|
+ chunk.runOrQueueLightUpdate(() -> this.r(blockposition)); // Paper - Queue light update
|
2018-12-17 06:18:06 +01:00
|
|
|
this.methodProfiler.exit();
|
2016-03-25 07:38:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2019-04-05 06:52:02 +02:00
|
|
|
2.21.0
|
2016-03-25 07:38:38 +01:00
|
|
|
|