mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
* prevents async entity tracker update equipment * fix seenBy updated check * skip submit empty * fix invertedVisibilityEntities data race * strict thread check * set max-threads to 1 by default * use fixed thread count * increase thread priority * Revert "use fixed thread count" This reverts commit6746bc25a8. * Revert "set max-threads to 1 by default" This reverts commit5295b6d3e1. * update entity tracker * cleanup * [ci skip] fix phrasing * cleanup * cleanup * support Citizens * optimize update if chunk player no change * configurable threads * configurable no blocking * fix pos y and z * optimize no blocking * cleanup * cleanup * add handle during waitUntilNextTick * fix entity disappear * cleanup * disable nonblocking by default * [ci skip] add entity slice * impl fork-join * fix async locator diff * optimize queue * inline iterator * [ci skip] Update patch header * cleanup * improve compatibility * add license header * optimize spin wait * remove queue-size option * dynamic adjust subtasks --------- Co-authored-by: Taiyou06 <kaandindar21@gmail.com> Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
130 lines
6.0 KiB
Diff
130 lines
6.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Thu, 6 Mar 2025 00:26:19 +0100
|
|
Subject: [PATCH] SparklyPaper: Track each world MSPT
|
|
|
|
Original project: https://github.com/SparklyPower/SparklyPaper
|
|
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index c8265f25ead389b025aef6ebe4cc44972132f143..5ad00ebb9e0acab73a8366f0caf06979cfcccca0 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -1686,7 +1686,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// Leaf start - SparklyPaper - parallel world ticking mod (move level ticking logic out for branch convergence)
|
|
private void tickLevel(ServerLevel serverLevel, BooleanSupplier hasTimeLeft) {
|
|
try {
|
|
+ long i = Util.getNanos(); // SparklyPaper - track world's MSPT
|
|
serverLevel.tick(hasTimeLeft);
|
|
+ // SparklyPaper start - track world's MSPT
|
|
+ long j = Util.getNanos() - i;
|
|
+
|
|
+ // These are from the "tickServer" function
|
|
+ serverLevel.tickTimes5s.add(this.tickCount, j);
|
|
+ serverLevel.tickTimes10s.add(this.tickCount, j);
|
|
+ serverLevel.tickTimes60s.add(this.tickCount, j);
|
|
+ // SparklyPaper end - track world's MSPT
|
|
} catch (Throwable levelTickingException) {
|
|
CrashReport crashReport = CrashReport.forThrowable(levelTickingException, "Exception ticking world");
|
|
serverLevel.fillReportDetails(crashReport);
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index bc9cf4aa9b1e71e03100a10c45ef9fc23ee5ae9f..bbe2a420193d15874a4dd384ddb3e24ee2d62420 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -571,6 +571,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
// Paper end - chunk tick iteration
|
|
|
|
+ // SparklyPaper start - track world's MSPT
|
|
+ public final MinecraftServer.TickTimes tickTimes5s = new MinecraftServer.TickTimes(100);
|
|
+ public final MinecraftServer.TickTimes tickTimes10s = new MinecraftServer.TickTimes(200);
|
|
+ public final MinecraftServer.TickTimes tickTimes60s = new MinecraftServer.TickTimes(1200);
|
|
+ // SparklyPaper end - track world's MSPT
|
|
+
|
|
public ServerLevel(
|
|
MinecraftServer server,
|
|
Executor dispatcher,
|
|
diff --git a/org/purpurmc/purpur/task/TPSBarTask.java b/org/purpurmc/purpur/task/TPSBarTask.java
|
|
index 8769993e7ca59da309087051a3cd38fc562c15d1..b65c839e45402c618020c77fe63b89bd19cc7d96 100644
|
|
--- a/org/purpurmc/purpur/task/TPSBarTask.java
|
|
+++ b/org/purpurmc/purpur/task/TPSBarTask.java
|
|
@@ -28,6 +28,44 @@ public class TPSBarTask extends BossBarTask {
|
|
|
|
@Override
|
|
void updateBossBar(BossBar bossbar, Player player) {
|
|
+ // SparklyPaper start - track world's MSPT
|
|
+ if (org.dreeam.leaf.config.modules.async.SparklyPaperParallelWorldTicking.enabled) {
|
|
+ // Get player's current world
|
|
+ net.minecraft.server.level.ServerLevel serverLevel = ((org.bukkit.craftbukkit.CraftWorld) player.getWorld()).getHandle();
|
|
+
|
|
+ // Calculate world-specific MSPT and TPS
|
|
+ double worldMspt = calculateWorldMSPT(serverLevel);
|
|
+ double worldTps = Math.min(20.0, 1000.0 / Math.max(worldMspt, 0.001)); // Avoid division by zero
|
|
+
|
|
+ // Store original values
|
|
+ double originalTps = this.tps;
|
|
+ double originalMspt = this.mspt;
|
|
+
|
|
+ try {
|
|
+ // Temporarily set to world values
|
|
+ this.tps = worldTps;
|
|
+ this.mspt = worldMspt;
|
|
+
|
|
+ // Create MSPT component with world name
|
|
+ Component msptWithWorld = Component.empty()
|
|
+ .append(getMSPTColor())
|
|
+ .append(Component.text(" [" + player.getWorld().getName() + "]").color(net.kyori.adventure.text.format.NamedTextColor.GRAY));
|
|
+
|
|
+ // Update the boss bar using the methods that depend on the fields
|
|
+ bossbar.progress(getBossBarProgress());
|
|
+ bossbar.color(getBossBarColor());
|
|
+ bossbar.name(MiniMessage.miniMessage().deserialize(PurpurConfig.commandTPSBarTitle,
|
|
+ Placeholder.component("tps", getTPSColor()),
|
|
+ Placeholder.component("mspt", msptWithWorld),
|
|
+ Placeholder.component("ping", getPingColor(player.getPing()))
|
|
+ ));
|
|
+ } finally {
|
|
+ // Restore original values
|
|
+ this.tps = originalTps;
|
|
+ this.mspt = originalMspt;
|
|
+ }
|
|
+ } else {
|
|
+ // Default behavior
|
|
bossbar.progress(getBossBarProgress());
|
|
bossbar.color(getBossBarColor());
|
|
bossbar.name(MiniMessage.miniMessage().deserialize(PurpurConfig.commandTPSBarTitle,
|
|
@@ -35,6 +73,8 @@ public class TPSBarTask extends BossBarTask {
|
|
Placeholder.component("mspt", getMSPTColor()),
|
|
Placeholder.component("ping", getPingColor(player.getPing()))
|
|
));
|
|
+ }
|
|
+ // SparklyPaper end - track world's MSPT
|
|
}
|
|
|
|
@Override
|
|
@@ -136,6 +176,25 @@ public class TPSBarTask extends BossBarTask {
|
|
return MiniMessage.miniMessage().deserialize(color, Placeholder.parsed("text", String.format("%s", ping)));
|
|
}
|
|
|
|
+ // SparklyPaper start - track world's MSPT
|
|
+ private double calculateWorldMSPT(net.minecraft.server.level.ServerLevel serverLevel) {
|
|
+ long[] times = serverLevel.tickTimes5s.getTimes();
|
|
+ long total = 0L;
|
|
+ int count = 0;
|
|
+
|
|
+ for (long value : times) {
|
|
+ if (value > 0L) {
|
|
+ total += value;
|
|
+ count++;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (count == 0) return 0.0;
|
|
+
|
|
+ return (double) total / (double) count * 1.0E-6D;
|
|
+ }
|
|
+ // SparklyPaper end - track world's MSPT
|
|
+
|
|
public enum FillMode {
|
|
TPS, MSPT, PING
|
|
}
|