-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SparklyPaper: Parallel world ticking
- Loading branch information
1 parent
9a99f8f
commit 431cdb3
Showing
3 changed files
with
1,841 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
patches/server/0106-SparklyPaper-Track-how-much-MSPT-each-world-used.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: MrPowerGamerBR <git@mrpowergamerbr.com> | ||
Date: Mon, 6 Nov 2023 21:54:33 -0300 | ||
Subject: [PATCH] SparklyPaper: Track how much MSPT each world used | ||
|
||
Original project: https://github.com/SparklyPower/SparklyPaper | ||
|
||
diff --git a/src/main/java/io/papermc/paper/command/MSPTCommand.java b/src/main/java/io/papermc/paper/command/MSPTCommand.java | ||
index 8b5293b0c696ef21d0101493ffa41b60bf0bc86b..601198a33adb29316b0617d5390d1620b7c1095c 100644 | ||
--- a/src/main/java/io/papermc/paper/command/MSPTCommand.java | ||
+++ b/src/main/java/io/papermc/paper/command/MSPTCommand.java | ||
@@ -78,6 +78,46 @@ public final class MSPTCommand extends Command { | ||
) | ||
) | ||
); | ||
+ | ||
+ // SparklyPaper start - track world's MSPT | ||
+ sender.sendMessage(text()); | ||
+ sender.sendMessage(text().content("World tick times ").color(GOLD) | ||
+ .append(text().color(YELLOW) | ||
+ .append( | ||
+ text("("), | ||
+ text("avg", GRAY), | ||
+ text("/"), | ||
+ text("min", GRAY), | ||
+ text("/"), | ||
+ text("max", GRAY), | ||
+ text(")") | ||
+ ) | ||
+ ).append( | ||
+ text(" from last 5s"), | ||
+ text(",", GRAY), | ||
+ text(" 10s"), | ||
+ text(",", GRAY), | ||
+ text(" 1m"), | ||
+ text(":", YELLOW) | ||
+ ) | ||
+ ); | ||
+ for (net.minecraft.server.level.ServerLevel serverLevel : server.getAllLevels()) { | ||
+ List<Component> worldTimes = new ArrayList<>(); | ||
+ worldTimes.addAll(eval(serverLevel.tickTimes5s.getTimes())); | ||
+ worldTimes.addAll(eval(serverLevel.tickTimes10s.getTimes())); | ||
+ worldTimes.addAll(eval(serverLevel.tickTimes60s.getTimes())); | ||
+ | ||
+ sender.sendMessage(text().content("◴ " + serverLevel.getWorld().getName() + ": ").color(GOLD) | ||
+ .append(text().color(GRAY) | ||
+ .append( | ||
+ worldTimes.get(0), SLASH, worldTimes.get(1), SLASH, worldTimes.get(2), text(", ", YELLOW), | ||
+ worldTimes.get(3), SLASH, worldTimes.get(4), SLASH, worldTimes.get(5), text(", ", YELLOW), | ||
+ worldTimes.get(6), SLASH, worldTimes.get(7), SLASH, worldTimes.get(8) | ||
+ ) | ||
+ ) | ||
+ ); | ||
+ } | ||
+ // SparklyPaper end | ||
return true; | ||
} | ||
|
||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java | ||
index cfcc4ab30a03e04f7e4aa0970fbde99910c4d2d2..86295e25055fa245f039944757bb7f8f76330389 100644 | ||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java | ||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java | ||
@@ -1815,7 +1815,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa | ||
// CraftBukkit end */ | ||
|
||
try { | ||
+ long i = Util.getNanos(); // SparklyPaper - track world's MSPT | ||
worldserver.tick(shouldKeepTicking); | ||
+ // SparklyPaper start - track world's MSPT | ||
+ long j = Util.getNanos() - i; | ||
+ | ||
+ // These are from the "tickServer" function | ||
+ worldserver.tickTimes5s.add(this.tickCount, j); | ||
+ worldserver.tickTimes10s.add(this.tickCount, j); | ||
+ worldserver.tickTimes60s.add(this.tickCount, j); | ||
+ // SparklyPaper end | ||
} catch (Throwable throwable) { | ||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world"); | ||
|
||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java | ||
index 6a20d3e05e8ceef8752e1a461e91cd1d373f8a89..9dd95e05841fc0e107d5b132f0e6e7f10979feee 100644 | ||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java | ||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java | ||
@@ -499,6 +499,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. | ||
} | ||
// Paper end - lag compensation | ||
|
||
+ // 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 | ||
+ | ||
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer | ||
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { | ||
// IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error |
Oops, something went wrong.