Skip to content

Commit

Permalink
SparklyPaper: Parallel world ticking
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Sep 29, 2024
1 parent 9a99f8f commit 431cdb3
Show file tree
Hide file tree
Showing 3 changed files with 1,841 additions and 25 deletions.
27 changes: 2 additions & 25 deletions .github/workflows/build-1211.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Build Leaf 1.21.1
name: Build Leaf 1.21.1 - Parallel World Ticking

on:
push:
branches: [ "ver/1.21.1" ]
pull_request:
branches: [ "ver/1.21.1" ]
branches: [ "feat/parallel-world-tick" ]

jobs:
build:
Expand Down Expand Up @@ -36,16 +34,6 @@ jobs:
mv build/libs/leaf-paperclip-1.21.1-R0.1-SNAPSHOT-mojmap.jar ./leaf-1.21.1-mojmap.jar
mv build/libs/leaf-paperclip-1.21.1-R0.1-SNAPSHOT-reobf.jar ./leaf-1.21.1-reobf.jar
- name: Publish API
if: github.event_name != 'pull_request'
run: |
echo "REPO_USER=${{ secrets.REPO_USER }}" >> $GITHUB_ENV
export REPO_USER=${{ secrets.REPO_USER }}
echo "REPO_PASSWORD=${{ secrets.REPO_PASSWORD }}" >> $GITHUB_ENV
export REPO_PASSWORD=${{ secrets.REPO_PASSWORD }}
./gradlew :leaf-api:publish
./gradlew publishDevBundlePublicationToLeafRepository -PpublishDevBundle=true
- name: Upload Leaf
uses: actions/upload-artifact@main
with:
Expand All @@ -55,14 +43,3 @@ jobs:
- name: Rename Paperclip Jar
run: |
mv ./leaf-1.21.1-mojmap.jar ./leaf-1.21.1.jar
# TODO: marvinpinto/action-automatic-releases is archived, need to find new one
- name: Release Leaf
if: github.event_name != 'pull_request'
uses: marvinpinto/action-automatic-releases@master
with:
title: "Leaf 1.21.1"
automatic_release_tag: "ver-1.21.1"
repo_token: "${{ secrets.GITHUB_TOKEN }}"
files: "./leaf-1.21.1.jar"
prerelease: false
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
Loading

0 comments on commit 431cdb3

Please sign in to comment.