9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-25 18:09:17 +00:00

General patch cleanup & New reject policy

This commit is contained in:
HaHaWTH
2025-04-27 00:22:03 +14:00
parent 5abe1dfb9a
commit 1974f34879
10 changed files with 61 additions and 92 deletions

View File

@@ -6,39 +6,30 @@ Subject: [PATCH] Replace ConcurrentLong2ReferenceChainedHashTable with custom
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/queue/ChunkUnloadQueue.java b/ca/spottedleaf/moonrise/patches/chunk_system/queue/ChunkUnloadQueue.java
index 7eafc5b7cba23d8dec92ecc1050afe3fd8c9e309..c2d5e83f0bdf98d3c07d6da2bba3b1ebaf7307d5 100644
index 7eafc5b7cba23d8dec92ecc1050afe3fd8c9e309..7a299490d502147ddfd533637da36ea0d2ac918a 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/queue/ChunkUnloadQueue.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/queue/ChunkUnloadQueue.java
@@ -7,6 +7,8 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import it.unimi.dsi.fastutil.longs.LongIterator;
import it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet;
+import org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -16,7 +18,7 @@ public final class ChunkUnloadQueue {
@@ -16,7 +16,7 @@ public final class ChunkUnloadQueue {
public final int coordinateShift;
private final AtomicLong orderGenerator = new AtomicLong();
- private final ConcurrentLong2ReferenceChainedHashTable<UnloadSection> unloadSections = new ConcurrentLong2ReferenceChainedHashTable<>();
+ private final LeafConcurrentLong2ReferenceChainedHashTable<UnloadSection> unloadSections = new LeafConcurrentLong2ReferenceChainedHashTable<>();
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<UnloadSection> unloadSections = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
/*
* Note: write operations do not occur in parallel for any given section.
@@ -32,8 +34,8 @@ public final class ChunkUnloadQueue {
@@ -32,8 +32,8 @@ public final class ChunkUnloadQueue {
public List<SectionToUnload> retrieveForAllRegions() {
final List<SectionToUnload> ret = new ArrayList<>();
- for (final Iterator<ConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection>> iterator = this.unloadSections.entryIterator(); iterator.hasNext();) {
- final ConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection> entry = iterator.next();
+ for (final Iterator<LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection>> iterator = this.unloadSections.entryIterator(); iterator.hasNext();) {
+ final LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection> entry = iterator.next();
+ for (final Iterator<org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection>> iterator = this.unloadSections.entryIterator(); iterator.hasNext(); ) {
+ final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<UnloadSection> entry = iterator.next();
final long key = entry.getKey();
final UnloadSection section = entry.getValue();
final int sectionX = CoordinateUtils.getChunkX(key);
@@ -141,4 +143,4 @@ public final class ChunkUnloadQueue {
@@ -141,4 +141,4 @@ public final class ChunkUnloadQueue {
this.order = order;
}
}
@@ -46,90 +37,64 @@ index 7eafc5b7cba23d8dec92ecc1050afe3fd8c9e309..c2d5e83f0bdf98d3c07d6da2bba3b1eb
\ No newline at end of file
+}
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
index 06ac3537f5655d048d770bb004243f207fad9faa..a1f328a5c4ccc030c99762a68008ab1ecebdc06e 100644
index 06ac3537f5655d048d770bb004243f207fad9faa..647354efeb18694ac56a542bf4a88be61136f6a8 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
@@ -40,6 +40,7 @@ import net.minecraft.util.SortedArraySet;
import net.minecraft.util.Unit;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.chunk.LevelChunk;
+import org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable;
import org.slf4j.Logger;
import java.io.IOException;
import java.text.DecimalFormat;
@@ -71,11 +72,11 @@ public final class ChunkHolderManager {
@@ -71,11 +71,11 @@ public final class ChunkHolderManager {
private static final long PROBE_MARKER = Long.MIN_VALUE + 1;
public final ReentrantAreaLock ticketLockArea;
- private final ConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket<?>>> tickets = new ConcurrentLong2ReferenceChainedHashTable<>();
- private final ConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new ConcurrentLong2ReferenceChainedHashTable<>();
+ private final LeafConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket<?>>> tickets = new LeafConcurrentLong2ReferenceChainedHashTable<>();
+ private final LeafConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new LeafConcurrentLong2ReferenceChainedHashTable<>();
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket<?>>> tickets = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
final ChunkUnloadQueue unloadQueue;
- private final ConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f);
+ private final LeafConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = LeafConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f);
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f);
private final ServerLevel world;
private final ChunkTaskScheduler taskScheduler;
private long currentTick;
@@ -1422,9 +1423,9 @@ public final class ChunkHolderManager {
@@ -1422,9 +1422,9 @@ public final class ChunkHolderManager {
final JsonArray allTicketsJson = new JsonArray();
ret.add("tickets", allTicketsJson);
- for (final Iterator<ConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>>> iterator = this.tickets.entryIterator();
+ for (final Iterator<LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>>> iterator = this.tickets.entryIterator();
+ for (final Iterator<org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>>> iterator = this.tickets.entryIterator();
iterator.hasNext();) {
- final ConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>> coordinateTickets = iterator.next();
+ final LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>> coordinateTickets = iterator.next();
+ final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable.TableEntry<SortedArraySet<Ticket<?>>> coordinateTickets = iterator.next();
final long coordinate = coordinateTickets.getKey();
final SortedArraySet<Ticket<?>> tickets = coordinateTickets.getValue();
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
index 310a8f80debadd64c2d962ebf83b7d0505ce6e42..b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4 100644
index 310a8f80debadd64c2d962ebf83b7d0505ce6e42..01598347ea545f2ff2ac337086345d7369a64520 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
@@ -10,6 +10,8 @@ import it.unimi.dsi.fastutil.longs.Long2ByteLinkedOpenHashMap;
import it.unimi.dsi.fastutil.shorts.Short2ByteLinkedOpenHashMap;
import it.unimi.dsi.fastutil.shorts.Short2ByteMap;
import it.unimi.dsi.fastutil.shorts.ShortOpenHashSet;
+import org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable;
+
import java.lang.invoke.VarHandle;
import java.util.ArrayDeque;
import java.util.ArrayList;
@@ -35,11 +37,11 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -35,11 +35,11 @@ public abstract class ThreadedTicketLevelPropagator {
}
private final UpdateQueue updateQueue;
- private final ConcurrentLong2ReferenceChainedHashTable<Section> sections;
+ private final LeafConcurrentLong2ReferenceChainedHashTable<Section> sections;
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<Section> sections;
public ThreadedTicketLevelPropagator() {
this.updateQueue = new UpdateQueue();
- this.sections = new ConcurrentLong2ReferenceChainedHashTable<>();
+ this.sections = new LeafConcurrentLong2ReferenceChainedHashTable<>();
+ this.sections = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
}
// must hold ticket lock for:
diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
index 1487b7d8be435b3fbad2aabd05796965b4775a87..54c425ba84c7c70becdfbde08812afdde777f5a8 100644
index 1487b7d8be435b3fbad2aabd05796965b4775a87..a1459e3bc2076575e3f52d9e2b7d49630afeb799 100644
--- a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
+++ b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java
@@ -27,6 +27,8 @@ import net.minecraft.world.level.chunk.LightChunkGetter;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.lighting.LayerLightEventListener;
import net.minecraft.world.level.lighting.LevelLightEngine;
+import org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable;
+
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
@@ -740,7 +742,7 @@ public final class StarLightInterface {
@@ -740,7 +740,7 @@ public final class StarLightInterface {
public static final class ServerLightQueue extends LightQueue {
- private final ConcurrentLong2ReferenceChainedHashTable<ServerChunkTasks> chunkTasks = new ConcurrentLong2ReferenceChainedHashTable<>();
+ private final LeafConcurrentLong2ReferenceChainedHashTable<ServerChunkTasks> chunkTasks = new LeafConcurrentLong2ReferenceChainedHashTable<>();
+ private final org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<ServerChunkTasks> chunkTasks = new org.dreeam.leaf.util.map.spottedleaf.LeafConcurrentLong2ReferenceChainedHashTable<>();
public ServerLightQueue(final StarLightInterface lightInterface) {
super(lightInterface);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimize ThreadedTicketLevelPropagator
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc1de204b7 100644
index 01598347ea545f2ff2ac337086345d7369a64520..f7b995909cb580d03de3bf9ee20a6e36ef8aaaab 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
@@ -780,11 +780,13 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -778,11 +778,13 @@ public abstract class ThreadedTicketLevelPropagator {
// minimum number of bits to represent [0, SECTION_SIZE * SECTION_CACHE_WIDTH)
private static final int COORDINATE_BITS = 9;
private static final int COORDINATE_SIZE = 1 << COORDINATE_BITS;
@@ -22,7 +22,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
// index = x + (z * SECTION_CACHE_WIDTH)
// (this requires x >= 0 and z >= 0)
private final Section[] sections = new Section[SECTION_CACHE_WIDTH * SECTION_CACHE_WIDTH];
@@ -828,8 +830,8 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -826,8 +828,8 @@ public abstract class ThreadedTicketLevelPropagator {
// must hold ticket lock for (centerSectionX,centerSectionZ) in radius rad
// must call setupEncodeOffset
private final void setupCaches(final ThreadedTicketLevelPropagator propagator,
@@ -33,7 +33,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
for (int dz = -rad; dz <= rad; ++dz) {
for (int dx = -rad; dx <= rad; ++dx) {
final int sectionX = centerSectionX + dx;
@@ -847,29 +849,29 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -845,29 +847,29 @@ public abstract class ThreadedTicketLevelPropagator {
}
private final void setSectionInCache(final int sectionX, final int sectionZ, final Section section) {
@@ -70,7 +70,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
}
}
@@ -882,8 +884,8 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -880,8 +882,8 @@ public abstract class ThreadedTicketLevelPropagator {
// next LEVEL_BITS (6) bits: propagated level [0, 63]
// propagation directions bitset (16 bits):
private static final long ALL_DIRECTIONS_BITSET = (
@@ -81,7 +81,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
(1L << ((1 + 0) | ((1 - 1) << 2))) |
(1L << ((1 + 1) | ((1 - 1) << 2))) |
@@ -920,7 +922,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -918,7 +920,7 @@ public abstract class ThreadedTicketLevelPropagator {
}
private void ch(long bs, int shift) {
@@ -90,7 +90,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
for (int i = 0, len = Integer.bitCount(bitset); i < len; ++i) {
final int set = Integer.numberOfTrailingZeros(bitset);
final int tailingBit = (-bitset) & bitset;
@@ -1000,27 +1002,38 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -998,27 +1000,38 @@ public abstract class ThreadedTicketLevelPropagator {
final int decodeOffsetZ = -this.encodeOffsetZ;
final int encodeOffset = this.coordinateOffset;
final int sectionOffset = this.sectionIndexOffset;
@@ -135,7 +135,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
}
// this bitset represents the values that we have not propagated to
@@ -1036,8 +1049,8 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1034,8 +1047,8 @@ public abstract class ThreadedTicketLevelPropagator {
// must guarantee that either we propagate everything in 1 radius or we partially propagate for 1 radius
// but the rest not propagated are already handled
long currentPropagation = ~(
@@ -146,7 +146,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
(1L << ((2 + 0) | ((2 - 1) << 3))) |
(1L << ((2 + 1) | ((2 - 1) << 3))) |
@@ -1095,7 +1108,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1093,7 +1106,7 @@ public abstract class ThreadedTicketLevelPropagator {
currentPropagation ^= (bitsetLine1 | bitsetLine2 | bitsetLine3);
// now try to propagate
@@ -155,7 +155,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
// lower 8 bits are current level, next upper 7 bits are source level, next 1 bit is updated source flag
final short currentStoredLevel = section.levels[localIndex];
@@ -1106,8 +1119,8 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1104,8 +1117,8 @@ public abstract class ThreadedTicketLevelPropagator {
}
// update level
@@ -166,7 +166,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
// queue next
if (toPropagate > 1) {
@@ -1115,7 +1128,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1113,7 +1126,7 @@ public abstract class ThreadedTicketLevelPropagator {
// the child bitset is 4x4, so we just shift each line by 4
// add the propagation bitset offset to each line to make it easy to OR it into the propagation queue value
final long childPropagation =
@@ -175,7 +175,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
((bitsetLine2 >>> (start + 8)) << (4 + COORDINATE_BITS + COORDINATE_BITS + LEVEL_BITS)) | // z = 0
((bitsetLine3 >>> (start + (8 + 8))) << (4 + 4 + COORDINATE_BITS + COORDINATE_BITS + LEVEL_BITS)); // z = 1
@@ -1125,7 +1138,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1123,7 +1136,7 @@ public abstract class ThreadedTicketLevelPropagator {
queue = this.resizeIncreaseQueue();
}
queue[queueLength++] =
@@ -184,7 +184,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
((toPropagate & (LEVEL_COUNT - 1L)) << (COORDINATE_BITS + COORDINATE_BITS)) |
childPropagation; //(ALL_DIRECTIONS_BITSET << (COORDINATE_BITS + COORDINATE_BITS + LEVEL_BITS));
continue;
@@ -1146,18 +1159,19 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1144,18 +1157,19 @@ public abstract class ThreadedTicketLevelPropagator {
final int decodeOffsetZ = -this.encodeOffsetZ;
final int encodeOffset = this.coordinateOffset;
final int sectionOffset = this.sectionIndexOffset;
@@ -208,7 +208,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
// this bitset represents the values that we have not propagated to
// this bitset lets us determine what directions the neighbours we set should propagate to, in most cases
@@ -1172,8 +1186,8 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1170,8 +1184,8 @@ public abstract class ThreadedTicketLevelPropagator {
// must guarantee that either we propagate everything in 1 radius or we partially propagate for 1 radius
// but the rest not propagated are already handled
long currentPropagation = ~(
@@ -219,7 +219,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
(1L << ((2 + 0) | ((2 - 1) << 3))) |
(1L << ((2 + 1) | ((2 - 1) << 3))) |
@@ -1229,7 +1243,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1227,7 +1241,7 @@ public abstract class ThreadedTicketLevelPropagator {
final long bitsetLine3 = currentPropagation & (7L << (start + (8 + 8)));
// now try to propagate
@@ -228,7 +228,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
// lower 8 bits are current level, next upper 7 bits are source level, next 1 bit is updated source flag
final short currentStoredLevel = section.levels[localIndex];
@@ -1246,7 +1260,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1244,7 +1258,7 @@ public abstract class ThreadedTicketLevelPropagator {
increaseQueue = this.resizeIncreaseQueue();
}
increaseQueue[increaseQueueLength++] =
@@ -237,7 +237,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
((currentLevel & (LEVEL_COUNT - 1L)) << (COORDINATE_BITS + COORDINATE_BITS)) |
(FLAG_RECHECK_LEVEL | (ALL_DIRECTIONS_BITSET << (COORDINATE_BITS + COORDINATE_BITS + LEVEL_BITS)));
continue;
@@ -1257,8 +1271,8 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1255,8 +1269,8 @@ public abstract class ThreadedTicketLevelPropagator {
//currentPropagation ^= (bitsetLine1 | bitsetLine2 | bitsetLine3);
// update level
@@ -248,7 +248,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
if (sourceLevel != 0) {
// re-propagate source
@@ -1267,7 +1281,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1265,7 +1279,7 @@ public abstract class ThreadedTicketLevelPropagator {
increaseQueue = this.resizeIncreaseQueue();
}
increaseQueue[increaseQueueLength++] =
@@ -257,7 +257,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
((sourceLevel & (LEVEL_COUNT - 1L)) << (COORDINATE_BITS + COORDINATE_BITS)) |
(FLAG_WRITE_LEVEL | (ALL_DIRECTIONS_BITSET << (COORDINATE_BITS + COORDINATE_BITS + LEVEL_BITS)));
}
@@ -1278,7 +1292,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1276,7 +1290,7 @@ public abstract class ThreadedTicketLevelPropagator {
// the child bitset is 4x4, so we just shift each line by 4
// add the propagation bitset offset to each line to make it easy to OR it into the propagation queue value
final long childPropagation =
@@ -266,7 +266,7 @@ index b69d256e2f6bab3c1b90c5f8c42caa3d80cd67a4..e8dddc7fca4b0383844be5337a87c4bc
((bitsetLine2 >>> (start + 8)) << (4 + COORDINATE_BITS + COORDINATE_BITS + LEVEL_BITS)) | // z = 0
((bitsetLine3 >>> (start + (8 + 8))) << (4 + 4 + COORDINATE_BITS + COORDINATE_BITS + LEVEL_BITS)); // z = 1
@@ -1288,7 +1302,7 @@ public abstract class ThreadedTicketLevelPropagator {
@@ -1286,7 +1300,7 @@ public abstract class ThreadedTicketLevelPropagator {
queue = this.resizeDecreaseQueue();
}
queue[queueLength++] =

View File

@@ -1,14 +1,15 @@
package org.dreeam.leaf.async.ai;
import org.jetbrains.annotations.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.List;
import java.util.concurrent.ExecutorService;
public class AsyncGoalExecutor {
@Nullable
public static java.util.concurrent.ExecutorService EXECUTOR;
public static ExecutorService EXECUTOR;
public static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger("Leaf Async Entity Lookup");
public static final Logger LOGGER = LogManager.getLogger("Leaf Async Entity Lookup");
public static void runTasks(List<Runnable> tasks) {
for (Runnable task : tasks) {

View File

@@ -6,7 +6,8 @@ import java.util.Locale;
public enum PathfindTaskRejectPolicy {
FLUSH_ALL,
CALLER_RUNS;
CALLER_RUNS,
DISCARD;
public static PathfindTaskRejectPolicy fromString(String policy) {
try {

View File

@@ -22,7 +22,7 @@ public class AsyncMobSpawning extends ConfigModules {
This just offloads some expensive calculations that are required for mob spawning.""",
"""
是否异步化生物生成.
在实体较多的服务器上, 异步生成可最高带来15%的性能提升.
在实体较多的服务器上, 异步生成可最高带来 15% 的性能提升.
须在Paper配置文件中打开 per-player-mob-spawns 才能生效.""");
// This prevents us from changing the value during a reload.

View File

@@ -24,11 +24,13 @@ public class AsyncPathfinding extends ConfigModules {
"""
The policy to use when the queue is full and a new task is submitted.
FLUSH_ALL: All pending tasks will be run on server thread.
CALLER_RUNS: Newly submitted task will be run on server thread.""",
CALLER_RUNS: Newly submitted task will be run on server thread.
DISCARD: Newly submitted task will be dropped directly.""",
"""
当队列满时, 新提交的任务将使用以下策略处理.
FLUSH_ALL: 所有等待中的任务都将在主线程上运行.
CALLER_RUNS: 新提交的任务将在主线程上运行."""
CALLER_RUNS: 新提交的任务将在主线程上运行.
DISCARD: 新提交的任务会被直接丢弃."""
);
if (asyncPathfindingInitialized) {
config.getConfigSection(getBasePath());

View File

@@ -1,10 +1,10 @@
package org.dreeam.leaf.config.modules.async;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.dreeam.leaf.async.ai.AsyncGoalExecutor;
import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory;
import org.dreeam.leaf.config.LeafConfig;
import org.dreeam.leaf.config.annotations.Experimental;
import java.util.concurrent.ArrayBlockingQueue;
@@ -62,12 +62,11 @@ public class AsyncTargetFinding extends ConfigModules {
0L,
TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<>(128),
new com.google.common.util.concurrent.ThreadFactoryBuilder()
new ThreadFactoryBuilder()
.setNameFormat("Leaf Async Target Finding Thread")
.setDaemon(true)
.setPriority(Thread.NORM_PRIORITY - 2)
.build(),
new ThreadPoolExecutor.CallerRunsPolicy());
LeafConfig.LOGGER.info("Using 1 threads for Async Target Finding");
}
}

View File

@@ -18,7 +18,8 @@ public class MultithreadedTracker extends ConfigModules {
@Override
public void onLoaded() {
config.addCommentRegionBased(getBasePath(), """
config.addCommentRegionBased(getBasePath(),
"""
Make entity tracking saving asynchronously, can improve performance significantly,
especially in some massive entities in small area situations.""",
"""

View File

@@ -23,7 +23,7 @@ public class SparklyPaperParallelWorldTicking extends ConfigModules {
config.addCommentRegionBased(getBasePath(),
"""
**Experimental feature**
Enables parallel world ticking to improve performance on multi-core systems..""",
Enables parallel world ticking to improve performance on multi-core systems.""",
"""
**实验性功能**
启用并行世界处理以提高多核 CPU 使用率.""");

View File

@@ -67,8 +67,8 @@ public class FastRNG extends ConfigModules {
Use direct random implementation instead of delegating to Java's RandomGenerator.
This may improve performance but potentially changes RNG behavior.""",
"""
使用直接随机实现而不是委托给Java的RandomGenerator.
这可能会提高性能但可能会改变RNG行为"""));
使用直接随机实现而不是委派给 RandomGenerator.
这可能会提高性能, 但可能会改变 RNG 行为."""));
if (enabled) {
try {