Light improvements
Trying to solve random hangs we've seen, ensuring that this part of code isnt the culprit also fixing a vanilla bug reportedby PhiPro where tickets are released too early hoping this reduces amount of incorrect light issues.
Dieser Commit ist enthalten in:
Ursprung
e3e1191ac9
Commit
826e09f369
@ -1027,7 +1027,7 @@ index a35e7b392c74fadf2760d1fc2021e98d33858cb5..944094e8e770cc8c0205ef2aa6c48fff
|
|||||||
lightenginelayer.a(Long.MAX_VALUE, l3, 15, false);
|
lightenginelayer.a(Long.MAX_VALUE, l3, 15, false);
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||||
index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb726b95b6 100644
|
index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..fd0beefb900c064d3c35a3d2f79f5b7d9c1287bb 100644
|
||||||
--- a/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
--- a/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||||
+++ b/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
+++ b/src/main/java/net/minecraft/server/LightEngineThreaded.java
|
||||||
@@ -1,6 +1,7 @@
|
@@ -1,6 +1,7 @@
|
||||||
@ -1038,7 +1038,7 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectList;
|
import it.unimi.dsi.fastutil.objects.ObjectList;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||||
@@ -15,15 +16,158 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
@@ -15,15 +16,149 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
private final ThreadedMailbox<Runnable> b;
|
private final ThreadedMailbox<Runnable> b;
|
||||||
@ -1048,7 +1048,7 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
+ private static final int MAX_PRIORITIES = PlayerChunkMap.GOLDEN_TICKET + 2;
|
+ private static final int MAX_PRIORITIES = PlayerChunkMap.GOLDEN_TICKET + 2;
|
||||||
+
|
+
|
||||||
+ private boolean isChunkLightStatus(long pair) {
|
+ private boolean isChunkLightStatus(long pair) {
|
||||||
+ PlayerChunk playerChunk = playerChunkMap.getUpdatingChunk(pair);
|
+ PlayerChunk playerChunk = playerChunkMap.getVisibleChunk(pair);
|
||||||
+ if (playerChunk == null) {
|
+ if (playerChunk == null) {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
@ -1084,7 +1084,6 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
+ // Retain the chunks priority level for queued light tasks
|
+ // Retain the chunks priority level for queued light tasks
|
||||||
+ class LightQueue {
|
+ class LightQueue {
|
||||||
+ private int size = 0;
|
+ private int size = 0;
|
||||||
+ private int lowestPriority = MAX_PRIORITIES;
|
|
||||||
+ private final Long2ObjectLinkedOpenHashMap<ChunkLightQueue>[] buckets = new Long2ObjectLinkedOpenHashMap[MAX_PRIORITIES];
|
+ private final Long2ObjectLinkedOpenHashMap<ChunkLightQueue>[] buckets = new Long2ObjectLinkedOpenHashMap[MAX_PRIORITIES];
|
||||||
+ private final java.util.concurrent.ConcurrentLinkedQueue<PendingLightTask> pendingTasks = new java.util.concurrent.ConcurrentLinkedQueue<>();
|
+ private final java.util.concurrent.ConcurrentLinkedQueue<PendingLightTask> pendingTasks = new java.util.concurrent.ConcurrentLinkedQueue<>();
|
||||||
+ private final java.util.concurrent.ConcurrentLinkedQueue<Runnable> priorityChanges = new java.util.concurrent.ConcurrentLinkedQueue<>();
|
+ private final java.util.concurrent.ConcurrentLinkedQueue<Runnable> priorityChanges = new java.util.concurrent.ConcurrentLinkedQueue<>();
|
||||||
@ -1105,11 +1104,6 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
+ remove.post.addAll(existing.post);
|
+ remove.post.addAll(existing.post);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ if (!this.buckets[priority].isEmpty()) {
|
|
||||||
+ if (lowestPriority > priority) {
|
|
||||||
+ lowestPriority = priority;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ });
|
+ });
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -1136,10 +1130,6 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
+ if (update.fastUpdate) {
|
+ if (update.fastUpdate) {
|
||||||
+ lightQueue.shouldFastUpdate = true;
|
+ lightQueue.shouldFastUpdate = true;
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ if (this.lowestPriority > priority) {
|
|
||||||
+ this.lowestPriority = priority;
|
|
||||||
+ }
|
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public final boolean isEmpty() {
|
+ public final boolean isEmpty() {
|
||||||
@ -1161,11 +1151,12 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
+ }
|
+ }
|
||||||
+ boolean hasWork = false;
|
+ boolean hasWork = false;
|
||||||
+ Long2ObjectLinkedOpenHashMap<ChunkLightQueue>[] buckets = this.buckets;
|
+ Long2ObjectLinkedOpenHashMap<ChunkLightQueue>[] buckets = this.buckets;
|
||||||
|
+ int lowestPriority = 0;
|
||||||
+ while (lowestPriority < MAX_PRIORITIES && !isEmpty()) {
|
+ while (lowestPriority < MAX_PRIORITIES && !isEmpty()) {
|
||||||
+ Long2ObjectLinkedOpenHashMap<ChunkLightQueue> bucket = buckets[lowestPriority];
|
+ Long2ObjectLinkedOpenHashMap<ChunkLightQueue> bucket = buckets[lowestPriority];
|
||||||
+ if (bucket.isEmpty()) {
|
+ if (bucket.isEmpty()) {
|
||||||
+ lowestPriority++;
|
+ lowestPriority++;
|
||||||
+ if (hasWork && lowestPriority <= 3) {
|
+ if (hasWork && lowestPriority <= 5) {
|
||||||
+ return true;
|
+ return true;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ continue;
|
+ continue;
|
||||||
@ -1200,7 +1191,7 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
this.e = mailbox;
|
this.e = mailbox;
|
||||||
this.b = threadedmailbox;
|
this.b = threadedmailbox;
|
||||||
}
|
}
|
||||||
@@ -110,13 +254,9 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
@@ -110,13 +245,9 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void a(int i, int j, IntSupplier intsupplier, LightEngineThreaded.Update lightenginethreaded_update, Runnable runnable) {
|
private void a(int i, int j, IntSupplier intsupplier, LightEngineThreaded.Update lightenginethreaded_update, Runnable runnable) {
|
||||||
@ -1217,7 +1208,7 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -133,8 +273,20 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
@@ -133,8 +264,19 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
||||||
public CompletableFuture<IChunkAccess> a(IChunkAccess ichunkaccess, boolean flag) {
|
public CompletableFuture<IChunkAccess> a(IChunkAccess ichunkaccess, boolean flag) {
|
||||||
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||||
|
|
||||||
@ -1231,7 +1222,6 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
+ boolean[] skippedPre = {false};
|
+ boolean[] skippedPre = {false};
|
||||||
+ this.queue.addChunk(pair, prioritySupplier, SystemUtils.a(() -> {
|
+ this.queue.addChunk(pair, prioritySupplier, SystemUtils.a(() -> {
|
||||||
+ if (!isChunkLightStatus(pair)) {
|
+ if (!isChunkLightStatus(pair)) {
|
||||||
+ this.d.c(chunkcoordintpair); // copied from end of method to release light ticket
|
|
||||||
+ future.complete(ichunkaccess);
|
+ future.complete(ichunkaccess);
|
||||||
+ skippedPre[0] = true;
|
+ skippedPre[0] = true;
|
||||||
+ return;
|
+ return;
|
||||||
@ -1240,18 +1230,19 @@ index f8c2b957bb5b38f05251cccf5137a9c23262c3d6..ec8498c3db7a8d417f27eed5d3af38cb
|
|||||||
ChunkSection[] achunksection = ichunkaccess.getSections();
|
ChunkSection[] achunksection = ichunkaccess.getSections();
|
||||||
|
|
||||||
for (int i = 0; i < 16; ++i) {
|
for (int i = 0; i < 16; ++i) {
|
||||||
@@ -152,55 +304,47 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
@@ -152,55 +294,48 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- this.d.c(chunkcoordintpair);
|
- this.d.c(chunkcoordintpair);
|
||||||
+ this.d.c(chunkcoordintpair); // Paper - if change, copy into !isChunkLightStatus above
|
+ // this.d.c(chunkcoordintpair); // Paper - move into post task below
|
||||||
}, () -> {
|
}, () -> {
|
||||||
return "lightChunk " + chunkcoordintpair + " " + flag;
|
return "lightChunk " + chunkcoordintpair + " " + flag;
|
||||||
- }));
|
- }));
|
||||||
- return CompletableFuture.supplyAsync(() -> {
|
- return CompletableFuture.supplyAsync(() -> {
|
||||||
+ // Paper start - merge the 2 together
|
+ // Paper start - merge the 2 together
|
||||||
+ }), () -> {
|
+ }), () -> {
|
||||||
|
+ this.d.c(chunkcoordintpair); // Paper - release light tickets as post task to ensure they stay loaded until fully done
|
||||||
+ if (skippedPre[0]) return; // Paper - future's already complete
|
+ if (skippedPre[0]) return; // Paper - future's already complete
|
||||||
ichunkaccess.b(true);
|
ichunkaccess.b(true);
|
||||||
super.b(chunkcoordintpair, false);
|
super.b(chunkcoordintpair, false);
|
||||||
@ -1338,7 +1329,7 @@ index ff00830b95a17f66d0c913087492dbf4b066df8a..4085426af03f032cf405bdfd1e40a8e5
|
|||||||
private static final int nibbleBucketSizeMultiplier = Integer.getInteger("Paper.nibbleBucketSize", 3072);
|
private static final int nibbleBucketSizeMultiplier = Integer.getInteger("Paper.nibbleBucketSize", 3072);
|
||||||
private static final int maxPoolSize = Integer.getInteger("Paper.maxNibblePoolSize", (int) Math.min(6, Math.max(1, Runtime.getRuntime().maxMemory() / 1024 / 1024 / 1024)) * (nibbleBucketSizeMultiplier * 8));
|
private static final int maxPoolSize = Integer.getInteger("Paper.maxNibblePoolSize", (int) Math.min(6, Math.max(1, Runtime.getRuntime().maxMemory() / 1024 / 1024 / 1024)) * (nibbleBucketSizeMultiplier * 8));
|
||||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||||
index 27c4dc6caf7b6303766dd8eee4812209600cd728..676f0d28b0c8a590c6429a93902953636b3c1f11 100644
|
index 1f14ebf09de9f2671b30498ea8fd66750ae85dff..de1e409dc5161371c6f14d036603be448fcd3e26 100644
|
||||||
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||||
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||||
@@ -724,6 +724,7 @@ public class PlayerChunk {
|
@@ -724,6 +724,7 @@ public class PlayerChunk {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren