Use improved original flush logic on linear region flushing

This commit is contained in:
MrHua269
2024-12-27 15:14:52 +08:00
parent 8a01b9ad39
commit 16df7dce12
3 changed files with 85 additions and 145 deletions

View File

@@ -68,17 +68,16 @@ index 0000000000000000000000000000000000000000..d92f1d549c7e01daa6b5bba7d405e462
+} +}
diff --git a/src/main/java/abomination/LinearRegionFile.java b/src/main/java/abomination/LinearRegionFile.java diff --git a/src/main/java/abomination/LinearRegionFile.java b/src/main/java/abomination/LinearRegionFile.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856d79a6a38 index 0000000000000000000000000000000000000000..bb0fcf5f47b5ae3d86e1d0572f951236afdcd017
--- /dev/null --- /dev/null
+++ b/src/main/java/abomination/LinearRegionFile.java +++ b/src/main/java/abomination/LinearRegionFile.java
@@ -0,0 +1,608 @@ @@ -0,0 +1,622 @@
+package abomination; +package abomination;
+ +
+import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO; +import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO;
+import com.github.luben.zstd.ZstdInputStream; +import com.github.luben.zstd.ZstdInputStream;
+import com.github.luben.zstd.ZstdOutputStream; +import com.github.luben.zstd.ZstdOutputStream;
+import com.mojang.logging.LogUtils; +import com.mojang.logging.LogUtils;
+import me.earthme.luminol.config.modules.misc.RegionFormatConfig;
+import net.jpountz.lz4.LZ4Compressor; +import net.jpountz.lz4.LZ4Compressor;
+import net.jpountz.lz4.LZ4Factory; +import net.jpountz.lz4.LZ4Factory;
+import net.jpountz.lz4.LZ4FastDecompressor; +import net.jpountz.lz4.LZ4FastDecompressor;
@@ -95,8 +94,11 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+import java.nio.file.Files; +import java.nio.file.Files;
+import java.nio.file.Path; +import java.nio.file.Path;
+import java.nio.file.StandardCopyOption; +import java.nio.file.StandardCopyOption;
+import java.util.concurrent.ScheduledFuture; +import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicInteger; +import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.LockSupport;
+import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.locks.ReentrantLock;
+ +
+// LinearRegionFile_implementation_version_0_5byXymb +// LinearRegionFile_implementation_version_0_5byXymb
@@ -127,9 +129,7 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ private final int compressionLevel; + private final int compressionLevel;
+ private int gridSize = 8; + private int gridSize = 8;
+ private int bucketSize = 4; + private int bucketSize = 4;
+ + private final Thread bindThread;
+ private final AtomicInteger modifiedChunkCount = new AtomicInteger(0);
+ private ScheduledFuture<?> ioTask = null;
+ +
+ public Path getRegionFile() { + public Path getRegionFile() {
+ return this.regionFile; + return this.regionFile;
@@ -199,7 +199,7 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ File regionFile = new File(this.regionFile.toString()); + File regionFile = new File(this.regionFile.toString());
+ +
+ if(!regionFile.canRead()) { + if(!regionFile.canRead()) {
+ //this.start(); + this.bindThread.start();
+ return; + return;
+ } + }
+ +
@@ -220,7 +220,7 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ throw new RuntimeException("Invalid version: " + version + " file " + this.regionFile); + throw new RuntimeException("Invalid version: " + version + " file " + this.regionFile);
+ } + }
+ +
+ //this.start(); + this.bindThread.start();
+ } catch (IOException e) { + } catch (IOException e) {
+ throw new RuntimeException("Failed to open region file " + this.regionFile, e); + throw new RuntimeException("Failed to open region file " + this.regionFile, e);
+ } + }
@@ -324,6 +324,35 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ } + }
+ +
+ public LinearRegionFile(RegionStorageInfo storageKey, Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync, int compressionLevel) throws IOException { + public LinearRegionFile(RegionStorageInfo storageKey, Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync, int compressionLevel) throws IOException {
+ Runnable flushCheck = () -> {
+ while (!close) {
+ synchronized (saveLock) {
+ if (markedToSave && activeSaveThreads < SAVE_THREAD_MAX_COUNT) {
+ activeSaveThreads++;
+ Runnable flushOperation = () -> {
+ try {
+ flush();
+ } catch (IOException ex) {
+ LOGGER.error("Region file {} flush failed", this.regionFile.toAbsolutePath(), ex);
+ } finally {
+ synchronized (saveLock) {
+ activeSaveThreads--;
+ }
+ }
+ };
+
+ Thread saveThread = USE_VIRTUAL_THREAD ?
+ Thread.ofVirtual().name("Linear IO - " + LinearRegionFile.this.hashCode()).unstarted(flushOperation) :
+ Thread.ofPlatform().name("Linear IO - " + LinearRegionFile.this.hashCode()).unstarted(flushOperation);
+ saveThread.setPriority(Thread.NORM_PRIORITY - 3);
+ saveThread.start();
+ }
+ }
+ LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(SAVE_DELAY_MS));
+ }
+ };
+ this.bindThread = USE_VIRTUAL_THREAD ? Thread.ofVirtual().unstarted(flushCheck) : Thread.ofPlatform().unstarted(flushCheck);
+ this.bindThread.setName("Linear IO Schedule - " + this.hashCode());
+ this.regionFile = path; + this.regionFile = path;
+ this.compressionLevel = compressionLevel; + this.compressionLevel = compressionLevel;
+ +
@@ -347,14 +376,13 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ } + }
+ } + }
+ +
+ /* + public static int SAVE_THREAD_MAX_COUNT = 6;
+ private static final int SAVE_THREAD_MAX_COUNT = 6; + public static int SAVE_DELAY_MS = 100;
+ public static boolean USE_VIRTUAL_THREAD = true;
+ private static final Object saveLock = new Object(); + private static final Object saveLock = new Object();
+ private static int activeSaveThreads = 0; + private static int activeSaveThreads = 0;
+ */
+ +
+ /*public void run() { + /*public void run() {
+ try {
+ while (!close) { + while (!close) {
+ synchronized (saveLock) { + synchronized (saveLock) {
+ if (markedToSave && activeSaveThreads < SAVE_THREAD_MAX_COUNT) { + if (markedToSave && activeSaveThreads < SAVE_THREAD_MAX_COUNT) {
@@ -374,9 +402,8 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ saveThread.start(); + saveThread.start();
+ } + }
+ } + }
+ Thread.sleep(100); + LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(SAVE_DELAY_MS));
+ } + }
+ } catch(InterruptedException ignored) {}
+ }*/ + }*/
+ +
+ public synchronized boolean doesChunkExist(ChunkPos pos) throws Exception { + public synchronized boolean doesChunkExist(ChunkPos pos) throws Exception {
@@ -492,7 +519,6 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ fileStream.close(); + fileStream.close();
+ Files.move(tempFile.toPath(), this.regionFile, StandardCopyOption.REPLACE_EXISTING); + Files.move(tempFile.toPath(), this.regionFile, StandardCopyOption.REPLACE_EXISTING);
+//System.out.println("writeStart REGION FILE FLUSH " + (System.nanoTime() - writeStart) + " misses: " + bucketMisses); +//System.out.println("writeStart REGION FILE FLUSH " + (System.nanoTime() - writeStart) + " misses: " + bucketMisses);
+ this.modifiedChunkCount.set(0);
+ } + }
+ +
+ private void writeNBTFeatures(DataOutputStream dataStream) throws IOException { + private void writeNBTFeatures(DataOutputStream dataStream) throws IOException {
@@ -535,17 +561,6 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ LOGGER.error("Chunk write IOException " + e + " " + this.regionFile); + LOGGER.error("Chunk write IOException " + e + " " + this.regionFile);
+ } + }
+ markToSave(); + markToSave();
+ this.modifiedChunkCount.getAndIncrement();
+
+ this.ioTask = RegionFormatConfig.linearFlusher.claimTask(this.ioTask, this);
+ }
+
+ public synchronized boolean isClosed() {
+ return this.close;
+ }
+
+ public double getLoadPercent() {
+ return ((double)this.modifiedChunkCount.get()) / (32 * 32);
+ } + }
+ +
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) { + public DataOutputStream getChunkDataOutputStream(ChunkPos pos) {
@@ -624,7 +639,6 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ openRegionFile(); + openRegionFile();
+ close = true; + close = true;
+ try { + try {
+ if (this.ioTask != null) this.ioTask.cancel(false);
+ flush(); + flush();
+ } catch(IOException e) { + } catch(IOException e) {
+ throw new IOException("Region flush IOException " + e + " " + this.regionFile); + throw new IOException("Region flush IOException " + e + " " + this.regionFile);
@@ -680,67 +694,6 @@ index 0000000000000000000000000000000000000000..9fdc9aa840c6b2ae027bcf84a2b77856
+ } + }
+ } + }
+} +}
diff --git a/src/main/java/abomination/LinearRegionFileFlusher.java b/src/main/java/abomination/LinearRegionFileFlusher.java
new file mode 100644
index 0000000000000000000000000000000000000000..b4e4b4a7fb8f37715b6a3099ec2c7f48d65f9390
--- /dev/null
+++ b/src/main/java/abomination/LinearRegionFileFlusher.java
@@ -0,0 +1,55 @@
+package abomination;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class LinearRegionFileFlusher {
+ private final ScheduledThreadPoolExecutor delayedIoSchedule;
+ private final long baseDelay;
+
+ public LinearRegionFileFlusher(int nThreads, long baseDelay) {
+ this.delayedIoSchedule = new ScheduledThreadPoolExecutor(nThreads,
+ new ThreadFactoryBuilder()
+ .setPriority(3)
+ .setNameFormat("Linear IO Thread - %d")
+ .build()
+ );
+ this.baseDelay = baseDelay;
+ }
+
+ public void shutdown() {
+ this.delayedIoSchedule.shutdown();
+ while (true) {
+ try {
+ if (this.delayedIoSchedule.awaitTermination(1000, TimeUnit.MILLISECONDS)) break;
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public ScheduledFuture<?> claimTask(@Nullable ScheduledFuture<?> parent, @NotNull LinearRegionFile file){
+ if (parent != null) {
+ if (!parent.isCancelled() && !parent.isDone()) {
+ parent.cancel(false);
+ }
+ }
+
+ final double loadPercent = file.getLoadPercent() * 100;
+ final double delayOffset = Math.max(this.baseDelay, loadPercent * this.baseDelay);
+
+ final long actualDelay = (long) (this.baseDelay - delayOffset);
+ return this.delayedIoSchedule.schedule(() -> {
+ try {
+ file.flush();
+ }catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }, actualDelay, java.util.concurrent.TimeUnit.MILLISECONDS);
+ }
+}
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
index a814512fcfb85312474ae2c2c21443843bf57831..2e084a5b28cbe4737f48c25e10af589213525362 100644 index a814512fcfb85312474ae2c2c21443843bf57831..2e084a5b28cbe4737f48c25e10af589213525362 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/ChunkSystemRegionFileStorage.java
@@ -783,14 +736,13 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..c7d4d944eb198ac53a3eeae717a25c7d
} }
diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4dc62688fe2731f7b43d7f48c7cb76fef33821c1 index 0000000000000000000000000000000000000000..eb689b6b79143ffaf1eadcba84feca0c632d1407
--- /dev/null --- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java +++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
@@ -0,0 +1,64 @@ @@ -0,0 +1,59 @@
+package me.earthme.luminol.config.modules.misc; +package me.earthme.luminol.config.modules.misc;
+ +
+import abomination.LinearRegionFile; +import abomination.LinearRegionFile;
+import abomination.LinearRegionFileFlusher;
+import com.electronwill.nightconfig.core.file.CommentedFileConfig; +import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import me.earthme.luminol.config.*; +import me.earthme.luminol.config.*;
+import me.earthme.luminol.utils.EnumRegionFormat; +import me.earthme.luminol.utils.EnumRegionFormat;
@@ -809,9 +761,9 @@ index 0000000000000000000000000000000000000000..4dc62688fe2731f7b43d7f48c7cb76fe
+ @HotReloadUnsupported + @HotReloadUnsupported
+ @ConfigInfo(baseName = "linear_io_flush_delay_ms") + @ConfigInfo(baseName = "linear_io_flush_delay_ms")
+ public static int linearIoFlushDelayMs = 100; + public static int linearIoFlushDelayMs = 100;
+ + @HotReloadUnsupported
+ @DoNotLoad + @ConfigInfo(baseName = "linear_use_virtual_thread")
+ public static LinearRegionFileFlusher linearFlusher; + public static boolean linearUseVirtualThread = true;
+ +
+ @DoNotLoad + @DoNotLoad
+ public static EnumRegionFormat regionFormat; + public static EnumRegionFormat regionFormat;
@@ -834,20 +786,16 @@ index 0000000000000000000000000000000000000000..4dc62688fe2731f7b43d7f48c7cb76fe
+ throw new RuntimeException("Invalid region format: " + format); + throw new RuntimeException("Invalid region format: " + format);
+ } + }
+ +
+ if (regionFormat == EnumRegionFormat.LINEAR_V2) {
+ if (RegionFormatConfig.linearCompressionLevel > 23 || RegionFormatConfig.linearCompressionLevel < 1) { + if (RegionFormatConfig.linearCompressionLevel > 23 || RegionFormatConfig.linearCompressionLevel < 1) {
+ MinecraftServer.LOGGER.error("Linear region compression level should be between 1 and 22 in config: {}", RegionFormatConfig.linearCompressionLevel); + MinecraftServer.LOGGER.error("Linear region compression level should be between 1 and 22 in config: {}", RegionFormatConfig.linearCompressionLevel);
+ MinecraftServer.LOGGER.error("Falling back to compression level 1."); + MinecraftServer.LOGGER.error("Falling back to compression level 1.");
+ RegionFormatConfig.linearCompressionLevel = 1; + RegionFormatConfig.linearCompressionLevel = 1;
+ } + }
+ +
+ if (regionFormat == EnumRegionFormat.LINEAR_V2) { + LinearRegionFile.SAVE_DELAY_MS = linearIoFlushDelayMs;
+ linearFlusher = new LinearRegionFileFlusher(RegionFormatConfig.linearIoThreadCount, RegionFormatConfig.linearIoFlushDelayMs); + LinearRegionFile.SAVE_THREAD_MAX_COUNT = linearIoThreadCount;
+ } + LinearRegionFile.USE_VIRTUAL_THREAD = linearUseVirtualThread;
+ }
+
+ public static void shutdownLinearIOPool() {
+ if (linearFlusher != null) {
+ linearFlusher.shutdown();
+ } + }
+ } + }
+} +}
@@ -926,7 +874,7 @@ index 0000000000000000000000000000000000000000..5af068489646ed70330d8c6242ec88f5
+ +
+public record RegionCreatorInfo (RegionStorageInfo info, Path filePath, Path folder, boolean sync) {} +public record RegionCreatorInfo (RegionStorageInfo info, Path filePath, Path folder, boolean sync) {}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 8cc0c01a19fc71753d7c3ed4fa7e9992aaf93b5a..ad79dee048a57be6a6997a38195d636ce952c48d 100644 index 8cc0c01a19fc71753d7c3ed4fa7e9992aaf93b5a..04f68856cb3d982f1644d26f5ae57587b6e36ff2 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1036,10 +1036,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1036,10 +1036,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -942,14 +890,6 @@ index 8cc0c01a19fc71753d7c3ed4fa7e9992aaf93b5a..ad79dee048a57be6a6997a38195d636c
} }
return flag3; return flag3;
@@ -1180,6 +1180,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.saveAllChunks(false, true, true, true); // Paper - rewrite chunk system
this.isSaving = false;
+ me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearFlusher.shutdown(); // Luminol - Linear region file format
// Folia start - region threading
this.stopPart2();
}
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
index 622d0cbe023774d92d212f242b60b96317720835..9b4b01a741e8779f4ea06b0fd801ce243e179910 100644 index 622d0cbe023774d92d212f242b60b96317720835..9b4b01a741e8779f4ea06b0fd801ce243e179910 100644
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java --- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java

