From d72e245f405e94a8658b3e1e725a496c3cf9d92c Mon Sep 17 00:00:00 2001
From: Sotr
Date: Wed, 20 Mar 2019 02:19:36 +0800
Subject: [PATCH] Further optimize timings
---
.../main/java/co/aikar/timings/Timing.java | 2 +
.../java/co/aikar/timings/TimingHandler.java | 24 ++++++-
src/main/java/net/minecraft/server/Chunk.java | 6 +-
.../java/net/minecraft/server/ChunkMap.java | 2 +-
.../minecraft/server/ChunkProviderServer.java | 2 +-
.../minecraft/server/CommandDispatcher.java | 4 +-
.../minecraft/server/CustomFunctionData.java | 8 +--
.../java/net/minecraft/server/Entity.java | 16 ++---
.../minecraft/server/EntityInsentient.java | 20 +++---
.../net/minecraft/server/EntityLiving.java | 16 ++---
.../server/EntityMinecartAbstract.java | 2 +-
.../net/minecraft/server/MinecraftServer.java | 64 +++++++++----------
.../net/minecraft/server/PlayerChunkMap.java | 14 ++--
src/main/java/net/minecraft/server/World.java | 32 +++++-----
.../net/minecraft/server/WorldServer.java | 46 ++++++-------
15 files changed, 141 insertions(+), 117 deletions(-)
diff --git a/src/api/main/java/co/aikar/timings/Timing.java b/src/api/main/java/co/aikar/timings/Timing.java
index b7d4bdbf2..a60d0072d 100644
--- a/src/api/main/java/co/aikar/timings/Timing.java
+++ b/src/api/main/java/co/aikar/timings/Timing.java
@@ -34,6 +34,7 @@ public interface Timing extends AutoCloseable {
*/
Timing startTiming();
default Timing startTiming(boolean assertThread) { return startTiming(); }; // Akarin
+ default Timing startTimingUnsafe() { return startTiming(); }; // Akarin
/**
*
Stops timing and records the data. Propagates the data up to group handlers.
@@ -41,6 +42,7 @@ public interface Timing extends AutoCloseable {
* Will automatically be called when this Timing is used with try-with-resources
*/
void stopTiming();
+ default void stopTimingUnsafe() { stopTiming(); }; // Akarin
/**
* Starts timing the execution until {@link #stopTiming()} is called.
diff --git a/src/api/main/java/co/aikar/timings/TimingHandler.java b/src/api/main/java/co/aikar/timings/TimingHandler.java
index 283c08391..567a6bba7 100644
--- a/src/api/main/java/co/aikar/timings/TimingHandler.java
+++ b/src/api/main/java/co/aikar/timings/TimingHandler.java
@@ -50,6 +50,7 @@ class TimingHandler implements Timing {
private boolean timed;
private boolean enabled;
private TimingHandler parent;
+ private boolean unsafe; // Akarin
TimingHandler(TimingIdentifier id) {
if (id.name.startsWith("##")) {
@@ -107,6 +108,26 @@ class TimingHandler implements Timing {
return startTiming(false);
}
+ @Override
+ public Timing startTimingUnsafe() {
+ if (enabled && ++timingDepth == 1) {
+ start = System.nanoTime();
+ parent = TimingsManager.CURRENT;
+ TimingsManager.CURRENT = this;
+ unsafe = true;
+ }
+ return this;
+ }
+
+ @Override
+ public void stopTimingUnsafe() {
+ if (enabled && timingDepth > 0 && --timingDepth == 0 && start != 0) {
+ addDiff(System.nanoTime() - start);
+ start = 0;
+ unsafe = false;
+ }
+ }
+
@Override
public Timing startTiming(boolean assertThread) {
if (enabled && (ThreadAssertion.isMainThread() || Bukkit.isPrimaryThread()) /*&& ++timingDepth == 1*/) {
@@ -126,6 +147,7 @@ class TimingHandler implements Timing {
if (enabled && timingDepth > 0 && (ThreadAssertion.isMainThread() || Bukkit.isPrimaryThread()) /*&& --timingDepth == 0 && start != 0*/) {
if (AkarinGlobalConfig.lazyThreadAssertion) ThreadAssertion.setMainThread(false);
if (--timingDepth != 0 || start == 0) return;
+ unsafe = false;
// Akarin end
addDiff(System.nanoTime() - start);
start = 0;
@@ -196,7 +218,7 @@ class TimingHandler implements Timing {
*/
@Override
public void close() {
- stopTimingIfSync();
+ if (unsafe) stopTimingUnsafe(); else stopTimingIfSync(); // Akarin
}
public boolean isSpecial() {
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 2bcbf8902..9b64b9456 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -299,7 +299,7 @@ public class Chunk implements IChunkAccess {
}
private void g(boolean flag) {
- this.world.methodProfiler.enter("recheckGaps");
+ //this.world.methodProfiler.enter("recheckGaps"); // Akarin - remove caller
if (this.areNeighborsLoaded(1)) { // Paper
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
@@ -326,7 +326,7 @@ public class Chunk implements IChunkAccess {
}
if (flag) {
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
return;
}
}
@@ -336,7 +336,7 @@ public class Chunk implements IChunkAccess {
this.l = false;
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
private void c(int i, int j, int k) {
diff --git a/src/main/java/net/minecraft/server/ChunkMap.java b/src/main/java/net/minecraft/server/ChunkMap.java
index b6cbfee4a..fdac4ca90 100644
--- a/src/main/java/net/minecraft/server/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/ChunkMap.java
@@ -14,7 +14,7 @@ public class ChunkMap extends Long2ObjectOpenHashMap {
}
public Chunk put(long i, Chunk chunk) {
- chunk.world.timings.syncChunkLoadPostTimer.startTiming(); // Paper
+ chunk.world.timings.syncChunkLoadPostTimer.startTiming(true); // Paper // Akarin
//org.spigotmc.AsyncCatcher.catchOp("Async Chunk put"); // Paper // Akarin - comment
lastChunkByPos = chunk; // Paper
// Paper start
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 781e06877..48d2e29dc 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -179,7 +179,7 @@ public class ChunkProviderServer implements IChunkProvider {
this.asyncTaskHandler.postToMainThread(chunk::addEntities);
return chunk;
} else if (flag1) {
- try (co.aikar.timings.Timing timing = world.timings.chunkGeneration.startTiming()) { // Paper
+ try (co.aikar.timings.Timing timing = world.timings.chunkGeneration.startTiming(true)) { // Paper // Akarin
this.batchScheduler.b();
this.batchScheduler.a(new ChunkCoordIntPair(i, j));
CompletableFuture completablefuture = this.batchScheduler.c();
diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java
index 61471bf9f..c6cbb9919 100644
--- a/src/main/java/net/minecraft/server/CommandDispatcher.java
+++ b/src/main/java/net/minecraft/server/CommandDispatcher.java
@@ -172,7 +172,7 @@ public class CommandDispatcher {
stringreader.skip();
}
- commandlistenerwrapper.getServer().methodProfiler.enter(s);
+ //commandlistenerwrapper.getServer().methodProfiler.enter(s); // Akarin - remove caller
byte b0;
@@ -236,7 +236,7 @@ public class CommandDispatcher {
return b1;
}
} finally {
- commandlistenerwrapper.getServer().methodProfiler.exit();
+ //commandlistenerwrapper.getServer().methodProfiler.exit(); // Akarin - remove caller
}
return b0;
diff --git a/src/main/java/net/minecraft/server/CustomFunctionData.java b/src/main/java/net/minecraft/server/CustomFunctionData.java
index 6b417be1d..05606644a 100644
--- a/src/main/java/net/minecraft/server/CustomFunctionData.java
+++ b/src/main/java/net/minecraft/server/CustomFunctionData.java
@@ -61,7 +61,7 @@ public class CustomFunctionData implements ITickable, IResourcePackListener {
public void tick() {
MinecraftKey minecraftkey = CustomFunctionData.d;
- this.server.methodProfiler.a(minecraftkey::toString);
+ //this.server.methodProfiler.a(minecraftkey::toString); // Akarin - remove caller
Iterator iterator = this.k.iterator();
while (iterator.hasNext()) {
@@ -70,7 +70,7 @@ public class CustomFunctionData implements ITickable, IResourcePackListener {
this.a(customfunction, this.f());
}
- this.server.methodProfiler.exit();
+ //this.server.methodProfiler.exit(); // Akarin - remove caller
if (this.l) {
this.l = false;
Collection collection = this.g().b(CustomFunctionData.e).a();
@@ -85,7 +85,7 @@ public class CustomFunctionData implements ITickable, IResourcePackListener {
this.a(customfunction1, this.f());
}
- this.server.methodProfiler.exit();
+ //this.server.methodProfiler.exit(); // Akarin - remove caller
}
}
@@ -118,7 +118,7 @@ public class CustomFunctionData implements ITickable, IResourcePackListener {
this.server.methodProfiler.a(customfunctiondata_a::toString);
customfunctiondata_a.a(this.h, i);
} finally {
- this.server.methodProfiler.exit();
+ //this.server.methodProfiler.exit(); // Akarin - remove caller
}
++j;
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 5902f07e5..443cae10d 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -396,7 +396,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
this.E();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
}
// CraftBukkit end
@@ -456,7 +456,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
this.E();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
*/
@@ -499,7 +499,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
this.justCreated = false;
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
// Paper start
@@ -806,7 +806,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("rest");
this.recalcPosition();
this.positionChanged = d7 != d0 || d9 != d2;
@@ -939,7 +939,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.fireTicks = -this.getMaxFireTicks();
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
}
@@ -2602,7 +2602,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
// Need to make sure the profiler state is reset afterwards (but we still want to time the call)
Entity entity = this.teleportTo(exit, true);
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
return entity;
} else {
return null;
@@ -2694,10 +2694,10 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
this.dead = true;
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
worldserver.p();
worldserver1.p();
- // this.world.methodProfiler.exit(); // CraftBukkit: Moved up to keep balanced
+ // //this.world.methodProfiler.exit(); // Akarin - remove caller // CraftBukkit: Moved up to keep balanced
return entity;
} else {
return null;
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 3059682a4..8d7233716 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -205,7 +205,7 @@ public abstract class EntityInsentient extends EntityLiving {
this.A();
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
protected void c(DamageSource damagesource) {
@@ -540,7 +540,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
protected void a(EntityItem entityitem) {
@@ -662,7 +662,7 @@ public abstract class EntityInsentient extends EntityLiving {
++this.ticksFarFromPlayer;
this.world.methodProfiler.enter("checkDespawn");
this.I();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
// Spigot Start
if ( this.fromMobSpawner )
{
@@ -677,19 +677,19 @@ public abstract class EntityInsentient extends EntityLiving {
// Spigot End
this.world.methodProfiler.enter("sensing");
this.bC.a();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("targetSelector");
this.targetSelector.doTick();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("goalSelector");
this.goalSelector.doTick();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("navigation");
this.navigation.d();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("mob tick");
this.mobTick();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
if (this.isPassenger() && this.getVehicle() instanceof EntityInsentient) {
EntityInsentient entityinsentient = (EntityInsentient) this.getVehicle();
@@ -704,8 +704,8 @@ public abstract class EntityInsentient extends EntityLiving {
this.lookController.a();
this.world.methodProfiler.exitEnter("jump");
this.h.b();
- this.world.methodProfiler.exit();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
protected void mobTick() {}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 5b1a357b0..de4de810e 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -318,7 +318,7 @@ public abstract class EntityLiving extends Entity {
this.aT = this.aS;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
// CraftBukkit start
@@ -2166,7 +2166,7 @@ public abstract class EntityLiving extends Entity {
this.ba += (f3 - this.ba) * 0.3F;
this.world.methodProfiler.enter("headTurn");
f2 = this.e(f1, f2);
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("rangeChecks");
while (this.yaw - this.lastYaw < -180.0F) {
@@ -2201,7 +2201,7 @@ public abstract class EntityLiving extends Entity {
this.aT += 360.0F;
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.bb += f2;
if (this.dc()) {
++this.bv;
@@ -2336,10 +2336,10 @@ public abstract class EntityLiving extends Entity {
} else if (this.cP()) {
this.world.methodProfiler.enter("newAi");
this.doTick();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("jump");
if (this.bg) {
if (this.W > 0.0D && (!this.onGround || this.W > 0.4D)) {
@@ -2354,7 +2354,7 @@ public abstract class EntityLiving extends Entity {
this.bJ = 0;
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("travel");
this.bh *= 0.98F;
this.bj *= 0.98F;
@@ -2363,7 +2363,7 @@ public abstract class EntityLiving extends Entity {
AxisAlignedBB axisalignedbb = this.getBoundingBox();
this.a(this.bh, this.bi, this.bj);
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
this.world.methodProfiler.enter("push");
if (this.bw > 0) {
--this.bw;
@@ -2371,7 +2371,7 @@ public abstract class EntityLiving extends Entity {
}
this.cN();
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
private void n() {
diff --git a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
index f83a695a1..ac9c0bea0 100644
--- a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
+++ b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
@@ -244,7 +244,7 @@ public abstract class EntityMinecartAbstract extends Entity implements INamableT
--this.portalCooldown;
}
- this.world.methodProfiler.exit();
+ //this.world.methodProfiler.exit(); // Akarin - remove caller
}
*/
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index eabdec579..bf3e33a18 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -926,7 +926,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
public void t() {}
protected void a(BooleanSupplier booleansupplier) {
- co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTimingUnsafe(); // Paper // Akarin
this.slackActivityAccountant.tickStarted(); // Spigot
long i = SystemUtils.getMonotonicNanos(); long startTime = i; // Paper
@@ -936,7 +936,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
this.methodProfiler.a(this.ticks);
}
- this.methodProfiler.enter("root");
+ //this.methodProfiler.enter(* // Akarin - remove caller
this.b(booleansupplier);
if (i - this.Y >= 5000000000L) {
this.Y = i;
@@ -952,7 +952,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
this.m.b().a(agameprofile);
}
- this.methodProfiler.enter("save");
+ //this.methodProfiler.enter(* // Akarin - remove caller
serverAutoSave = (autosavePeriod > 0 && this.ticks % autosavePeriod == 0); // Paper
int playerSaveInterval = com.destroystokyo.paper.PaperConfig.playerAutoSaveRate;
@@ -977,7 +977,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
this.methodProfiler.exit();
//} // Paper - Incremental Auto Saving
- this.methodProfiler.enter("snooper");
+ //this.methodProfiler.enter(* // Akarin - remove caller
if (getSnooperEnabled() && !this.snooper.d() && this.ticks > 100) { // Spigot
this.snooper.a();
}
@@ -987,7 +987,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
}
this.methodProfiler.exit();
- this.methodProfiler.enter("tallying");
+ //this.methodProfiler.enter(* // Akarin - remove caller
long l = this.d[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i;
this.ap = this.ap * 0.8F + (float) l / 1000000.0F * 0.19999999F;
@@ -997,15 +997,15 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
PaperLightingQueue.processQueue(startTime); // Paper
expiringMaps.removeIf(ExpiringMap::clean); // Paper
this.slackActivityAccountant.tickEnded(l); // Spigot
- co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTimingUnsafe(); // Paper // Akarin
}
public void b(BooleanSupplier booleansupplier) {
- MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Paper
+ MinecraftTimings.bukkitSchedulerTimer.startTimingUnsafe(); // Paper // Akarin
this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
- MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Paper
- MinecraftTimings.minecraftSchedulerTimer.startTiming(); // Paper
- this.methodProfiler.enter("jobs");
+ MinecraftTimings.bukkitSchedulerTimer.stopTimingUnsafe(); // Paper // Akarin
+ MinecraftTimings.minecraftSchedulerTimer.startTimingUnsafe(); // Paper // Akarin
+ //this.methodProfiler.enter(* // Akarin - remove caller
FutureTask futuretask;
@@ -1013,27 +1013,27 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
SystemUtils.a(futuretask, MinecraftServer.LOGGER);
}
PaperAsyncChunkProvider.processMainThreadQueue(this); // Paper
- MinecraftTimings.minecraftSchedulerTimer.stopTiming(); // Paper
+ MinecraftTimings.minecraftSchedulerTimer.stopTimingUnsafe(); // Paper // Akarin
this.methodProfiler.exitEnter("commandFunctions");
- MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot
+ MinecraftTimings.commandFunctionsTimer.startTimingUnsafe(); // Spigot // Akarin
this.getFunctionData().tick();
- MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot
+ MinecraftTimings.commandFunctionsTimer.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exitEnter("levels");
// CraftBukkit start
// Run tasks that are waiting on processing
- MinecraftTimings.processQueueTimer.startTiming(); // Spigot
+ MinecraftTimings.processQueueTimer.startTimingUnsafe(); // Spigot // Akarin
while (!processQueue.isEmpty()) {
processQueue.remove().run();
}
- MinecraftTimings.processQueueTimer.stopTiming(); // Spigot
+ MinecraftTimings.processQueueTimer.stopTimingUnsafe(); // Spigot // Akarin
- MinecraftTimings.chunkIOTickTimer.startTiming(); // Spigot
+ MinecraftTimings.chunkIOTickTimer.startTimingUnsafe(); // Spigot // Akarin
org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick();
- MinecraftTimings.chunkIOTickTimer.stopTiming(); // Spigot
+ MinecraftTimings.chunkIOTickTimer.stopTimingUnsafe(); // Spigot // Akarin
- MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot
+ MinecraftTimings.timeUpdateTimer.startTimingUnsafe(); // Spigot // Akarin
// Send time updates to everyone, it will get the right time from the world the player is in.
// Paper start - optimize time updates
for (final WorldServer world : this.getWorlds()) {
@@ -1053,7 +1053,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
}
}
// Paper end
- MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot
+ MinecraftTimings.timeUpdateTimer.stopTimingUnsafe(); // Spigot // Akarin
// WorldServer worldserver; // CraftBukkit - dropped down
long i;
@@ -1071,20 +1071,20 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
});
/* Drop global time updates
if (this.ticks % 20 == 0) {
- this.methodProfiler.enter("timeSync");
+ //this.methodProfiler.enter(* // Akarin - remove caller
this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager());
this.methodProfiler.exit();
}
// CraftBukkit end */
- this.methodProfiler.enter("tick");
+ //this.methodProfiler.enter(* // Akarin - remove caller
CrashReport crashreport;
try {
- worldserver.timings.doTick.startTiming(); // Spigot
+ worldserver.timings.doTick.startTimingUnsafe(); // Spigot // Akarin
worldserver.doTick(booleansupplier);
- worldserver.timings.doTick.stopTiming(); // Spigot
+ worldserver.timings.doTick.stopTimingUnsafe(); // Spigot // Akarin
} catch (Throwable throwable) {
// Spigot Start
try {
@@ -1098,9 +1098,9 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
}
try {
- worldserver.timings.tickEntities.startTiming(); // Spigot
+ worldserver.timings.tickEntities.startTimingUnsafe(); // Spigot // Akarin
worldserver.tickEntities();
- worldserver.timings.tickEntities.stopTiming(); // Spigot
+ worldserver.timings.tickEntities.stopTimingUnsafe(); // Spigot // Akarin
} catch (Throwable throwable1) {
// Spigot Start
try {
@@ -1114,7 +1114,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
}
this.methodProfiler.exit();
- this.methodProfiler.enter("tracker");
+ //this.methodProfiler.enter(* // Akarin - remove caller
worldserver.getTracker().updatePlayers();
this.methodProfiler.exit();
this.methodProfiler.exit();
@@ -1123,20 +1123,20 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
}
this.methodProfiler.exitEnter("connection");
- MinecraftTimings.connectionTimer.startTiming(); // Spigot
+ MinecraftTimings.connectionTimer.startTimingUnsafe(); // Spigot // Akarin
this.getServerConnection().c();
- MinecraftTimings.connectionTimer.stopTiming(); // Spigot
+ MinecraftTimings.connectionTimer.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exitEnter("players");
- MinecraftTimings.playerListTimer.startTiming(); // Spigot
+ MinecraftTimings.playerListTimer.startTimingUnsafe(); // Spigot // Akarin
this.playerList.tick();
- MinecraftTimings.playerListTimer.stopTiming(); // Spigot
+ MinecraftTimings.playerListTimer.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exitEnter("tickables");
- MinecraftTimings.tickablesTimer.startTiming(); // Spigot
+ MinecraftTimings.tickablesTimer.startTimingUnsafe(); // Spigot // Akarin
for (int j = 0; j < this.k.size(); ++j) {
((ITickable) this.k.get(j)).tick();
}
- MinecraftTimings.tickablesTimer.stopTiming(); // Spigot
+ MinecraftTimings.tickablesTimer.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exit();
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index b7dda8e28..90eb26356 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -85,7 +85,7 @@ public class PlayerChunkMap {
int j;
if (i - this.k > 8000L) {
- try (Timing ignored = world.timings.doChunkMapUpdate.startTiming()) { // Paper
+ try (Timing ignored = world.timings.doChunkMapUpdate.startTimingUnsafe()) { // Paper // Akarin
this.k = i;
for (j = 0; j < this.i.size(); ++j) {
@@ -97,7 +97,7 @@ public class PlayerChunkMap {
}
if (!this.f.isEmpty()) {
- try (Timing ignored = world.timings.doChunkMapToUpdate.startTiming()) { // Paper
+ try (Timing ignored = world.timings.doChunkMapToUpdate.startTimingUnsafe()) { // Paper // Akarin
Iterator iterator = this.f.iterator();
while (iterator.hasNext()) {
@@ -111,7 +111,7 @@ public class PlayerChunkMap {
if (this.l && i % 4L == 0L) {
this.l = false;
- try (Timing ignored = world.timings.doChunkMapSortMissing.startTiming()) { // Paper
+ try (Timing ignored = world.timings.doChunkMapSortMissing.startTimingUnsafe()) { // Paper // Akarin
Collections.sort(this.h, (playerchunk1, playerchunk2) -> {
return ComparisonChain.start().compare(playerchunk1.g(), playerchunk2.g()).result();
});
@@ -120,7 +120,7 @@ public class PlayerChunkMap {
if (this.m && i % 4L == 2L) {
this.m = false;
- try (Timing ignored = world.timings.doChunkMapSortSendToPlayers.startTiming()) { // Paper
+ try (Timing ignored = world.timings.doChunkMapSortSendToPlayers.startTimingUnsafe()) { // Paper // Akarin
Collections.sort(this.g, (playerchunk1, playerchunk2) -> {
return ComparisonChain.start().compare(playerchunk1.g(), playerchunk2.g()).result();
});
@@ -128,7 +128,7 @@ public class PlayerChunkMap {
}
if (!this.h.isEmpty()) {
- try (Timing ignored = world.timings.doChunkMapPlayersNeedingChunks.startTiming()) { // Paper
+ try (Timing ignored = world.timings.doChunkMapPlayersNeedingChunks.startTimingUnsafe()) { // Paper // Akarin
// Spigot start
org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant;
activityAccountant.startActivity(0.5);
@@ -171,7 +171,7 @@ public class PlayerChunkMap {
if (!this.g.isEmpty()) {
j = world.paperConfig.maxChunkSendsPerTick; // Paper
- try (Timing ignored = world.timings.doChunkMapPendingSendToPlayers.startTiming()) { // Paper
+ try (Timing ignored = world.timings.doChunkMapPendingSendToPlayers.startTimingUnsafe()) { // Paper // Akarin
Iterator iterator2 = this.g.iterator();
while (iterator2.hasNext()) {
@@ -189,7 +189,7 @@ public class PlayerChunkMap {
}
if (this.managedPlayers.isEmpty()) {
- try (Timing ignored = world.timings.doChunkMapUnloadChunks.startTiming()) { // Paper
+ try (Timing ignored = world.timings.doChunkMapUnloadChunks.startTimingUnsafe()) { // Paper // Akarin
WorldProvider worldprovider = this.world.worldProvider;
if (!worldprovider.canRespawn() && !this.world.savingDisabled) { // Paper - respect saving disabled setting
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 1132bcc8a..ba3631646 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -442,7 +442,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
IBlockData iblockdata2 = this.getType(blockposition);
if (iblockdata2.b(this, blockposition) != iblockdata1.b(this, blockposition) || iblockdata2.e() != iblockdata1.e()) {
- this.methodProfiler.enter("checkLight");
+ //this.methodProfiler.enter(* // Akarin - remove caller
chunk.runOrQueueLightUpdate(() -> this.r(blockposition)); // Paper - Queue light update
this.methodProfiler.exit();
}
@@ -1246,8 +1246,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
public void tickEntities() {
- this.methodProfiler.enter("entities");
- this.methodProfiler.enter("global");
+ //this.methodProfiler.enter(* // Akarin - remove caller
+ //this.methodProfiler.enter(* // Akarin - remove caller
Entity entity;
int i;
@@ -1282,7 +1282,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
this.methodProfiler.exitEnter("remove");
- timings.entityRemoval.startTiming(); // Paper
+ timings.entityRemoval.startTimingUnsafe(); // Paper // Akarin
this.entityList.removeAll(this.g);
int j;
@@ -1306,14 +1306,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.g.clear();
this.p_();
- timings.entityRemoval.stopTiming(); // Paper
+ timings.entityRemoval.stopTimingUnsafe(); // Paper // Akarin
this.methodProfiler.exitEnter("regular");
CrashReport crashreport1;
CrashReportSystemDetails crashreportsystemdetails1;
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
- timings.entityTick.startTiming(); // Spigot
+ timings.entityTick.startTimingUnsafe(); // Spigot // Akarin
guardEntityList = true; // Spigot
// CraftBukkit start - Use field for loop variable
co.aikar.timings.TimingHistory.entityTicks += this.entityList.size(); // Paper
@@ -1335,7 +1335,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
entity.stopRiding();
}
- this.methodProfiler.enter("tick");
+ //this.methodProfiler.enter(* // Akarin - remove caller
if (!entity.dead && !(entity instanceof EntityPlayer)) {
try {
entity.tickTimer.startTiming(); // Paper
@@ -1355,7 +1355,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
this.methodProfiler.exit();
- this.methodProfiler.enter("remove");
+ //this.methodProfiler.enter(* // Akarin - remove caller
if (entity.dead) {
// Paper start
/*
@@ -1379,9 +1379,9 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
guardEntityList = false; // Spigot
- timings.entityTick.stopTiming(); // Spigot
+ timings.entityTick.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exitEnter("blockEntities");
- timings.tileEntityTick.startTiming(); // Spigot
+ timings.tileEntityTick.startTimingUnsafe(); // Spigot // Akarin
if (!this.tileEntityListUnload.isEmpty()) {
// Paper start - Use alternate implementation with faster contains
java.util.Set toRemove = com.koloboke.collect.set.hash.HashObjSets.getDefaultFactory().withNullKeyAllowed(true).withEquivalence(com.koloboke.collect.Equivalence.identity()).newImmutableSet(tileEntityListUnload); // Akarin - koloboke
@@ -1457,8 +1457,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
}
- timings.tileEntityTick.stopTiming(); // Spigot
- timings.tileEntityPending.startTiming(); // Spigot
+ timings.tileEntityTick.stopTimingUnsafe(); // Spigot // Akarin
+ timings.tileEntityPending.startTimingUnsafe(); // Spigot // Akarin
this.J = false;
this.methodProfiler.exitEnter("pendingBlockEntities");
if (!this.c.isEmpty()) {
@@ -1491,7 +1491,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.c.clear();
}
- timings.tileEntityPending.stopTiming(); // Spigot
+ timings.tileEntityPending.stopTimingUnsafe(); // Spigot // Akarin
co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityListTick.size(); // Paper
this.methodProfiler.exit();
this.methodProfiler.exit();
@@ -1572,7 +1572,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
}
- this.methodProfiler.enter("chunkCheck");
+ //this.methodProfiler.enter(* // Akarin - remove caller
if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) {
entity.locX = entity.N;
}
@@ -2259,7 +2259,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
int i = 0;
int j = 0;
- this.methodProfiler.enter("getBrightness");
+ //this.methodProfiler.enter(* // Akarin - remove caller
int k = this.getBrightness(enumskyblock, blockposition);
int l = this.a(blockposition, enumskyblock);
int i1 = blockposition.getX();
@@ -2342,7 +2342,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
this.methodProfiler.exit();
- this.methodProfiler.enter("checkedPosition < toCheckCount");
+ //this.methodProfiler.enter(* // Akarin - remove caller
while (i < j) {
l1 = this.E[i++];
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index e9b321197..0d2ef8555 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -267,7 +267,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
this.i();
}
- this.methodProfiler.enter("spawner");
+ //this.methodProfiler.enter(* // Akarin - remove caller
// CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals
long time = this.worldData.getTime();
if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) {
@@ -278,7 +278,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
// CraftBukkit end
}
- timings.doChunkUnload.startTiming(); // Spigot
+ timings.doChunkUnload.startTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exitEnter("chunkSource");
this.chunkProvider.unloadChunks(booleansupplier);
int j = this.a(1.0F);
@@ -292,37 +292,37 @@ public class WorldServer extends World implements IAsyncTaskHandler {
this.worldData.setDayTime(this.worldData.getDayTime() + 1L);
}
- timings.doChunkUnload.stopTiming(); // Spigot
+ timings.doChunkUnload.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exitEnter("tickPending");
- timings.scheduledBlocks.startTiming(); // Paper
+ timings.scheduledBlocks.startTimingUnsafe(); // Paper // Akarin
this.q();
- timings.scheduledBlocks.stopTiming(); // Paper
+ timings.scheduledBlocks.stopTimingUnsafe(); // Paper // Akarin
this.methodProfiler.exitEnter("tickBlocks");
- timings.chunkTicks.startTiming(); // Paper
+ timings.chunkTicks.startTimingUnsafe(); // Paper // Akarin
this.n_();
- timings.chunkTicks.stopTiming(); // Paper
+ timings.chunkTicks.stopTimingUnsafe(); // Paper // Akarin
this.methodProfiler.exitEnter("chunkMap");
- timings.doChunkMap.startTiming(); // Spigot
+ timings.doChunkMap.startTimingUnsafe(); // Spigot // Akarin
this.manager.flush();
- timings.doChunkMap.stopTiming(); // Spigot
+ timings.doChunkMap.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exitEnter("village");
- timings.doVillages.startTiming(); // Spigot
+ timings.doVillages.startTimingUnsafe(); // Spigot // Akarin
this.villages.tick();
this.siegeManager.a();
- timings.doVillages.stopTiming(); // Spigot
+ timings.doVillages.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exitEnter("portalForcer");
- timings.doPortalForcer.startTiming(); // Spigot
+ timings.doPortalForcer.startTimingUnsafe(); // Spigot // Akarin
this.portalTravelAgent.a(this.getTime());
- timings.doPortalForcer.stopTiming(); // Spigot
+ timings.doPortalForcer.stopTimingUnsafe(); // Spigot // Akarin
this.methodProfiler.exit();
- timings.doSounds.startTiming(); // Spigot
+ timings.doSounds.startTimingUnsafe(); // Spigot // Akarin
this.an();
- timings.doSounds.stopTiming(); // Spigot
+ timings.doSounds.stopTimingUnsafe(); // Spigot // Akarin
this.P = false;
- timings.doChunkGC.startTiming();// Spigot
+ timings.doChunkGC.startTimingUnsafe();// Spigot // Akarin
this.getWorld().processChunkGC(); // CraftBukkit
- timings.doChunkGC.stopTiming(); // Spigot
+ timings.doChunkGC.stopTimingUnsafe(); // Spigot // Akarin
}
public boolean j_() {
@@ -442,7 +442,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
}
protected void l() {
- this.methodProfiler.enter("playerCheckLight");
+ //this.methodProfiler.enter(* // Akarin - remove caller
if (spigotConfig.randomLightUpdates && !this.players.isEmpty()) { // Spigot
int i = this.random.nextInt(this.players.size());
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
@@ -470,10 +470,10 @@ public class WorldServer extends World implements IAsyncTaskHandler {
boolean flag = this.isRaining();
boolean flag1 = this.Y();
- this.methodProfiler.enter("pollingChunks");
+ //this.methodProfiler.enter(* // Akarin - remove caller
for (Iterator iterator1 = this.manager.b(); iterator1.hasNext(); this.methodProfiler.exit()) {
- this.methodProfiler.enter("getChunk");
+ //this.methodProfiler.enter(* // Akarin - remove caller
Chunk chunk = (Chunk) iterator1.next();
int j = chunk.locX * 16;
int k = chunk.locZ * 16;
@@ -548,7 +548,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
IBlockData iblockdata = chunksection.getType(i2, k2, j2);
Fluid fluid = chunksection.b(i2, k2, j2);
- this.methodProfiler.enter("randomTick");
+ //this.methodProfiler.enter(* // Akarin - remove caller
if (iblockdata.t()) {
iblockdata.b((World) this, new BlockPosition(i2 + j, k2 + chunksection.getYPosition(), j2 + k), this.random);
}
@@ -617,7 +617,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
entity.stopRiding();
}
- this.methodProfiler.enter("tick");
+ //this.methodProfiler.enter(* // Akarin - remove caller
if (!entity.dead) {
try {
this.g(entity);
@@ -631,7 +631,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
}
this.methodProfiler.exit();
- this.methodProfiler.enter("remove");
+ //this.methodProfiler.enter(* // Akarin - remove caller
if (entity.dead) {
int j = entity.chunkX;
int k = entity.chunkZ;