Paper 1.9

This commit is contained in:
Zach Brown
2016-02-29 17:09:49 -06:00
parent cf5b4b8828
commit 26eb457a39
139 changed files with 5550 additions and 8067 deletions

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 8 Mar 2015 03:47:32 -0500
Date: Tue, 1 Mar 2016 23:09:29 -0600
Subject: [PATCH] Further improve server tick loop
Improves how the catchup buffer is handled, allowing it to roll both ways
@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
public ConsoleReader reader;
- public static int currentTick = (int) (System.currentTimeMillis() / 50);
+ public static int currentTick = 0; // PaperSpigot - Further improve tick loop
+ public static int currentTick = 0; // Paper - Further improve tick loop
public final Thread primaryThread;
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
public int autosavePeriod;
@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- public final double[] recentTps = new double[ 3 ];
- // Spigot end
public MinecraftServer(OptionSet options, Proxy proxy, File file1) {
public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
io.netty.util.ResourceLeakDetector.setEnabled( false ); // Spigot - disable
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
this.isRunning = false;
@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- private static double calcTps(double avg, double exp, double tps)
- {
- return ( avg * exp ) + ( tps * ( 1 - exp ) );
+ // PaperSpigot start - Further improve tick loop
+ // Paper start - Further improve server tick loop
+ private static final int TPS = 20;
+ private static final long SEC_IN_NANO = 1000000000;
+ private static final long TICK_TIME = SEC_IN_NANO / TPS;
@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public final RollingAverage tps1 = new RollingAverage(60);
+ public final RollingAverage tps5 = new RollingAverage(60 * 5);
+ public final RollingAverage tps15 = new RollingAverage(60 * 15);
+ public double[] recentTps = new double[ 3 ]; // PaperSpigot - Fine have your darn compat with bad plugins
+ public double[] recentTps = new double[3]; // Paper - Fine have your darn compat with bad plugins
+
+ public static class RollingAverage {
+ private final int size;
@ -90,24 +90,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
}
- // Spigot End
+ // PaperSpigot End
+ // Paper End
public void run() {
try {
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
this.a(this.r);
// Spigot start
+ // PaperSpigot start - Further improve tick loop
Arrays.fill( recentTps, 20 );
- long lastTick = System.nanoTime(), catchupTime = 0, curTime, wait, tickSection = lastTick;
+ //long lastTick = System.nanoTime(), catchupTime = 0, curTime, wait, tickSection = lastTick;
+ long start = System.nanoTime(), lastTick = start - TICK_TIME, catchupTime = 0, curTime, wait, tickSection = start;
+ // PaperSpigot end
+ long start = System.nanoTime(), lastTick = start - TICK_TIME, catchupTime = 0, curTime, wait, tickSection = start; // Paper - Further improve server tick loop
while (this.isRunning) {
curTime = System.nanoTime();
- wait = TICK_TIME - (curTime - lastTick) - catchupTime;
+ // PaperSpigot start - Further improve tick loop
+ // Paper start - Further improve server tick loop
+ wait = TICK_TIME - (curTime - lastTick);
+ if (wait > 0) {
+ if (catchupTime < 2E6) {
@ -132,7 +128,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- if ( MinecraftServer.currentTick++ % SAMPLE_INTERVAL == 0 )
+ catchupTime = Math.min(MAX_CATCHUP_BUFFER, catchupTime - wait);
+
+ if ( ++MinecraftServer.currentTick % SAMPLE_INTERVAL == 0 )
{
- double currentTps = 1E9 / ( curTime - tickSection ) * SAMPLE_INTERVAL;
@ -148,33 +143,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ recentTps[0] = tps1.getAverage();
+ recentTps[1] = tps5.getAverage();
+ recentTps[2] = tps15.getAverage();
+ // Paper end
tickSection = curTime;
+ // PaperSpigot end
}
lastTick = curTime;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
return CraftMagicNumbers.INSTANCE;
}
+ // Paper - Add getTPS API - Further improve tick loop
+ @Override
+ public double[] getTPS() {
+ return new double[] {
+ MinecraftServer.getServer().tps1.getAverage(),
+ MinecraftServer.getServer().tps5.getAverage(),
+ MinecraftServer.getServer().tps15.getAverage()
+ };
+ }
+ // Paper end
+
private final Spigot spigot = new Spigot()
{
+ // PaperSpigot start - Add getTPS (Further improve tick loop)
+ @Override
+ public double[] getTPS() {
+ return new double[] {
+ MinecraftServer.getServer().tps1.getAverage(),
+ MinecraftServer.getServer().tps5.getAverage(),
+ MinecraftServer.getServer().tps15.getAverage()
+ };
+ }
+ // PaperSpigot end
+
@Override
public YamlConfiguration getConfig()
{
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
@ -197,21 +191,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- {
- sb.append( format( tps ) );
- sb.append( ", " );
+ // PaperSpigot start - Further improve tick handling
+ double[] tps = org.bukkit.Bukkit.spigot().getTPS();
+ // Paper start - Further improve tick handling
+ double[] tps = org.bukkit.Bukkit.getTPS();
+ String[] tpsAvg = new String[tps.length];
+
+ for ( int i = 0; i < tps.length; i++) {
+ tpsAvg[i] = format( tps[i] );
+ for ( int i = 0; i < tps.length; i++) {
+ tpsAvg[i] = format( tps[i] );
}
- sender.sendMessage( sb.substring( 0, sb.length() - 2 ) );
+ sender.sendMessage( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", "));
+ // Paper end
return true;
}
- private String format(double tps)
+ private static String format(double tps) // PaperSpigot - made static
+ private static String format(double tps) // Paper - Made static
{
return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
+ ( ( tps > 20.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 );