View File

@@ -18,7 +18,7 @@ index 48604e7f96adc9e226e034054c5e2bad0b024eb5..99f0c1e4d3437154a1062b0a8f94b7a0
return; return;
} }
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 88be8a6232bc3311cc0bdb7c697f7a78ce33e38d..c7390e0341cd19fa5e0b21882f27943174f718d0 100644 index 04f68856cb3d982f1644d26f5ae57587b6e36ff2..55bac6e6cccce6e0282936ac78bbe82628daa655 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -809,8 +809,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -809,8 +809,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -41,7 +41,7 @@ index 88be8a6232bc3311cc0bdb7c697f7a78ce33e38d..c7390e0341cd19fa5e0b21882f279431
this.server.disablePlugins(); this.server.disablePlugins();
this.server.waitForAsyncTasksShutdown(); // Paper - Wait for Async Tasks during shutdown this.server.waitForAsyncTasksShutdown(); // Paper - Wait for Async Tasks during shutdown
} }
@@ -1324,7 +1324,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1323,7 +1323,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error this.statusIcon = (ServerStatus.Favicon) this.loadStatusIcon().orElse(null); // CraftBukkit - decompile error
this.status = this.buildServerStatus(); this.status = this.buildServerStatus();
@@ -50,7 +50,7 @@ index 88be8a6232bc3311cc0bdb7c697f7a78ce33e38d..c7390e0341cd19fa5e0b21882f279431
// Folia start - region threading // Folia start - region threading
if (true) { if (true) {
io.papermc.paper.threadedregions.RegionizedServer.getInstance().init(); // Folia - region threading - only after loading worlds io.papermc.paper.threadedregions.RegionizedServer.getInstance().init(); // Folia - region threading - only after loading worlds
@@ -1729,7 +1729,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1728,7 +1728,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} }
if (this.emptyTicks >= j) { if (this.emptyTicks >= j) {
@@ -59,7 +59,7 @@ index 88be8a6232bc3311cc0bdb7c697f7a78ce33e38d..c7390e0341cd19fa5e0b21882f279431
if (this.emptyTicks == j) { if (this.emptyTicks == j) {
MinecraftServer.LOGGER.info("Server empty for {} seconds, pausing", this.pauseWhileEmptySeconds()); MinecraftServer.LOGGER.info("Server empty for {} seconds, pausing", this.pauseWhileEmptySeconds());
this.autoSave(); this.autoSave();
@@ -1748,7 +1748,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1747,7 +1747,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper end - avoid issues with certain tasks not processing during sleep // Paper end - avoid issues with certain tasks not processing during sleep
// Folia - region threading // Folia - region threading
this.tickConnection(); this.tickConnection();
@@ -69,7 +69,7 @@ index 88be8a6232bc3311cc0bdb7c697f7a78ce33e38d..c7390e0341cd19fa5e0b21882f279431
return; return;
} }
} }
@@ -1773,7 +1774,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1772,7 +1773,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}; };
// Folia end - region threading // Folia end - region threading
@@ -78,7 +78,7 @@ index 88be8a6232bc3311cc0bdb7c697f7a78ce33e38d..c7390e0341cd19fa5e0b21882f279431
new com.destroystokyo.paper.event.server.ServerTickStartEvent((int)region.getCurrentTick()).callEvent(); // Paper - Server Tick Events // Folia - region threading new com.destroystokyo.paper.event.server.ServerTickStartEvent((int)region.getCurrentTick()).callEvent(); // Paper - Server Tick Events // Folia - region threading
// Folia start - region threading // Folia start - region threading
if (region != null) { if (region != null) {
@@ -1844,7 +1845,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1843,7 +1844,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
long remaining = scheduledEnd - endTime; // Folia - region ticking long remaining = scheduledEnd - endTime; // Folia - region ticking
new com.destroystokyo.paper.event.server.ServerTickEndEvent((int)io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(), ((double)(endTime - startTime) / 1000000D), remaining).callEvent(); // Folia - region ticking new com.destroystokyo.paper.event.server.ServerTickEndEvent((int)io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(), ((double)(endTime - startTime) / 1000000D), remaining).callEvent(); // Folia - region ticking
// Paper end - Server Tick Events // Paper end - Server Tick Events

View File

@@ -179,10 +179,10 @@ index de2f03d6e771c09e8da2da454b7ec4a16c0a17ab..0b7347e8fdf995900221ee4aa4e97a4d
if (mspt == -1){ if (mspt == -1){
return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3)); return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index c7390e0341cd19fa5e0b21882f27943174f718d0..19e1dfbcd69e3f960d148b014e9e9248072918a2 100644 index 55bac6e6cccce6e0282936ac78bbe82628daa655..2cff9edf247587dffaac5405127de0afc17dc7c0 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1802,6 +1802,29 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1801,6 +1801,29 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_SCHEDULER_TICK); } // Folia - profiler } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_SCHEDULER_TICK); } // Folia - profiler
} }
// Folia end - region threading // Folia end - region threading
@@ -212,7 +212,7 @@ index c7390e0341cd19fa5e0b21882f27943174f718d0..19e1dfbcd69e3f960d148b014e9e9248
if (region == null) this.tickRateManager.tick(); // Folia - region threading if (region == null) this.tickRateManager.tick(); // Folia - region threading
this.tickChildren(shouldKeepTicking, region); // Folia - region threading this.tickChildren(shouldKeepTicking, region); // Folia - region threading
if (region == null && i - this.lastServerStatus >= MinecraftServer.STATUS_EXPIRE_TIME_NANOS) { // Folia - region threading if (region == null && i - this.lastServerStatus >= MinecraftServer.STATUS_EXPIRE_TIME_NANOS) { // Folia - region threading
@@ -1810,6 +1833,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1809,6 +1832,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} }
// Folia - region threading // Folia - region threading
@@ -332,7 +332,7 @@ index 921527acc8624536f4a48e9fdf7fce370bc52c77..497de02dce0f397ce261b4d62777e11f
+ // KioCG end + // KioCG end
} }
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 3b2bce1b5261a0efbbfcd7d38bf7f093d97df3a6..2d9f75526240689facba1a4fbef7d40ef8299a1d 100644 index b6aaa238626bc747379f991c17c279de52907083..3700f7c1893e9ccdcef04ae1fab5d7c97c5a91d7 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -6236,4 +6236,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -6236,4 +6236,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess