mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
Upstream has released updates that appear to apply and compile correctly Purpur Changes: PurpurMC/Purpur@11c030a8 Updated Upstream (Paper)
5153 lines
220 KiB
Diff
5153 lines
220 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sun, 2 Feb 2025 14:43:32 +0300
|
|
Subject: [PATCH] Completely remove Mojang profiler
|
|
|
|
|
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
|
index e03e2b976870ecda1e5e3c53d47e7978fe5670ed..758ce439d2e10e6ef42a58d147a77093667e0acd 100644
|
|
--- a/net/minecraft/commands/Commands.java
|
|
+++ b/net/minecraft/commands/Commands.java
|
|
@@ -58,7 +58,6 @@ import net.minecraft.server.commands.CloneCommands;
|
|
import net.minecraft.server.commands.DamageCommand;
|
|
import net.minecraft.server.commands.DataPackCommand;
|
|
import net.minecraft.server.commands.DeOpCommands;
|
|
-import net.minecraft.server.commands.DebugCommand;
|
|
import net.minecraft.server.commands.DebugConfigCommand;
|
|
import net.minecraft.server.commands.DebugMobSpawningCommand;
|
|
import net.minecraft.server.commands.DebugPathCommand;
|
|
@@ -139,7 +138,6 @@ import net.minecraft.server.commands.WorldBorderCommand;
|
|
import net.minecraft.server.commands.data.DataCommands;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.tags.TagKey;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
import net.minecraft.util.profiling.jfr.JvmProfiler;
|
|
import net.minecraft.world.flag.FeatureFlagSet;
|
|
import net.minecraft.world.flag.FeatureFlags;
|
|
@@ -191,7 +189,6 @@ public class Commands {
|
|
DamageCommand.register(this.dispatcher, context);
|
|
DataCommands.register(this.dispatcher);
|
|
DataPackCommand.register(this.dispatcher, context);
|
|
- DebugCommand.register(this.dispatcher);
|
|
DefaultGameModeCommands.register(this.dispatcher);
|
|
DialogCommand.register(this.dispatcher, context);
|
|
DifficultyCommand.register(this.dispatcher);
|
|
@@ -363,7 +360,6 @@ public class Commands {
|
|
org.spigotmc.AsyncCatcher.catchOp("Cannot perform command async");
|
|
// Paper end
|
|
CommandSourceStack commandSourceStack = parseResults.getContext().getSource();
|
|
- Profiler.get().push(() -> "/" + command);
|
|
ContextChain<CommandSourceStack> contextChain = finishParsing(parseResults, command, commandSourceStack);
|
|
|
|
try {
|
|
@@ -401,8 +397,6 @@ public class Commands {
|
|
commandSourceStack.sendFailure(Component.literal(Util.describeError(var12)));
|
|
LOGGER.error("'/{}' threw an exception", command, var12);
|
|
}
|
|
- } finally {
|
|
- Profiler.get().pop();
|
|
}
|
|
}
|
|
|
|
@@ -459,7 +453,7 @@ public class Commands {
|
|
int max = Math.max(1, server.getGameRules().getInt(GameRules.RULE_MAX_COMMAND_CHAIN_LENGTH));
|
|
int _int = server.getGameRules().getInt(GameRules.RULE_MAX_COMMAND_FORK_COUNT);
|
|
|
|
- try (ExecutionContext<CommandSourceStack> executionContext1 = new ExecutionContext<>(max, _int, Profiler.get())) {
|
|
+ try (ExecutionContext<CommandSourceStack> executionContext1 = new ExecutionContext<>(max, _int)) {
|
|
CURRENT_EXECUTION_CONTEXT.set(executionContext1);
|
|
contextConsumer.accept(executionContext1);
|
|
executionContext1.runCommandQueue();
|
|
diff --git a/net/minecraft/commands/execution/ExecutionContext.java b/net/minecraft/commands/execution/ExecutionContext.java
|
|
index 18c7fff36ca26a659fa8ea022c93ea65f3199181..d2627a450f2481714aa1a9ecc9153a95bdab8e89 100644
|
|
--- a/net/minecraft/commands/execution/ExecutionContext.java
|
|
+++ b/net/minecraft/commands/execution/ExecutionContext.java
|
|
@@ -12,7 +12,6 @@ import net.minecraft.commands.ExecutionCommandSource;
|
|
import net.minecraft.commands.execution.tasks.BuildContexts;
|
|
import net.minecraft.commands.execution.tasks.CallFunction;
|
|
import net.minecraft.commands.functions.InstantiatedFunction;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import org.slf4j.Logger;
|
|
|
|
public class ExecutionContext<T> implements AutoCloseable {
|
|
@@ -20,7 +19,6 @@ public class ExecutionContext<T> implements AutoCloseable {
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
private final int commandLimit;
|
|
private final int forkLimit;
|
|
- private final ProfilerFiller profiler;
|
|
@Nullable
|
|
private TraceCallbacks tracer;
|
|
private int commandQuota;
|
|
@@ -29,10 +27,9 @@ public class ExecutionContext<T> implements AutoCloseable {
|
|
private final List<CommandQueueEntry<T>> newTopCommands = new ObjectArrayList<>();
|
|
private int currentFrameDepth;
|
|
|
|
- public ExecutionContext(int commandLimit, int forkLimit, ProfilerFiller profiler) {
|
|
+ public ExecutionContext(int commandLimit, int forkLimit) {
|
|
this.commandLimit = commandLimit;
|
|
this.forkLimit = forkLimit;
|
|
- this.profiler = profiler;
|
|
this.commandQuota = commandLimit;
|
|
}
|
|
|
|
@@ -131,10 +128,6 @@ public class ExecutionContext<T> implements AutoCloseable {
|
|
return this.tracer;
|
|
}
|
|
|
|
- public ProfilerFiller profiler() {
|
|
- return this.profiler;
|
|
- }
|
|
-
|
|
public int forkLimit() {
|
|
return this.forkLimit;
|
|
}
|
|
diff --git a/net/minecraft/commands/execution/tasks/BuildContexts.java b/net/minecraft/commands/execution/tasks/BuildContexts.java
|
|
index 569abbea01f585990d2017c68580257275bbb06d..824ccbfa77cd1135d409f5f46e6ae5422d323036 100644
|
|
--- a/net/minecraft/commands/execution/tasks/BuildContexts.java
|
|
+++ b/net/minecraft/commands/execution/tasks/BuildContexts.java
|
|
@@ -42,51 +42,47 @@ public class BuildContexts<T extends ExecutionCommandSource<T>> {
|
|
ChainModifiers chainModifiers1 = chainModifiers;
|
|
List<T> list = sources;
|
|
if (contextChain.getStage() != Stage.EXECUTE) {
|
|
- context.profiler().push(() -> "prepare " + this.commandInput);
|
|
+ // DivineMC start - Completely remove Mojang profiler
|
|
+ for (int forkLimit = context.forkLimit(); contextChain.getStage() != Stage.EXECUTE; contextChain = contextChain.nextStage()) {
|
|
+ CommandContext<T> topContext = contextChain.getTopContext();
|
|
+ if (topContext.isForked()) {
|
|
+ chainModifiers1 = chainModifiers1.setForked();
|
|
+ }
|
|
|
|
- try {
|
|
- for (int forkLimit = context.forkLimit(); contextChain.getStage() != Stage.EXECUTE; contextChain = contextChain.nextStage()) {
|
|
- CommandContext<T> topContext = contextChain.getTopContext();
|
|
- if (topContext.isForked()) {
|
|
- chainModifiers1 = chainModifiers1.setForked();
|
|
- }
|
|
+ RedirectModifier<T> redirectModifier = topContext.getRedirectModifier();
|
|
+ if (redirectModifier instanceof CustomModifierExecutor.ModifierAdapter<T> customModifierExecutor) {
|
|
+ customModifierExecutor.apply(originalSource, list, contextChain, chainModifiers1, ExecutionControl.create(context, frame));
|
|
+ return;
|
|
+ }
|
|
|
|
- RedirectModifier<T> redirectModifier = topContext.getRedirectModifier();
|
|
- if (redirectModifier instanceof CustomModifierExecutor.ModifierAdapter<T> customModifierExecutor) {
|
|
- customModifierExecutor.apply(originalSource, list, contextChain, chainModifiers1, ExecutionControl.create(context, frame));
|
|
- return;
|
|
- }
|
|
+ if (redirectModifier != null) {
|
|
+ context.incrementCost();
|
|
+ boolean isForked = chainModifiers1.isForked();
|
|
+ List<T> list1 = new ObjectArrayList<>();
|
|
+
|
|
+ for (T executionCommandSource : list) {
|
|
+ try {
|
|
+ Collection<T> collection = ContextChain.runModifier(
|
|
+ topContext, executionCommandSource, (commandContext, flag, i) -> {}, isForked
|
|
+ );
|
|
+ if (list1.size() + collection.size() >= forkLimit) {
|
|
+ originalSource.handleError(ERROR_FORK_LIMIT_REACHED.create(forkLimit), isForked, context.tracer());
|
|
+ return;
|
|
+ }
|
|
|
|
- if (redirectModifier != null) {
|
|
- context.incrementCost();
|
|
- boolean isForked = chainModifiers1.isForked();
|
|
- List<T> list1 = new ObjectArrayList<>();
|
|
-
|
|
- for (T executionCommandSource : list) {
|
|
- try {
|
|
- Collection<T> collection = ContextChain.runModifier(
|
|
- topContext, executionCommandSource, (commandContext, flag, i) -> {}, isForked
|
|
- );
|
|
- if (list1.size() + collection.size() >= forkLimit) {
|
|
- originalSource.handleError(ERROR_FORK_LIMIT_REACHED.create(forkLimit), isForked, context.tracer());
|
|
- return;
|
|
- }
|
|
-
|
|
- list1.addAll(collection);
|
|
- } catch (CommandSyntaxException var20) {
|
|
- executionCommandSource.handleError(var20, isForked, context.tracer());
|
|
- if (!isForked) {
|
|
- return;
|
|
- }
|
|
+ list1.addAll(collection);
|
|
+ } catch (CommandSyntaxException var20) {
|
|
+ executionCommandSource.handleError(var20, isForked, context.tracer());
|
|
+ if (!isForked) {
|
|
+ return;
|
|
}
|
|
}
|
|
-
|
|
- list = list1;
|
|
}
|
|
+
|
|
+ list = list1;
|
|
}
|
|
- } finally {
|
|
- context.profiler().pop();
|
|
}
|
|
+ // DivineMC end - Completely remove Mojang profiler
|
|
}
|
|
|
|
if (list.isEmpty()) {
|
|
diff --git a/net/minecraft/commands/execution/tasks/ExecuteCommand.java b/net/minecraft/commands/execution/tasks/ExecuteCommand.java
|
|
index 18071dcc69cc28471dddb7de94e803ec1e5fc2e4..aa25f5ebaf7d1b22825b962b02dcae02bc35468f 100644
|
|
--- a/net/minecraft/commands/execution/tasks/ExecuteCommand.java
|
|
+++ b/net/minecraft/commands/execution/tasks/ExecuteCommand.java
|
|
@@ -23,8 +23,6 @@ public class ExecuteCommand<T extends ExecutionCommandSource<T>> implements Unbo
|
|
|
|
@Override
|
|
public void execute(T source, ExecutionContext<T> executionContext, Frame frame) {
|
|
- executionContext.profiler().push(() -> "execute " + this.commandInput);
|
|
-
|
|
try {
|
|
executionContext.incrementCost();
|
|
int i = ContextChain.runExecutable(this.executionContext, source, ExecutionCommandSource.resultConsumer(), this.modifiers.isForked());
|
|
@@ -34,8 +32,6 @@ public class ExecuteCommand<T extends ExecutionCommandSource<T>> implements Unbo
|
|
}
|
|
} catch (CommandSyntaxException var9) {
|
|
source.handleError(var9, this.modifiers.isForked(), executionContext.tracer());
|
|
- } finally {
|
|
- executionContext.profiler().pop();
|
|
}
|
|
}
|
|
}
|
|
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
|
index 3b6d2cf670caefd42536de896d3e13c96ebf87b1..16635681a7ed6c6db8434fc14f9ac7c9243fd4a8 100644
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
|
@@ -114,19 +114,8 @@ import net.minecraft.util.TimeUtil;
|
|
import net.minecraft.util.debugchart.RemoteDebugSampleType;
|
|
import net.minecraft.util.debugchart.SampleLogger;
|
|
import net.minecraft.util.debugchart.TpsDebugDimensions;
|
|
-import net.minecraft.util.profiling.EmptyProfileResults;
|
|
-import net.minecraft.util.profiling.ProfileResults;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
-import net.minecraft.util.profiling.ResultField;
|
|
-import net.minecraft.util.profiling.SingleTickProfiler;
|
|
import net.minecraft.util.profiling.jfr.JvmProfiler;
|
|
import net.minecraft.util.profiling.jfr.callback.ProfiledDuration;
|
|
-import net.minecraft.util.profiling.metrics.profiling.ActiveMetricsRecorder;
|
|
-import net.minecraft.util.profiling.metrics.profiling.InactiveMetricsRecorder;
|
|
-import net.minecraft.util.profiling.metrics.profiling.MetricsRecorder;
|
|
-import net.minecraft.util.profiling.metrics.profiling.ServerMetricsSamplersProvider;
|
|
-import net.minecraft.util.profiling.metrics.storage.MetricsPersister;
|
|
import net.minecraft.util.thread.ReentrantBlockableEventLoop;
|
|
import net.minecraft.world.Difficulty;
|
|
import net.minecraft.world.RandomSequences;
|
|
@@ -199,13 +188,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
public LevelStorageSource.LevelStorageAccess storageSource;
|
|
public final PlayerDataStorage playerDataStorage;
|
|
private final List<Runnable> tickables = Lists.newArrayList();
|
|
- private MetricsRecorder metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
|
- private Consumer<ProfileResults> onMetricsRecordingStopped = results -> this.stopRecordingMetrics();
|
|
- private Consumer<Path> onMetricsRecordingFinished = path -> {};
|
|
- private boolean willStartRecordingMetrics;
|
|
- @Nullable
|
|
- private MinecraftServer.TimeProfiler debugCommandProfiler;
|
|
- private boolean debugCommandProfilerDelayStart;
|
|
private ServerConnectionListener connection;
|
|
public final ChunkProgressListenerFactory progressListenerFactory;
|
|
@Nullable
|
|
@@ -993,9 +975,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
shutdownThread = Thread.currentThread(); // Paper - Improved watchdog support
|
|
org.spigotmc.WatchdogThread.doStop(); // Paper - Improved watchdog support
|
|
// CraftBukkit end
|
|
- if (this.metricsRecorder.isRecording()) {
|
|
- this.cancelRecordingMetrics();
|
|
- }
|
|
|
|
LOGGER.info("Stopping server");
|
|
Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
|
|
@@ -1267,50 +1246,38 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// Spigot end
|
|
|
|
boolean flag = l == 0L;
|
|
- if (this.debugCommandProfilerDelayStart) {
|
|
- this.debugCommandProfilerDelayStart = false;
|
|
- this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
|
|
- }
|
|
|
|
//MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time
|
|
lastTick = currentTime;
|
|
this.nextTickTimeNanos += l;
|
|
|
|
- try (Profiler.Scope scope = Profiler.use(this.createProfiler())) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("tick");
|
|
- this.tickFrame.start();
|
|
- this.tickServer(flag ? () -> false : this::haveTime);
|
|
- // Paper start - rewrite chunk system
|
|
- final Throwable crash = this.chunkSystemCrash;
|
|
- if (crash != null) {
|
|
- this.chunkSystemCrash = null;
|
|
- throw new RuntimeException("Chunk system crash propagated to tick()", crash);
|
|
- }
|
|
- // Paper end - rewrite chunk system
|
|
- this.tickFrame.end();
|
|
- profilerFiller.popPush("nextTickWait");
|
|
- this.mayHaveDelayedTasks = true;
|
|
- this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + l, this.nextTickTimeNanos);
|
|
- // Purpur start - Configurable TPS Catchup
|
|
- if (!org.purpurmc.purpur.PurpurConfig.tpsCatchup /*|| !gg.pufferfish.pufferfish.PufferfishConfig.tpsCatchup*/) { // Purpur - Configurable TPS Catchup
|
|
- this.nextTickTimeNanos = currentTime + l;
|
|
- this.delayedTasksMaxNextTickTimeNanos = nextTickTimeNanos;
|
|
- }
|
|
- // Purpur end - Configurable TPS Catchup
|
|
- this.startMeasuringTaskExecutionTime();
|
|
- this.waitUntilNextTick();
|
|
- this.finishMeasuringTaskExecutionTime();
|
|
- if (flag) {
|
|
- this.tickRateManager.endTickWork();
|
|
- }
|
|
-
|
|
- profilerFiller.pop();
|
|
- this.logFullTickTime();
|
|
- } finally {
|
|
- this.endMetricsRecordingTick();
|
|
+ this.tickFrame.start();
|
|
+ this.tickServer(flag ? () -> false : this::haveTime);
|
|
+ // Paper start - rewrite chunk system
|
|
+ final Throwable crash = this.chunkSystemCrash;
|
|
+ if (crash != null) {
|
|
+ this.chunkSystemCrash = null;
|
|
+ throw new RuntimeException("Chunk system crash propagated to tick()", crash);
|
|
+ }
|
|
+ // Paper end - rewrite chunk system
|
|
+ this.tickFrame.end();
|
|
+ this.mayHaveDelayedTasks = true;
|
|
+ this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + l, this.nextTickTimeNanos);
|
|
+ // Purpur start - Configurable TPS Catchup
|
|
+ if (!org.purpurmc.purpur.PurpurConfig.tpsCatchup /*|| !gg.pufferfish.pufferfish.PufferfishConfig.tpsCatchup*/) { // Purpur - Configurable TPS Catchup
|
|
+ this.nextTickTimeNanos = currentTime + l;
|
|
+ this.delayedTasksMaxNextTickTimeNanos = nextTickTimeNanos;
|
|
+ }
|
|
+ // Purpur end - Configurable TPS Catchup
|
|
+ this.startMeasuringTaskExecutionTime();
|
|
+ this.waitUntilNextTick();
|
|
+ this.finishMeasuringTaskExecutionTime();
|
|
+ if (flag) {
|
|
+ this.tickRateManager.endTickWork();
|
|
}
|
|
|
|
+ this.logFullTickTime();
|
|
+
|
|
this.isReady = true;
|
|
JvmProfiler.INSTANCE.onServerTick(this.smoothedTickTimeMillis);
|
|
}
|
|
@@ -1482,7 +1449,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
|
|
@Override
|
|
public void doRunTask(TickTask task) {
|
|
- Profiler.get().incrementCounter("runTask");
|
|
super.doRunTask(task);
|
|
}
|
|
|
|
@@ -1572,12 +1538,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
|
|
this.ticksUntilAutosave--;
|
|
// Paper start - Incremental chunk and player saving
|
|
- final ProfilerFiller profiler = Profiler.get();
|
|
int playerSaveInterval = io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.rate;
|
|
if (playerSaveInterval < 0) {
|
|
playerSaveInterval = autosavePeriod;
|
|
}
|
|
- profiler.push("save");
|
|
final boolean fullSave = autosavePeriod > 0 && this.tickCount % autosavePeriod == 0;
|
|
try {
|
|
this.isSaving = true;
|
|
@@ -1592,10 +1556,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
} finally {
|
|
this.isSaving = false;
|
|
}
|
|
- profiler.pop();
|
|
// Paper end - Incremental chunk and player saving
|
|
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
this.runAllTasks(); // Paper - move runAllTasks() into full server tick (previously for timings)
|
|
this.server.spark.executeMainThreadTasks(); // Paper - spark
|
|
// Paper start - Server Tick Events
|
|
@@ -1604,7 +1566,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.tickCount, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent();
|
|
// Paper end - Server Tick Events
|
|
this.server.spark.tickEnd(((double)(endTime - lastTick) / 1000000D)); // Paper - spark
|
|
- profilerFiller.push("tallying");
|
|
long l = Util.getNanos() - nanos;
|
|
int i1 = this.tickCount % 100;
|
|
this.aggregatedTickTimesNanos = this.aggregatedTickTimesNanos - this.tickTimesNanos[i1];
|
|
@@ -1617,16 +1578,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
this.tickTimes60s.add(this.tickCount, l);
|
|
// Paper end - Add tick times API and /mspt command
|
|
this.logTickMethodTime(nanos);
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
private void autoSave() {
|
|
this.ticksUntilAutosave = this.autosavePeriod; // CraftBukkit
|
|
LOGGER.debug("Autosave started");
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("save");
|
|
this.saveEverything(true, false, false);
|
|
- profilerFiller.pop();
|
|
LOGGER.debug("Autosave finished");
|
|
}
|
|
|
|
@@ -1694,7 +1651,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
public final io.papermc.paper.threadedregions.EntityScheduler.EntitySchedulerTickList entitySchedulerTickList = new io.papermc.paper.threadedregions.EntityScheduler.EntitySchedulerTickList(); // Paper - optimise Folia entity scheduler
|
|
|
|
protected void tickChildren(BooleanSupplier hasTimeLeft) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing());
|
|
this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
|
|
// Paper start - optimise Folia entity scheduler
|
|
@@ -1709,9 +1665,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// Paper end - optimise Folia entity scheduler
|
|
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.handleQueue(this.tickCount); // Paper
|
|
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue(this.tickCount); // Paper
|
|
- profilerFiller.push("commandFunctions");
|
|
this.getFunctions().tick();
|
|
- profilerFiller.popPush("levels");
|
|
|
|
// CraftBukkit start
|
|
// Run tasks that are waiting on processing
|
|
@@ -1747,17 +1701,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
serverLevel.updateLagCompensationTick(); // Paper - lag compensation
|
|
net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = serverLevel.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers
|
|
serverLevel.hasRidableMoveEvent = org.purpurmc.purpur.event.entity.RidableMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur - Ridables
|
|
- profilerFiller.push(() -> serverLevel + " " + serverLevel.dimension().location());
|
|
/* Drop global time updates
|
|
if (this.tickCount % 20 == 0) {
|
|
- profilerFiller.push("timeSync");
|
|
this.synchronizeTime(serverLevel);
|
|
- profilerFiller.pop();
|
|
}
|
|
// CraftBukkit end */
|
|
|
|
- profilerFiller.push("tick");
|
|
-
|
|
try {
|
|
serverLevel.tick(hasTimeLeft);
|
|
} catch (Throwable var7) {
|
|
@@ -1766,34 +1715,24 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
throw new ReportedException(crashReport);
|
|
}
|
|
|
|
- profilerFiller.pop();
|
|
- profilerFiller.pop();
|
|
serverLevel.explosionDensityCache.clear(); // Paper - Optimize explosions
|
|
}
|
|
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
|
|
|
- profilerFiller.popPush("connection");
|
|
this.tickConnection();
|
|
- profilerFiller.popPush("players");
|
|
this.playerList.tick();
|
|
if (this.tickRateManager.runsNormally()) {
|
|
GameTestTicker.SINGLETON.tick();
|
|
}
|
|
|
|
- profilerFiller.popPush("server gui refresh");
|
|
-
|
|
for (int i = 0; i < this.tickables.size(); i++) {
|
|
this.tickables.get(i).run();
|
|
}
|
|
|
|
- profilerFiller.popPush("send chunks");
|
|
-
|
|
for (ServerPlayer serverPlayer : this.playerList.getPlayers()) {
|
|
serverPlayer.connection.chunkSender.sendNextChunks(serverPlayer);
|
|
serverPlayer.connection.resumeFlushing();
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
public void tickConnection() {
|
|
@@ -1809,14 +1748,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
}
|
|
|
|
public void forceTimeSynchronization() {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("timeSync");
|
|
-
|
|
for (ServerLevel serverLevel : this.getAllLevels()) {
|
|
this.synchronizeTime(serverLevel);
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
public boolean isLevelEnabled(Level level) {
|
|
@@ -2632,55 +2566,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
}
|
|
// CraftBukkit end
|
|
|
|
- private ProfilerFiller createProfiler() {
|
|
- if (this.willStartRecordingMetrics) {
|
|
- this.metricsRecorder = ActiveMetricsRecorder.createStarted(
|
|
- new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()),
|
|
- Util.timeSource,
|
|
- Util.ioPool(),
|
|
- new MetricsPersister("server"),
|
|
- this.onMetricsRecordingStopped,
|
|
- path -> {
|
|
- this.executeBlocking(() -> this.saveDebugReport(path.resolve("server")));
|
|
- this.onMetricsRecordingFinished.accept(path);
|
|
- }
|
|
- );
|
|
- this.willStartRecordingMetrics = false;
|
|
- }
|
|
-
|
|
- this.metricsRecorder.startTick();
|
|
- return SingleTickProfiler.decorateFiller(this.metricsRecorder.getProfiler(), SingleTickProfiler.createTickProfiler("Server"));
|
|
- }
|
|
-
|
|
- public void endMetricsRecordingTick() {
|
|
- this.metricsRecorder.endTick();
|
|
- }
|
|
-
|
|
- public boolean isRecordingMetrics() {
|
|
- return this.metricsRecorder.isRecording();
|
|
- }
|
|
-
|
|
- public void startRecordingMetrics(Consumer<ProfileResults> output, Consumer<Path> onMetricsRecordingFinished) {
|
|
- this.onMetricsRecordingStopped = profileResults -> {
|
|
- this.stopRecordingMetrics();
|
|
- output.accept(profileResults);
|
|
- };
|
|
- this.onMetricsRecordingFinished = onMetricsRecordingFinished;
|
|
- this.willStartRecordingMetrics = true;
|
|
- }
|
|
-
|
|
- public void stopRecordingMetrics() {
|
|
- this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
|
- }
|
|
-
|
|
- public void finishRecordingMetrics() {
|
|
- this.metricsRecorder.end();
|
|
- }
|
|
-
|
|
- public void cancelRecordingMetrics() {
|
|
- this.metricsRecorder.cancel();
|
|
- }
|
|
-
|
|
public Path getWorldPath(LevelResource levelResource) {
|
|
return this.storageSource.getLevelPath(levelResource);
|
|
}
|
|
@@ -2730,24 +2615,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
return this.isSaving;
|
|
}
|
|
|
|
- public boolean isTimeProfilerRunning() {
|
|
- return this.debugCommandProfilerDelayStart || this.debugCommandProfiler != null;
|
|
- }
|
|
-
|
|
- public void startTimeProfiler() {
|
|
- this.debugCommandProfilerDelayStart = true;
|
|
- }
|
|
-
|
|
- public ProfileResults stopTimeProfiler() {
|
|
- if (this.debugCommandProfiler == null) {
|
|
- return EmptyProfileResults.EMPTY;
|
|
- } else {
|
|
- ProfileResults profileResults = this.debugCommandProfiler.stop(Util.getNanos(), this.tickCount);
|
|
- this.debugCommandProfiler = null;
|
|
- return profileResults;
|
|
- }
|
|
- }
|
|
-
|
|
public int getMaxChainedNeighborUpdates() {
|
|
return 1000000;
|
|
}
|
|
@@ -2857,55 +2724,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
public record ServerResourcePackInfo(UUID id, String url, String hash, boolean isRequired, @Nullable Component prompt) {
|
|
}
|
|
|
|
- static class TimeProfiler {
|
|
- final long startNanos;
|
|
- final int startTick;
|
|
-
|
|
- TimeProfiler(long startNanos, int startTick) {
|
|
- this.startNanos = startNanos;
|
|
- this.startTick = startTick;
|
|
- }
|
|
-
|
|
- ProfileResults stop(final long endTimeNano, final int endTimeTicks) {
|
|
- return new ProfileResults() {
|
|
- @Override
|
|
- public List<ResultField> getTimes(String sectionPath) {
|
|
- return Collections.emptyList();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean saveResults(Path path) {
|
|
- return false;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getStartTimeNano() {
|
|
- return TimeProfiler.this.startNanos;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int getStartTimeTicks() {
|
|
- return TimeProfiler.this.startTick;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getEndTimeNano() {
|
|
- return endTimeNano;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int getEndTimeTicks() {
|
|
- return endTimeTicks;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public String getProfilerResults() {
|
|
- return "";
|
|
- }
|
|
- };
|
|
- }
|
|
- }
|
|
-
|
|
// Paper start - Add tick times API and /mspt command
|
|
public static class TickTimes {
|
|
private final long[] times;
|
|
diff --git a/net/minecraft/server/ReloadableServerResources.java b/net/minecraft/server/ReloadableServerResources.java
|
|
index c891715968193f2ab4579b4a2b4aeeae6a210070..7b0cf6cdd0eeaea228380c5960704e632d97de98 100644
|
|
--- a/net/minecraft/server/ReloadableServerResources.java
|
|
+++ b/net/minecraft/server/ReloadableServerResources.java
|
|
@@ -99,7 +99,7 @@ public class ReloadableServerResources {
|
|
backgroundExecutor,
|
|
gameExecutor,
|
|
DATA_RELOAD_INITIAL_TASK,
|
|
- LOGGER.isDebugEnabled()
|
|
+ false // DivineMC - Completely remove Mojang profiler
|
|
)
|
|
.done()
|
|
.thenApply(object -> reloadableServerResources);
|
|
diff --git a/net/minecraft/server/ServerAdvancementManager.java b/net/minecraft/server/ServerAdvancementManager.java
|
|
index a524f5b9aa082ada267c8e20df4ff4d22a76d281..339626862c33bca9cbc34acc520ba5d7831e189f 100644
|
|
--- a/net/minecraft/server/ServerAdvancementManager.java
|
|
+++ b/net/minecraft/server/ServerAdvancementManager.java
|
|
@@ -17,7 +17,6 @@ import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.server.packs.resources.ResourceManager;
|
|
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
|
import net.minecraft.util.ProblemReporter;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import org.slf4j.Logger;
|
|
|
|
public class ServerAdvancementManager extends SimpleJsonResourceReloadListener<Advancement> {
|
|
@@ -32,7 +31,7 @@ public class ServerAdvancementManager extends SimpleJsonResourceReloadListener<A
|
|
}
|
|
|
|
@Override
|
|
- protected void apply(Map<ResourceLocation, Advancement> object, ResourceManager resourceManager, ProfilerFiller profiler) {
|
|
+ protected void apply(Map<ResourceLocation, Advancement> object, ResourceManager resourceManager) {
|
|
Builder<ResourceLocation, AdvancementHolder> builder = ImmutableMap.builder();
|
|
object.forEach((resourceLocation, advancement) -> {
|
|
// Spigot start
|
|
diff --git a/net/minecraft/server/ServerFunctionManager.java b/net/minecraft/server/ServerFunctionManager.java
|
|
index e3cb5d9cd0332c32df82fa6aef37401c523e8af0..10c79570432491bfb2bbfedf0491ab2b803d0c71 100644
|
|
--- a/net/minecraft/server/ServerFunctionManager.java
|
|
+++ b/net/minecraft/server/ServerFunctionManager.java
|
|
@@ -14,8 +14,6 @@ import net.minecraft.commands.execution.ExecutionContext;
|
|
import net.minecraft.commands.functions.CommandFunction;
|
|
import net.minecraft.commands.functions.InstantiatedFunction;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import org.slf4j.Logger;
|
|
|
|
public class ServerFunctionManager {
|
|
@@ -50,19 +48,12 @@ public class ServerFunctionManager {
|
|
}
|
|
|
|
private void executeTagFunctions(Collection<CommandFunction<CommandSourceStack>> functionObjects, ResourceLocation identifier) {
|
|
- Profiler.get().push(identifier::toString);
|
|
-
|
|
for (CommandFunction<CommandSourceStack> commandFunction : functionObjects) {
|
|
this.execute(commandFunction, this.getGameLoopSender());
|
|
}
|
|
-
|
|
- Profiler.get().pop();
|
|
}
|
|
|
|
public void execute(CommandFunction<CommandSourceStack> function, CommandSourceStack source) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push(() -> "function " + function.id());
|
|
-
|
|
try {
|
|
InstantiatedFunction<CommandSourceStack> instantiatedFunction = function.instantiate(null, this.getDispatcher());
|
|
Commands.executeCommandInContext(
|
|
@@ -72,8 +63,6 @@ public class ServerFunctionManager {
|
|
} catch (FunctionInstantiationException var9) {
|
|
} catch (Exception var10) {
|
|
LOGGER.warn("Failed to execute function {}", function.id(), var10);
|
|
- } finally {
|
|
- profilerFiller.pop();
|
|
}
|
|
}
|
|
|
|
diff --git a/net/minecraft/server/commands/DebugCommand.java b/net/minecraft/server/commands/DebugCommand.java
|
|
deleted file mode 100644
|
|
index a78213464c5c365c6395fdf1295cb406c618d33b..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/server/commands/DebugCommand.java
|
|
+++ /dev/null
|
|
@@ -1,277 +0,0 @@
|
|
-package net.minecraft.server.commands;
|
|
-
|
|
-import com.mojang.brigadier.CommandDispatcher;
|
|
-import com.mojang.brigadier.context.CommandContext;
|
|
-import com.mojang.brigadier.context.ContextChain;
|
|
-import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
-import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
|
-import com.mojang.logging.LogUtils;
|
|
-import java.io.IOException;
|
|
-import java.io.PrintWriter;
|
|
-import java.io.UncheckedIOException;
|
|
-import java.io.Writer;
|
|
-import java.nio.charset.StandardCharsets;
|
|
-import java.nio.file.Files;
|
|
-import java.nio.file.Path;
|
|
-import java.util.Collection;
|
|
-import java.util.Locale;
|
|
-import net.minecraft.Util;
|
|
-import net.minecraft.commands.CommandResultCallback;
|
|
-import net.minecraft.commands.CommandSource;
|
|
-import net.minecraft.commands.CommandSourceStack;
|
|
-import net.minecraft.commands.Commands;
|
|
-import net.minecraft.commands.FunctionInstantiationException;
|
|
-import net.minecraft.commands.arguments.item.FunctionArgument;
|
|
-import net.minecraft.commands.execution.ChainModifiers;
|
|
-import net.minecraft.commands.execution.CustomCommandExecutor;
|
|
-import net.minecraft.commands.execution.ExecutionContext;
|
|
-import net.minecraft.commands.execution.ExecutionControl;
|
|
-import net.minecraft.commands.execution.Frame;
|
|
-import net.minecraft.commands.execution.TraceCallbacks;
|
|
-import net.minecraft.commands.execution.tasks.CallFunction;
|
|
-import net.minecraft.commands.functions.CommandFunction;
|
|
-import net.minecraft.commands.functions.InstantiatedFunction;
|
|
-import net.minecraft.network.chat.Component;
|
|
-import net.minecraft.resources.ResourceLocation;
|
|
-import net.minecraft.server.MinecraftServer;
|
|
-import net.minecraft.util.TimeUtil;
|
|
-import net.minecraft.util.profiling.ProfileResults;
|
|
-import org.apache.commons.io.IOUtils;
|
|
-import org.slf4j.Logger;
|
|
-
|
|
-public class DebugCommand {
|
|
- static final Logger LOGGER = LogUtils.getLogger();
|
|
- private static final SimpleCommandExceptionType ERROR_NOT_RUNNING = new SimpleCommandExceptionType(Component.translatable("commands.debug.notRunning"));
|
|
- private static final SimpleCommandExceptionType ERROR_ALREADY_RUNNING = new SimpleCommandExceptionType(
|
|
- Component.translatable("commands.debug.alreadyRunning")
|
|
- );
|
|
- static final SimpleCommandExceptionType NO_RECURSIVE_TRACES = new SimpleCommandExceptionType(Component.translatable("commands.debug.function.noRecursion"));
|
|
- static final SimpleCommandExceptionType NO_RETURN_RUN = new SimpleCommandExceptionType(Component.translatable("commands.debug.function.noReturnRun"));
|
|
-
|
|
- public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
|
- dispatcher.register(
|
|
- Commands.literal("debug")
|
|
- .requires(Commands.hasPermission(3))
|
|
- .then(Commands.literal("start").executes(commandContext -> start(commandContext.getSource())))
|
|
- .then(Commands.literal("stop").executes(context -> stop(context.getSource())))
|
|
- .then(
|
|
- Commands.literal("function")
|
|
- .requires(Commands.hasPermission(3))
|
|
- .then(
|
|
- Commands.argument("name", FunctionArgument.functions())
|
|
- .suggests(FunctionCommand.SUGGEST_FUNCTION)
|
|
- .executes(new DebugCommand.TraceCustomExecutor())
|
|
- )
|
|
- )
|
|
- );
|
|
- }
|
|
-
|
|
- private static int start(CommandSourceStack source) throws CommandSyntaxException {
|
|
- MinecraftServer server = source.getServer();
|
|
- if (server.isTimeProfilerRunning()) {
|
|
- throw ERROR_ALREADY_RUNNING.create();
|
|
- } else {
|
|
- server.startTimeProfiler();
|
|
- source.sendSuccess(() -> Component.translatable("commands.debug.started"), true);
|
|
- return 0;
|
|
- }
|
|
- }
|
|
-
|
|
- private static int stop(CommandSourceStack source) throws CommandSyntaxException {
|
|
- MinecraftServer server = source.getServer();
|
|
- if (!server.isTimeProfilerRunning()) {
|
|
- throw ERROR_NOT_RUNNING.create();
|
|
- } else {
|
|
- ProfileResults profileResults = server.stopTimeProfiler();
|
|
- double d = (double)profileResults.getNanoDuration() / TimeUtil.NANOSECONDS_PER_SECOND;
|
|
- double d1 = profileResults.getTickDuration() / d;
|
|
- source.sendSuccess(
|
|
- () -> Component.translatable(
|
|
- "commands.debug.stopped", String.format(Locale.ROOT, "%.2f", d), profileResults.getTickDuration(), String.format(Locale.ROOT, "%.2f", d1)
|
|
- ),
|
|
- true
|
|
- );
|
|
- return (int)d1;
|
|
- }
|
|
- }
|
|
-
|
|
- static class TraceCustomExecutor
|
|
- extends CustomCommandExecutor.WithErrorHandling<CommandSourceStack>
|
|
- implements CustomCommandExecutor.CommandAdapter<CommandSourceStack> {
|
|
- @Override
|
|
- public void runGuarded(
|
|
- CommandSourceStack source,
|
|
- ContextChain<CommandSourceStack> contextChain,
|
|
- ChainModifiers chainModifiers,
|
|
- ExecutionControl<CommandSourceStack> executionControl
|
|
- ) throws CommandSyntaxException {
|
|
- if (chainModifiers.isReturn()) {
|
|
- throw DebugCommand.NO_RETURN_RUN.create();
|
|
- } else if (executionControl.tracer() != null) {
|
|
- throw DebugCommand.NO_RECURSIVE_TRACES.create();
|
|
- } else {
|
|
- CommandContext<CommandSourceStack> topContext = contextChain.getTopContext();
|
|
- Collection<CommandFunction<CommandSourceStack>> functions = FunctionArgument.getFunctions(topContext, "name");
|
|
- MinecraftServer server = source.getServer();
|
|
- String string = "debug-trace-" + Util.getFilenameFormattedDateTime() + ".txt";
|
|
- CommandDispatcher<CommandSourceStack> dispatcher = source.getServer().getFunctions().getDispatcher();
|
|
- int i = 0;
|
|
-
|
|
- try {
|
|
- Path file = server.getFile("debug");
|
|
- Files.createDirectories(file);
|
|
- final PrintWriter printWriter = new PrintWriter(Files.newBufferedWriter(file.resolve(string), StandardCharsets.UTF_8));
|
|
- DebugCommand.Tracer tracer = new DebugCommand.Tracer(printWriter);
|
|
- executionControl.tracer(tracer);
|
|
-
|
|
- for (final CommandFunction<CommandSourceStack> commandFunction : functions) {
|
|
- try {
|
|
- CommandSourceStack commandSourceStack = source.withSource(tracer).withMaximumPermission(2);
|
|
- InstantiatedFunction<CommandSourceStack> instantiatedFunction = commandFunction.instantiate(null, dispatcher);
|
|
- executionControl.queueNext((new CallFunction<CommandSourceStack>(instantiatedFunction, CommandResultCallback.EMPTY, false) {
|
|
- @Override
|
|
- public void execute(CommandSourceStack source1, ExecutionContext<CommandSourceStack> executionContext, Frame frame) {
|
|
- printWriter.println(commandFunction.id());
|
|
- super.execute(source1, executionContext, frame);
|
|
- }
|
|
- }).bind(commandSourceStack));
|
|
- i += instantiatedFunction.entries().size();
|
|
- } catch (FunctionInstantiationException var18) {
|
|
- source.sendFailure(var18.messageComponent());
|
|
- }
|
|
- }
|
|
- } catch (IOException | UncheckedIOException var19) {
|
|
- DebugCommand.LOGGER.warn("Tracing failed", (Throwable)var19);
|
|
- source.sendFailure(Component.translatable("commands.debug.function.traceFailed"));
|
|
- }
|
|
-
|
|
- int i1 = i;
|
|
- executionControl.queueNext(
|
|
- (executionContext, frame) -> {
|
|
- if (functions.size() == 1) {
|
|
- source.sendSuccess(
|
|
- () -> Component.translatable(
|
|
- "commands.debug.function.success.single", i1, Component.translationArg(functions.iterator().next().id()), string
|
|
- ),
|
|
- true
|
|
- );
|
|
- } else {
|
|
- source.sendSuccess(() -> Component.translatable("commands.debug.function.success.multiple", i1, functions.size(), string), true);
|
|
- }
|
|
- }
|
|
- );
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- static class Tracer implements CommandSource, TraceCallbacks {
|
|
- public static final int INDENT_OFFSET = 1;
|
|
- private final PrintWriter output;
|
|
- private int lastIndent;
|
|
- private boolean waitingForResult;
|
|
-
|
|
- Tracer(PrintWriter output) {
|
|
- this.output = output;
|
|
- }
|
|
-
|
|
- private void indentAndSave(int indent) {
|
|
- this.printIndent(indent);
|
|
- this.lastIndent = indent;
|
|
- }
|
|
-
|
|
- private void printIndent(int indent) {
|
|
- for (int i = 0; i < indent + 1; i++) {
|
|
- this.output.write(" ");
|
|
- }
|
|
- }
|
|
-
|
|
- private void newLine() {
|
|
- if (this.waitingForResult) {
|
|
- this.output.println();
|
|
- this.waitingForResult = false;
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void onCommand(int depth, String command) {
|
|
- this.newLine();
|
|
- this.indentAndSave(depth);
|
|
- this.output.print("[C] ");
|
|
- this.output.print(command);
|
|
- this.waitingForResult = true;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void onReturn(int depth, String command, int returnValue) {
|
|
- if (this.waitingForResult) {
|
|
- this.output.print(" -> ");
|
|
- this.output.println(returnValue);
|
|
- this.waitingForResult = false;
|
|
- } else {
|
|
- this.indentAndSave(depth);
|
|
- this.output.print("[R = ");
|
|
- this.output.print(returnValue);
|
|
- this.output.print("] ");
|
|
- this.output.println(command);
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void onCall(int depth, ResourceLocation function, int commands) {
|
|
- this.newLine();
|
|
- this.indentAndSave(depth);
|
|
- this.output.print("[F] ");
|
|
- this.output.print(function);
|
|
- this.output.print(" size=");
|
|
- this.output.println(commands);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void onError(String errorMessage) {
|
|
- this.newLine();
|
|
- this.indentAndSave(this.lastIndent + 1);
|
|
- this.output.print("[E] ");
|
|
- this.output.print(errorMessage);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void sendSystemMessage(Component component) {
|
|
- this.newLine();
|
|
- this.printIndent(this.lastIndent + 1);
|
|
- this.output.print("[M] ");
|
|
- this.output.println(component.getString());
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean acceptsSuccess() {
|
|
- return true;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean acceptsFailure() {
|
|
- return true;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean shouldInformAdmins() {
|
|
- return false;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean alwaysAccepts() {
|
|
- return true;
|
|
- }
|
|
-
|
|
- // Paper start
|
|
- @Override
|
|
- public org.bukkit.command.CommandSender getBukkitSender(final CommandSourceStack wrapper) {
|
|
- throw new UnsupportedOperationException();
|
|
- }
|
|
- // Paper end
|
|
-
|
|
- @Override
|
|
- public void close() {
|
|
- IOUtils.closeQuietly((Writer)this.output);
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/server/commands/PerfCommand.java b/net/minecraft/server/commands/PerfCommand.java
|
|
index b10cb4a73df58a5fe64e88868733ba41616f59e4..9f9cbe6056f8a4eeca64c40872d7403bb0ddc600 100644
|
|
--- a/net/minecraft/server/commands/PerfCommand.java
|
|
+++ b/net/minecraft/server/commands/PerfCommand.java
|
|
@@ -19,9 +19,6 @@ import net.minecraft.network.chat.Component;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.util.FileZipper;
|
|
import net.minecraft.util.TimeUtil;
|
|
-import net.minecraft.util.profiling.EmptyProfileResults;
|
|
-import net.minecraft.util.profiling.ProfileResults;
|
|
-import net.minecraft.util.profiling.metrics.storage.MetricsPersister;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.slf4j.Logger;
|
|
|
|
@@ -42,66 +39,22 @@ public class PerfCommand {
|
|
}
|
|
|
|
private static int startProfilingDedicatedServer(CommandSourceStack source) throws CommandSyntaxException {
|
|
- MinecraftServer server = source.getServer();
|
|
- if (server.isRecordingMetrics()) {
|
|
- throw ERROR_ALREADY_RUNNING.create();
|
|
- } else {
|
|
- Consumer<ProfileResults> consumer = profileResults -> whenStopped(source, profileResults);
|
|
- Consumer<Path> consumer1 = path -> saveResults(source, path, server);
|
|
- server.startRecordingMetrics(consumer, consumer1);
|
|
- source.sendSuccess(() -> Component.translatable("commands.perf.started"), false);
|
|
- return 0;
|
|
- }
|
|
+ return removedMessage(source); // DivineMC - Completely remove Mojang profiler
|
|
}
|
|
|
|
private static int stopProfilingDedicatedServer(CommandSourceStack source) throws CommandSyntaxException {
|
|
- MinecraftServer server = source.getServer();
|
|
- if (!server.isRecordingMetrics()) {
|
|
- throw ERROR_NOT_RUNNING.create();
|
|
- } else {
|
|
- server.finishRecordingMetrics();
|
|
- return 0;
|
|
- }
|
|
+ return removedMessage(source); // DivineMC - Completely remove Mojang profiler
|
|
}
|
|
|
|
- private static void saveResults(CommandSourceStack source, Path path, MinecraftServer server) {
|
|
- String string = String.format(
|
|
- Locale.ROOT, "%s-%s-%s", Util.getFilenameFormattedDateTime(), server.getWorldData().getLevelName(), SharedConstants.getCurrentVersion().id()
|
|
- );
|
|
-
|
|
- String string1;
|
|
- try {
|
|
- string1 = FileUtil.findAvailableName(MetricsPersister.PROFILING_RESULTS_DIR, string, ".zip");
|
|
- } catch (IOException var11) {
|
|
- source.sendFailure(Component.translatable("commands.perf.reportFailed"));
|
|
- LOGGER.error("Failed to create report name", (Throwable)var11);
|
|
- return;
|
|
- }
|
|
-
|
|
- try (FileZipper fileZipper = new FileZipper(MetricsPersister.PROFILING_RESULTS_DIR.resolve(string1))) {
|
|
- fileZipper.add(Paths.get("system.txt"), server.fillSystemReport(new SystemReport()).toLineSeparatedString());
|
|
- fileZipper.add(path);
|
|
- }
|
|
+ // DivineMC start - Completely remove Mojang profiler
|
|
+ private static int removedMessage(CommandSourceStack source) {
|
|
+ net.kyori.adventure.text.minimessage.MiniMessage mm = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage();
|
|
|
|
- try {
|
|
- FileUtils.forceDelete(path.toFile());
|
|
- } catch (IOException var9) {
|
|
- LOGGER.warn("Failed to delete temporary profiling file {}", path, var9);
|
|
- }
|
|
-
|
|
- source.sendSuccess(() -> Component.translatable("commands.perf.reportSaved", string1), false);
|
|
- }
|
|
+ source.getSender().sendMessage(mm.deserialize("<gold>Mojang's Profiler has been removed in DivineMC to save your server performance. Please use <click:suggest_command:'/spark'><grey>/spark</grey></click> instead"));
|
|
+ source.getSender().sendMessage(mm.deserialize("<gold>For more information, view its documentation at"));
|
|
+ source.getSender().sendMessage(mm.deserialize("<gold><click:open_url:'https://spark.lucko.me/docs/Command-Usage'>https://spark.lucko.me/docs/Command-Usage</click>"));
|
|
|
|
- private static void whenStopped(CommandSourceStack source, ProfileResults results) {
|
|
- if (results != EmptyProfileResults.EMPTY) {
|
|
- int tickDuration = results.getTickDuration();
|
|
- double d = (double)results.getNanoDuration() / TimeUtil.NANOSECONDS_PER_SECOND;
|
|
- source.sendSuccess(
|
|
- () -> Component.translatable(
|
|
- "commands.perf.stopped", String.format(Locale.ROOT, "%.2f", d), tickDuration, String.format(Locale.ROOT, "%.2f", tickDuration / d)
|
|
- ),
|
|
- false
|
|
- );
|
|
- }
|
|
+ return 0;
|
|
}
|
|
+ // DivineMC end - Completely remove Mojang profiler
|
|
}
|
|
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index 83bd88eb9944481642f912c2d4862dfecdec2246..06657a0fbf65dd095519d706dd5a8e1d8b6b381a 100644
|
|
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -789,12 +789,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
return this.settings.getProperties().serverResourcePackInfo;
|
|
}
|
|
|
|
- @Override
|
|
- public void endMetricsRecordingTick() {
|
|
- super.endMetricsRecordingTick();
|
|
- this.debugSampleSubscriptionTracker.tick(this.getTickCount());
|
|
- }
|
|
-
|
|
@Override
|
|
public SampleLogger getTickTimeLogger() {
|
|
return this.tickTimeLogger;
|
|
diff --git a/net/minecraft/server/level/ChunkGenerationTask.java b/net/minecraft/server/level/ChunkGenerationTask.java
|
|
index 4221af18f5087badb5cd8c7cf66ab3312edf0394..e9d861182439eecacfab2ac431726e8adeaab3aa 100644
|
|
--- a/net/minecraft/server/level/ChunkGenerationTask.java
|
|
+++ b/net/minecraft/server/level/ChunkGenerationTask.java
|
|
@@ -5,8 +5,6 @@ import java.util.List;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.util.StaticCache2D;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.Zone;
|
|
import net.minecraft.world.level.ChunkPos;
|
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
|
import net.minecraft.world.level.chunk.status.ChunkDependencies;
|
|
@@ -67,7 +65,6 @@ public class ChunkGenerationTask {
|
|
chunkStatus = ChunkStatus.getStatusList().get(this.scheduledStatus.getIndex() + 1);
|
|
}
|
|
|
|
- this.scheduleLayer(chunkStatus, this.needsGeneration);
|
|
this.scheduledStatus = chunkStatus;
|
|
}
|
|
|
|
@@ -112,22 +109,6 @@ public class ChunkGenerationTask {
|
|
return this.cache.get(this.pos.x, this.pos.z);
|
|
}
|
|
|
|
- private void scheduleLayer(ChunkStatus status, boolean needsGeneration) {
|
|
- try (Zone zone = Profiler.get().zone("scheduleLayer")) {
|
|
- zone.addText(status::getName);
|
|
- int radiusForLayer = this.getRadiusForLayer(status, needsGeneration);
|
|
-
|
|
- for (int i = this.pos.x - radiusForLayer; i <= this.pos.x + radiusForLayer; i++) {
|
|
- for (int i1 = this.pos.z - radiusForLayer; i1 <= this.pos.z + radiusForLayer; i1++) {
|
|
- GenerationChunkHolder generationChunkHolder = this.cache.get(i, i1);
|
|
- if (this.markedForCancellation || !this.scheduleChunkInLayer(status, needsGeneration, generationChunkHolder)) {
|
|
- return;
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
private int getRadiusForLayer(ChunkStatus status, boolean needsGeneration) {
|
|
ChunkPyramid chunkPyramid = needsGeneration ? ChunkPyramid.GENERATION_PYRAMID : ChunkPyramid.LOADING_PYRAMID;
|
|
return chunkPyramid.getStepTo(this.targetStatus).getAccumulatedRadiusOf(status);
|
|
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
|
index eb352aa4296abc3ed4cf31c590bc0be66daf4de3..edda52a8430386238be4963e8ea2406f0c2d4df3 100644
|
|
--- a/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/net/minecraft/server/level/ChunkMap.java
|
|
@@ -62,8 +62,6 @@ import net.minecraft.util.CsvOutput;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.StaticCache2D;
|
|
import net.minecraft.util.TriState;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.util.thread.BlockableEventLoop;
|
|
import net.minecraft.util.thread.ConsecutiveExecutor;
|
|
import net.minecraft.world.entity.Entity;
|
|
@@ -409,15 +407,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
}
|
|
|
|
protected void tick(BooleanSupplier hasMoreTime) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("poi");
|
|
this.poiManager.tick(hasMoreTime);
|
|
- profilerFiller.popPush("chunk_unload");
|
|
if (!this.level.noSave()) {
|
|
this.processUnloads(hasMoreTime);
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
public boolean hasWork() {
|
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
|
index 2882cd829d4d8e1f8615f085f6908efcdf68ac62..25150731bb3f3d04b248ebc47fc9b453e49a705e 100644
|
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -26,8 +26,6 @@ import net.minecraft.network.protocol.Packet;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.level.progress.ChunkProgressListener;
|
|
import net.minecraft.util.VisibleForDebug;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.util.thread.BlockableEventLoop;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.MobCategory;
|
|
@@ -472,37 +470,28 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
// CraftBukkit start - modelled on below
|
|
public void purgeUnload() {
|
|
if (true) return; // Paper - rewrite chunk system
|
|
- ProfilerFiller gameprofilerfiller = Profiler.get();
|
|
|
|
- gameprofilerfiller.push("purge");
|
|
this.ticketStorage.purgeStaleTickets(this.chunkMap);
|
|
this.runDistanceManagerUpdates();
|
|
- gameprofilerfiller.popPush("unload");
|
|
this.chunkMap.tick(() -> true);
|
|
- gameprofilerfiller.pop();
|
|
this.clearCache();
|
|
}
|
|
// CraftBukkit end
|
|
|
|
@Override
|
|
public void tick(BooleanSupplier hasTimeLeft, boolean tickChunks) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("purge");
|
|
if (this.level.tickRateManager().runsNormally() || !tickChunks || this.level.spigotConfig.unloadFrozenChunks) { // Spigot
|
|
this.ticketStorage.purgeStaleTickets(this.chunkMap);
|
|
}
|
|
|
|
this.runDistanceManagerUpdates();
|
|
- profilerFiller.popPush("chunks");
|
|
if (tickChunks) {
|
|
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getPlayerChunkLoader().tick(); // Paper - rewrite chunk system
|
|
this.tickChunks();
|
|
this.chunkMap.tick();
|
|
}
|
|
|
|
- profilerFiller.popPush("unload");
|
|
this.chunkMap.tick(hasTimeLeft);
|
|
- profilerFiller.pop();
|
|
this.clearCache();
|
|
}
|
|
|
|
@@ -511,22 +500,15 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
long l = gameTime - this.lastInhabitedUpdate;
|
|
this.lastInhabitedUpdate = gameTime;
|
|
if (!this.level.isDebug()) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("pollingChunks");
|
|
if (this.level.tickRateManager().runsNormally()) {
|
|
- profilerFiller.push("tickingChunks");
|
|
- this.tickChunks(profilerFiller, l);
|
|
- profilerFiller.pop();
|
|
+ this.tickChunks(l);
|
|
}
|
|
|
|
- this.broadcastChangedChunks(profilerFiller);
|
|
- profilerFiller.pop();
|
|
+ this.broadcastChangedChunks();
|
|
}
|
|
}
|
|
|
|
- private void broadcastChangedChunks(ProfilerFiller profiler) {
|
|
- profiler.push("broadcast");
|
|
-
|
|
+ private void broadcastChangedChunks() {
|
|
for (ChunkHolder chunkHolder : this.chunkHoldersToBroadcast) {
|
|
LevelChunk tickingChunk = chunkHolder.getChunkToSend(); // Paper - rewrite chunk system
|
|
if (tickingChunk != null) {
|
|
@@ -535,11 +517,9 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
}
|
|
|
|
this.chunkHoldersToBroadcast.clear();
|
|
- profiler.pop();
|
|
}
|
|
|
|
- private void tickChunks(ProfilerFiller profiler, long timeInhabited) {
|
|
- profiler.popPush("naturalSpawnCount");
|
|
+ private void tickChunks(long timeInhabited) {
|
|
int naturalSpawnChunkCount = this.distanceManager.getNaturalSpawnChunkCount();
|
|
// Paper start - Optional per player mob spawns
|
|
NaturalSpawner.SpawnState spawnState;
|
|
@@ -564,7 +544,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
}
|
|
// Paper end - Optional per player mob spawns
|
|
this.lastSpawnState = spawnState;
|
|
- profiler.popPush("spawnAndTick");
|
|
boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
|
|
int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
|
List<MobCategory> filteredSpawningCategories;
|
|
@@ -586,14 +565,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
List<LevelChunk> list = this.spawningChunks;
|
|
|
|
try {
|
|
- profiler.push("filteringSpawningChunks");
|
|
this.chunkMap.collectSpawningChunks(list);
|
|
- profiler.popPush("shuffleSpawningChunks");
|
|
// Paper start - chunk tick iteration optimisation
|
|
this.shuffleRandom.setSeed(this.level.random.nextLong());
|
|
if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled
|
|
// Paper end - chunk tick iteration optimisation
|
|
- profiler.popPush("tickSpawningChunks");
|
|
|
|
for (LevelChunk levelChunk : list) {
|
|
this.tickSpawningChunk(levelChunk, timeInhabited, filteredSpawningCategories, spawnState);
|
|
@@ -602,10 +578,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
list.clear();
|
|
}
|
|
|
|
- profiler.popPush("tickTickingChunks");
|
|
this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations
|
|
- profiler.pop();
|
|
- profiler.popPush("customSpawners");
|
|
if (_boolean) {
|
|
this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
|
|
}
|
|
@@ -817,7 +790,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
|
|
|
@Override
|
|
protected void doRunTask(Runnable task) {
|
|
- Profiler.get().incrementCounter("runTask");
|
|
super.doRunTask(task);
|
|
}
|
|
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 3c7159d0981c948e71a5612ba4083accb5849ed4..5f2c27800f047f128857044493a6d9325ffd759b 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -75,8 +75,6 @@ import net.minecraft.util.Mth;
|
|
import net.minecraft.util.ProgressListener;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.datafix.DataFixTypes;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.util.valueproviders.IntProvider;
|
|
import net.minecraft.util.valueproviders.UniformInt;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
@@ -729,16 +727,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
|
|
public void tick(BooleanSupplier hasTimeLeft) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
this.handlingTick = true;
|
|
TickRateManager tickRateManager = this.tickRateManager();
|
|
boolean runsNormally = tickRateManager.runsNormally();
|
|
if (runsNormally) {
|
|
- profilerFiller.push("world border");
|
|
this.getWorldBorder().tick();
|
|
- profilerFiller.popPush("weather");
|
|
this.advanceWeatherCycle();
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
|
|
@@ -772,41 +766,30 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
this.tickTime();
|
|
}
|
|
|
|
- profilerFiller.push("tickPending");
|
|
if (!this.isDebug() && runsNormally) {
|
|
long l = this.getGameTime();
|
|
- profilerFiller.push("blockTicks");
|
|
this.blockTicks.tick(l, paperConfig().environment.maxBlockTicks, this::tickBlock); // Paper - configurable max block ticks
|
|
- profilerFiller.popPush("fluidTicks");
|
|
this.fluidTicks.tick(l, paperConfig().environment.maxFluidTicks, this::tickFluid); // Paper - configurable max fluid ticks
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
- profilerFiller.popPush("raid");
|
|
if (runsNormally) {
|
|
this.raids.tick(this);
|
|
}
|
|
|
|
- profilerFiller.popPush("chunkSource");
|
|
this.getChunkSource().tick(hasTimeLeft, true);
|
|
- profilerFiller.popPush("blockEvents");
|
|
if (runsNormally) {
|
|
this.runBlockEvents();
|
|
}
|
|
|
|
this.handlingTick = false;
|
|
- profilerFiller.pop();
|
|
boolean flag = !paperConfig().unsupportedSettings.disableWorldTickingWhenEmpty || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players // Paper - restore this
|
|
if (flag) {
|
|
this.resetEmptyTime();
|
|
}
|
|
|
|
if (flag || this.emptyTime++ < 300) {
|
|
- profilerFiller.push("entities");
|
|
if (this.dragonFight != null && runsNormally) {
|
|
- profilerFiller.push("dragonFight");
|
|
this.dragonFight.tick();
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR
|
|
@@ -815,9 +798,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
entity -> {
|
|
if (!entity.isRemoved()) {
|
|
if (!tickRateManager.isEntityFrozen(entity)) {
|
|
- profilerFiller.push("checkDespawn");
|
|
entity.checkDespawn();
|
|
- profilerFiller.pop();
|
|
if (true) { // Paper - rewrite chunk system
|
|
Entity vehicle = entity.getVehicle();
|
|
if (vehicle != null) {
|
|
@@ -828,21 +809,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
entity.stopRiding();
|
|
}
|
|
|
|
- profilerFiller.push("tick");
|
|
this.guardEntityTick(this::tickNonPassenger, entity);
|
|
- profilerFiller.pop();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
- profilerFiller.pop();
|
|
this.tickBlockEntities();
|
|
}
|
|
|
|
- profilerFiller.push("entityManagement");
|
|
// Paper - rewrite chunk system
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
@Override
|
|
@@ -857,9 +833,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
if (this.tickTime) {
|
|
long l = this.levelData.getGameTime() + 1L;
|
|
this.serverLevelData.setGameTime(l);
|
|
- Profiler.get().push("scheduledFunctions");
|
|
this.serverLevelData.getScheduledEvents().tick(this.server, l);
|
|
- Profiler.get().pop();
|
|
if (this.serverLevelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
|
// Purpur start - Configurable daylight cycle
|
|
int incrementTicks = isBrightOutside() ? this.purpurConfig.daytimeTicks : this.purpurConfig.nighttimeTicks;
|
|
@@ -959,8 +933,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
ChunkPos pos = chunk.getPos();
|
|
int minBlockX = pos.getMinBlockX();
|
|
int minBlockZ = pos.getMinBlockZ();
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("iceandsnow");
|
|
|
|
if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow
|
|
for (int i = 0; i < randomTickSpeed; i++) {
|
|
@@ -970,12 +942,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
} // Paper - Option to disable ice and snow
|
|
|
|
- profilerFiller.popPush("tickBlocks");
|
|
if (randomTickSpeed > 0) {
|
|
this.optimiseRandomTick(chunk, randomTickSpeed); // Paper - optimise random ticking
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
public void tickThunder(LevelChunk chunk) {
|
|
@@ -983,8 +952,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
boolean isRaining = this.isRaining();
|
|
int minBlockX = pos.getMinBlockX();
|
|
int minBlockZ = pos.getMinBlockZ();
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("thunder");
|
|
if (!this.paperConfig().environment.disableThunder && isRaining && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder
|
|
BlockPos blockPos = this.findLightningTargetAround(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15));
|
|
if (this.isRainingAt(blockPos)) {
|
|
@@ -1018,8 +985,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
}
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
@VisibleForTesting
|
|
@@ -1363,17 +1328,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
// Paper end - log detailed entity tick information
|
|
entity.setOldPosAndRot();
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
entity.tickCount++;
|
|
entity.totalEntityAge++; // Paper - age-like counter for all entities
|
|
- profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString());
|
|
- profilerFiller.incrementCounter("tickNonPassenger");
|
|
final boolean isActive = io.papermc.paper.entity.activation.ActivationRange.checkIfActive(entity); // Paper - EAR 2
|
|
if (isActive) { // Paper - EAR 2
|
|
entity.tick();
|
|
entity.postTick(); // CraftBukkit
|
|
} else {entity.inactiveTick();} // Paper - EAR 2
|
|
- profilerFiller.pop();
|
|
|
|
for (Entity entity1 : entity.getPassengers()) {
|
|
this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2
|
|
@@ -1394,9 +1355,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
passengerEntity.setOldPosAndRot();
|
|
passengerEntity.tickCount++;
|
|
passengerEntity.totalEntityAge++; // Paper - age-like counter for all entities
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(passengerEntity.getType()).toString());
|
|
- profilerFiller.incrementCounter("tickPassenger");
|
|
// Paper start - EAR 2
|
|
if (isActive) {
|
|
passengerEntity.rideTick();
|
|
@@ -1408,7 +1366,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
ridingEntity.positionRider(passengerEntity);
|
|
}
|
|
// Paper end - EAR 2
|
|
- profilerFiller.pop();
|
|
|
|
for (Entity entity : passengerEntity.getPassengers()) {
|
|
this.tickPassenger(passengerEntity, entity, isActive); // Paper - EAR 2
|
|
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
|
index ba9e1f5963aeda8b5ed52c7daaa2a9fe62006d3b..9a296776480af489561eb19c6ed18d9558ee746a 100644
|
|
--- a/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -106,8 +106,6 @@ import net.minecraft.util.HashOps;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.Unit;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.Container;
|
|
import net.minecraft.world.Difficulty;
|
|
import net.minecraft.world.InteractionHand;
|
|
@@ -1437,14 +1435,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
this.unsetRemoved();
|
|
*/
|
|
// CraftBukkit end
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("moving");
|
|
if (level != null && resourceKey == net.minecraft.world.level.dimension.LevelStem.OVERWORLD && level.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit - empty to fall through to null to event
|
|
this.enteredNetherPosition = this.position();
|
|
}
|
|
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("placing");
|
|
// CraftBukkit start
|
|
this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
|
|
LevelData worlddata = level.getLevelData();
|
|
@@ -1462,7 +1456,6 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
|
this.connection.internalTeleport(PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); // CraftBukkit - use internal teleport without event
|
|
this.connection.resetPosition();
|
|
level.addDuringTeleport(this);
|
|
- profilerFiller.pop();
|
|
this.triggerDimensionChangeTriggers(serverLevel);
|
|
this.stopUsingItem();
|
|
this.connection.send(new ClientboundPlayerAbilitiesPacket(this.getAbilities()));
|
|
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
index 63aba275b1b714e3f0d5761709a115b214d0ca69..667ef5b2ab50eeb0491f7fe0bc8913ec29a4603a 100644
|
|
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
@@ -26,7 +26,6 @@ import net.minecraft.network.protocol.cookie.ServerboundCookieResponsePacket;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.level.ClientInformation;
|
|
import net.minecraft.util.VisibleForDebug;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
import org.slf4j.Logger;
|
|
|
|
public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener {
|
|
@@ -283,7 +282,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
}
|
|
|
|
protected void keepConnectionAlive() {
|
|
- Profiler.get().push("keepAlive");
|
|
long millis = Util.getMillis();
|
|
// Paper start - improve keepalives
|
|
// Purpur start - Alternative Keepalive Handling
|
|
@@ -321,8 +319,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
// Paper end - improve keepalives
|
|
}
|
|
}
|
|
-
|
|
- Profiler.get().pop();
|
|
}
|
|
|
|
private boolean checkIfClosed(long time) {
|
|
diff --git a/net/minecraft/server/packs/resources/ProfiledReloadInstance.java b/net/minecraft/server/packs/resources/ProfiledReloadInstance.java
|
|
index f0e2bca572c6f1790772980cd3ec651e9077382d..954e4103c9c359bc13c9a07bec885af90df14cb5 100644
|
|
--- a/net/minecraft/server/packs/resources/ProfiledReloadInstance.java
|
|
+++ b/net/minecraft/server/packs/resources/ProfiledReloadInstance.java
|
|
@@ -9,8 +9,6 @@ import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
import net.minecraft.Util;
|
|
import net.minecraft.util.Unit;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import org.slf4j.Logger;
|
|
|
|
public class ProfiledReloadInstance extends SimpleReloadInstance<ProfiledReloadInstance.State> {
|
|
@@ -71,13 +69,10 @@ public class ProfiledReloadInstance extends SimpleReloadInstance<ProfiledReloadI
|
|
|
|
private static Executor profiledExecutor(Executor executor, AtomicLong timeTaken, AtomicLong timesRun, String name) {
|
|
return runnable -> executor.execute(() -> {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push(name);
|
|
long nanos = Util.getNanos();
|
|
runnable.run();
|
|
timeTaken.addAndGet(Util.getNanos() - nanos);
|
|
timesRun.incrementAndGet();
|
|
- profilerFiller.pop();
|
|
});
|
|
}
|
|
|
|
diff --git a/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java b/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java
|
|
index 407bd4b8026869bc14ee5e79ff80e7bdd1a07bcb..a174e00278356193a2d19172902ac699f8dfb669 100644
|
|
--- a/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java
|
|
+++ b/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java
|
|
@@ -3,8 +3,6 @@ package net.minecraft.server.packs.resources;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.Executor;
|
|
import net.minecraft.util.Unit;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
|
|
public interface ResourceManagerReloadListener extends PreparableReloadListener {
|
|
@Override
|
|
@@ -12,10 +10,7 @@ public interface ResourceManagerReloadListener extends PreparableReloadListener
|
|
PreparableReloadListener.PreparationBarrier barrier, ResourceManager manager, Executor backgroundExecutor, Executor gameExecutor
|
|
) {
|
|
return barrier.wait(Unit.INSTANCE).thenRunAsync(() -> {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("listener");
|
|
this.onResourceManagerReload(manager);
|
|
- profilerFiller.pop();
|
|
}, gameExecutor);
|
|
}
|
|
|
|
diff --git a/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java b/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java
|
|
index 16bab14884a5a7b8d7659379f5b7ea90aa9bd737..a2320c37e4ef495eae7a1978aa7c7dc642aefdf9 100644
|
|
--- a/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java
|
|
+++ b/net/minecraft/server/packs/resources/SimpleJsonResourceReloadListener.java
|
|
@@ -17,7 +17,6 @@ import net.minecraft.resources.FileToIdConverter;
|
|
import net.minecraft.resources.ResourceKey;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.util.StrictJsonParser;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import org.slf4j.Logger;
|
|
|
|
public abstract class SimpleJsonResourceReloadListener<T> extends SimplePreparableReloadListener<Map<ResourceLocation, T>> {
|
|
@@ -41,7 +40,7 @@ public abstract class SimpleJsonResourceReloadListener<T> extends SimplePreparab
|
|
}
|
|
|
|
@Override
|
|
- protected Map<ResourceLocation, T> prepare(ResourceManager resourceManager, ProfilerFiller profiler) {
|
|
+ protected Map<ResourceLocation, T> prepare(ResourceManager resourceManager) {
|
|
Map<ResourceLocation, T> map = new HashMap<>();
|
|
scanDirectory(resourceManager, this.lister, this.ops, this.codec, map);
|
|
return map;
|
|
diff --git a/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java b/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java
|
|
index 64b0508ef21952c65b0b967b756b2a4c64d96899..9682d64983d43f3c0142565e0cbb06f9fffef271 100644
|
|
--- a/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java
|
|
+++ b/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java
|
|
@@ -2,20 +2,18 @@ package net.minecraft.server.packs.resources;
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.Executor;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
|
|
public abstract class SimplePreparableReloadListener<T> implements PreparableReloadListener {
|
|
@Override
|
|
public final CompletableFuture<Void> reload(
|
|
PreparableReloadListener.PreparationBarrier barrier, ResourceManager manager, Executor backgroundExecutor, Executor gameExecutor
|
|
) {
|
|
- return CompletableFuture.<T>supplyAsync(() -> this.prepare(manager, Profiler.get()), backgroundExecutor)
|
|
+ return CompletableFuture.<T>supplyAsync(() -> this.prepare(manager), backgroundExecutor)
|
|
.thenCompose(barrier::wait)
|
|
- .thenAcceptAsync(object -> this.apply((T)object, manager, Profiler.get()), gameExecutor);
|
|
+ .thenAcceptAsync(object -> this.apply((T)object, manager), gameExecutor);
|
|
}
|
|
|
|
- protected abstract T prepare(ResourceManager resourceManager, ProfilerFiller profiler);
|
|
+ protected abstract T prepare(ResourceManager resourceManager);
|
|
|
|
- protected abstract void apply(T object, ResourceManager resourceManager, ProfilerFiller profiler);
|
|
+ protected abstract void apply(T object, ResourceManager resourceManager);
|
|
}
|
|
diff --git a/net/minecraft/util/profiling/ActiveProfiler.java b/net/minecraft/util/profiling/ActiveProfiler.java
|
|
deleted file mode 100644
|
|
index 365995455c5e076f145063ab9415b89139f76393..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/ActiveProfiler.java
|
|
+++ /dev/null
|
|
@@ -1,207 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import com.google.common.collect.Lists;
|
|
-import com.google.common.collect.Maps;
|
|
-import com.mojang.logging.LogUtils;
|
|
-import it.unimi.dsi.fastutil.longs.LongArrayList;
|
|
-import it.unimi.dsi.fastutil.longs.LongList;
|
|
-import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
|
-import it.unimi.dsi.fastutil.objects.Object2LongMaps;
|
|
-import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
|
-import it.unimi.dsi.fastutil.objects.ObjectArraySet;
|
|
-import java.time.Duration;
|
|
-import java.util.List;
|
|
-import java.util.Map;
|
|
-import java.util.Set;
|
|
-import java.util.function.BooleanSupplier;
|
|
-import java.util.function.IntSupplier;
|
|
-import java.util.function.LongSupplier;
|
|
-import java.util.function.Supplier;
|
|
-import javax.annotation.Nullable;
|
|
-import net.minecraft.Util;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import org.apache.commons.lang3.tuple.Pair;
|
|
-import org.slf4j.Logger;
|
|
-
|
|
-public class ActiveProfiler implements ProfileCollector {
|
|
- private static final long WARNING_TIME_NANOS = Duration.ofMillis(100L).toNanos();
|
|
- private static final Logger LOGGER = LogUtils.getLogger();
|
|
- private final List<String> paths = Lists.newArrayList();
|
|
- private final LongList startTimes = new LongArrayList();
|
|
- private final Map<String, ActiveProfiler.PathEntry> entries = Maps.newHashMap();
|
|
- private final IntSupplier getTickTime;
|
|
- private final LongSupplier getRealTime;
|
|
- private final long startTimeNano;
|
|
- private final int startTimeTicks;
|
|
- private String path = "";
|
|
- private boolean started;
|
|
- @Nullable
|
|
- private ActiveProfiler.PathEntry currentEntry;
|
|
- private final BooleanSupplier suppressWarnings;
|
|
- private final Set<Pair<String, MetricCategory>> chartedPaths = new ObjectArraySet<>();
|
|
-
|
|
- public ActiveProfiler(LongSupplier getRealTime, IntSupplier getTickTime, BooleanSupplier supressWarnings) {
|
|
- this.startTimeNano = getRealTime.getAsLong();
|
|
- this.getRealTime = getRealTime;
|
|
- this.startTimeTicks = getTickTime.getAsInt();
|
|
- this.getTickTime = getTickTime;
|
|
- this.suppressWarnings = supressWarnings;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void startTick() {
|
|
- if (this.started) {
|
|
- LOGGER.error("Profiler tick already started - missing endTick()?");
|
|
- } else {
|
|
- this.started = true;
|
|
- this.path = "";
|
|
- this.paths.clear();
|
|
- this.push("root");
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void endTick() {
|
|
- if (!this.started) {
|
|
- LOGGER.error("Profiler tick already ended - missing startTick()?");
|
|
- } else {
|
|
- this.pop();
|
|
- this.started = false;
|
|
- if (!this.path.isEmpty()) {
|
|
- LOGGER.error(
|
|
- "Profiler tick ended before path was fully popped (remainder: '{}'). Mismatched push/pop?",
|
|
- LogUtils.defer(() -> ProfileResults.demanglePath(this.path))
|
|
- );
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void push(String name) {
|
|
- if (!this.started) {
|
|
- LOGGER.error("Cannot push '{}' to profiler if profiler tick hasn't started - missing startTick()?", name);
|
|
- } else {
|
|
- if (!this.path.isEmpty()) {
|
|
- this.path = this.path + "\u001e";
|
|
- }
|
|
-
|
|
- this.path = this.path + name;
|
|
- this.paths.add(this.path);
|
|
- this.startTimes.add(Util.getNanos());
|
|
- this.currentEntry = null;
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void push(Supplier<String> nameSupplier) {
|
|
- this.push(nameSupplier.get());
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void markForCharting(MetricCategory category) {
|
|
- this.chartedPaths.add(Pair.of(this.path, category));
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void pop() {
|
|
- if (!this.started) {
|
|
- LOGGER.error("Cannot pop from profiler if profiler tick hasn't started - missing startTick()?");
|
|
- } else if (this.startTimes.isEmpty()) {
|
|
- LOGGER.error("Tried to pop one too many times! Mismatched push() and pop()?");
|
|
- } else {
|
|
- long nanos = Util.getNanos();
|
|
- long l = this.startTimes.removeLong(this.startTimes.size() - 1);
|
|
- this.paths.remove(this.paths.size() - 1);
|
|
- long l1 = nanos - l;
|
|
- ActiveProfiler.PathEntry currentEntry = this.getCurrentEntry();
|
|
- currentEntry.accumulatedDuration += l1;
|
|
- currentEntry.count++;
|
|
- currentEntry.maxDuration = Math.max(currentEntry.maxDuration, l1);
|
|
- currentEntry.minDuration = Math.min(currentEntry.minDuration, l1);
|
|
- if (l1 > WARNING_TIME_NANOS && !this.suppressWarnings.getAsBoolean()) {
|
|
- LOGGER.warn(
|
|
- "Something's taking too long! '{}' took aprox {} ms",
|
|
- LogUtils.defer(() -> ProfileResults.demanglePath(this.path)),
|
|
- LogUtils.defer(() -> l1 / 1000000.0)
|
|
- );
|
|
- }
|
|
-
|
|
- this.path = this.paths.isEmpty() ? "" : this.paths.get(this.paths.size() - 1);
|
|
- this.currentEntry = null;
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void popPush(String name) {
|
|
- this.pop();
|
|
- this.push(name);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void popPush(Supplier<String> nameSupplier) {
|
|
- this.pop();
|
|
- this.push(nameSupplier);
|
|
- }
|
|
-
|
|
- private ActiveProfiler.PathEntry getCurrentEntry() {
|
|
- if (this.currentEntry == null) {
|
|
- this.currentEntry = this.entries.computeIfAbsent(this.path, string -> new ActiveProfiler.PathEntry());
|
|
- }
|
|
-
|
|
- return this.currentEntry;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void incrementCounter(String counterName, int increment) {
|
|
- this.getCurrentEntry().counters.addTo(counterName, increment);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void incrementCounter(Supplier<String> counterNameSupplier, int increment) {
|
|
- this.getCurrentEntry().counters.addTo(counterNameSupplier.get(), increment);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public ProfileResults getResults() {
|
|
- return new FilledProfileResults(this.entries, this.startTimeNano, this.startTimeTicks, this.getRealTime.getAsLong(), this.getTickTime.getAsInt());
|
|
- }
|
|
-
|
|
- @Nullable
|
|
- @Override
|
|
- public ActiveProfiler.PathEntry getEntry(String entryId) {
|
|
- return this.entries.get(entryId);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public Set<Pair<String, MetricCategory>> getChartedPaths() {
|
|
- return this.chartedPaths;
|
|
- }
|
|
-
|
|
- public static class PathEntry implements ProfilerPathEntry {
|
|
- long maxDuration = Long.MIN_VALUE;
|
|
- long minDuration = Long.MAX_VALUE;
|
|
- long accumulatedDuration;
|
|
- long count;
|
|
- final Object2LongOpenHashMap<String> counters = new Object2LongOpenHashMap<>();
|
|
-
|
|
- @Override
|
|
- public long getDuration() {
|
|
- return this.accumulatedDuration;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getMaxDuration() {
|
|
- return this.maxDuration;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getCount() {
|
|
- return this.count;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public Object2LongMap<String> getCounters() {
|
|
- return Object2LongMaps.unmodifiable(this.counters);
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/ContinuousProfiler.java b/net/minecraft/util/profiling/ContinuousProfiler.java
|
|
deleted file mode 100644
|
|
index 553638f3140f2e0f2892adbf082b3af415424550..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/ContinuousProfiler.java
|
|
+++ /dev/null
|
|
@@ -1,38 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import java.util.function.BooleanSupplier;
|
|
-import java.util.function.IntSupplier;
|
|
-import java.util.function.LongSupplier;
|
|
-
|
|
-public class ContinuousProfiler {
|
|
- private final LongSupplier realTime;
|
|
- private final IntSupplier tickCount;
|
|
- private final BooleanSupplier suppressWarnings;
|
|
- private ProfileCollector profiler = InactiveProfiler.INSTANCE;
|
|
-
|
|
- public ContinuousProfiler(LongSupplier realTime, IntSupplier tickTime, BooleanSupplier supressWarnings) {
|
|
- this.realTime = realTime;
|
|
- this.tickCount = tickTime;
|
|
- this.suppressWarnings = supressWarnings;
|
|
- }
|
|
-
|
|
- public boolean isEnabled() {
|
|
- return this.profiler != InactiveProfiler.INSTANCE;
|
|
- }
|
|
-
|
|
- public void disable() {
|
|
- this.profiler = InactiveProfiler.INSTANCE;
|
|
- }
|
|
-
|
|
- public void enable() {
|
|
- this.profiler = new ActiveProfiler(this.realTime, this.tickCount, this.suppressWarnings);
|
|
- }
|
|
-
|
|
- public ProfilerFiller getFiller() {
|
|
- return this.profiler;
|
|
- }
|
|
-
|
|
- public ProfileResults getResults() {
|
|
- return this.profiler.getResults();
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/EmptyProfileResults.java b/net/minecraft/util/profiling/EmptyProfileResults.java
|
|
deleted file mode 100644
|
|
index 76930ff8c88c4cfc687d09653720ca05e87bec1a..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/EmptyProfileResults.java
|
|
+++ /dev/null
|
|
@@ -1,47 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import java.nio.file.Path;
|
|
-import java.util.Collections;
|
|
-import java.util.List;
|
|
-
|
|
-public class EmptyProfileResults implements ProfileResults {
|
|
- public static final EmptyProfileResults EMPTY = new EmptyProfileResults();
|
|
-
|
|
- private EmptyProfileResults() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public List<ResultField> getTimes(String sectionPath) {
|
|
- return Collections.emptyList();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean saveResults(Path path) {
|
|
- return false;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getStartTimeNano() {
|
|
- return 0L;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int getStartTimeTicks() {
|
|
- return 0;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getEndTimeNano() {
|
|
- return 0L;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int getEndTimeTicks() {
|
|
- return 0;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public String getProfilerResults() {
|
|
- return "";
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/FilledProfileResults.java b/net/minecraft/util/profiling/FilledProfileResults.java
|
|
deleted file mode 100644
|
|
index 2787f4e5e50939d44253f1b8301fb24a2974ae11..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/FilledProfileResults.java
|
|
+++ /dev/null
|
|
@@ -1,313 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import com.google.common.base.Splitter;
|
|
-import com.google.common.collect.Lists;
|
|
-import com.google.common.collect.Maps;
|
|
-import com.mojang.logging.LogUtils;
|
|
-import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
|
-import it.unimi.dsi.fastutil.objects.Object2LongMaps;
|
|
-import java.io.Writer;
|
|
-import java.nio.charset.StandardCharsets;
|
|
-import java.nio.file.Files;
|
|
-import java.nio.file.Path;
|
|
-import java.util.Collections;
|
|
-import java.util.Comparator;
|
|
-import java.util.Iterator;
|
|
-import java.util.List;
|
|
-import java.util.Locale;
|
|
-import java.util.Map;
|
|
-import java.util.Map.Entry;
|
|
-import net.minecraft.ReportType;
|
|
-import net.minecraft.SharedConstants;
|
|
-import org.apache.commons.io.IOUtils;
|
|
-import org.apache.commons.lang3.ObjectUtils;
|
|
-import org.slf4j.Logger;
|
|
-
|
|
-public class FilledProfileResults implements ProfileResults {
|
|
- private static final Logger LOGGER = LogUtils.getLogger();
|
|
- private static final ProfilerPathEntry EMPTY = new ProfilerPathEntry() {
|
|
- @Override
|
|
- public long getDuration() {
|
|
- return 0L;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getMaxDuration() {
|
|
- return 0L;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getCount() {
|
|
- return 0L;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public Object2LongMap<String> getCounters() {
|
|
- return Object2LongMaps.emptyMap();
|
|
- }
|
|
- };
|
|
- private static final Splitter SPLITTER = Splitter.on('\u001e');
|
|
- private static final Comparator<Entry<String, FilledProfileResults.CounterCollector>> COUNTER_ENTRY_COMPARATOR = Entry.<String, FilledProfileResults.CounterCollector>comparingByValue(
|
|
- Comparator.comparingLong(counterCollector -> counterCollector.totalValue)
|
|
- )
|
|
- .reversed();
|
|
- private final Map<String, ? extends ProfilerPathEntry> entries;
|
|
- private final long startTimeNano;
|
|
- private final int startTimeTicks;
|
|
- private final long endTimeNano;
|
|
- private final int endTimeTicks;
|
|
- private final int tickDuration;
|
|
-
|
|
- public FilledProfileResults(Map<String, ? extends ProfilerPathEntry> entries, long startTimeNano, int startTimeTicks, long endTimeNano, int endTimeTicks) {
|
|
- this.entries = entries;
|
|
- this.startTimeNano = startTimeNano;
|
|
- this.startTimeTicks = startTimeTicks;
|
|
- this.endTimeNano = endTimeNano;
|
|
- this.endTimeTicks = endTimeTicks;
|
|
- this.tickDuration = endTimeTicks - startTimeTicks;
|
|
- }
|
|
-
|
|
- private ProfilerPathEntry getEntry(String key) {
|
|
- ProfilerPathEntry profilerPathEntry = this.entries.get(key);
|
|
- return profilerPathEntry != null ? profilerPathEntry : EMPTY;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public List<ResultField> getTimes(String sectionPath) {
|
|
- String string = sectionPath;
|
|
- ProfilerPathEntry entry = this.getEntry("root");
|
|
- long duration = entry.getDuration();
|
|
- ProfilerPathEntry entry1 = this.getEntry(sectionPath);
|
|
- long duration1 = entry1.getDuration();
|
|
- long count = entry1.getCount();
|
|
- List<ResultField> list = Lists.newArrayList();
|
|
- if (!sectionPath.isEmpty()) {
|
|
- sectionPath = sectionPath + "\u001e";
|
|
- }
|
|
-
|
|
- long l = 0L;
|
|
-
|
|
- for (String string1 : this.entries.keySet()) {
|
|
- if (isDirectChild(sectionPath, string1)) {
|
|
- l += this.getEntry(string1).getDuration();
|
|
- }
|
|
- }
|
|
-
|
|
- float f = (float)l;
|
|
- if (l < duration1) {
|
|
- l = duration1;
|
|
- }
|
|
-
|
|
- if (duration < l) {
|
|
- duration = l;
|
|
- }
|
|
-
|
|
- for (String string2 : this.entries.keySet()) {
|
|
- if (isDirectChild(sectionPath, string2)) {
|
|
- ProfilerPathEntry entry2 = this.getEntry(string2);
|
|
- long duration2 = entry2.getDuration();
|
|
- double d = duration2 * 100.0 / l;
|
|
- double d1 = duration2 * 100.0 / duration;
|
|
- String sub = string2.substring(sectionPath.length());
|
|
- list.add(new ResultField(sub, d, d1, entry2.getCount()));
|
|
- }
|
|
- }
|
|
-
|
|
- if ((float)l > f) {
|
|
- list.add(new ResultField("unspecified", ((float)l - f) * 100.0 / l, ((float)l - f) * 100.0 / duration, count));
|
|
- }
|
|
-
|
|
- Collections.sort(list);
|
|
- list.add(0, new ResultField(string, 100.0, l * 100.0 / duration, count));
|
|
- return list;
|
|
- }
|
|
-
|
|
- private static boolean isDirectChild(String sectionPath, String entry) {
|
|
- return entry.length() > sectionPath.length() && entry.startsWith(sectionPath) && entry.indexOf(30, sectionPath.length() + 1) < 0;
|
|
- }
|
|
-
|
|
- private Map<String, FilledProfileResults.CounterCollector> getCounterValues() {
|
|
- Map<String, FilledProfileResults.CounterCollector> map = Maps.newTreeMap();
|
|
- this.entries
|
|
- .forEach(
|
|
- (string, profilerPathEntry) -> {
|
|
- Object2LongMap<String> counters = profilerPathEntry.getCounters();
|
|
- if (!counters.isEmpty()) {
|
|
- List<String> parts = SPLITTER.splitToList(string);
|
|
- counters.forEach(
|
|
- (string1, _long) -> map.computeIfAbsent(string1, string2 -> new FilledProfileResults.CounterCollector())
|
|
- .addValue(parts.iterator(), _long)
|
|
- );
|
|
- }
|
|
- }
|
|
- );
|
|
- return map;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getStartTimeNano() {
|
|
- return this.startTimeNano;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int getStartTimeTicks() {
|
|
- return this.startTimeTicks;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public long getEndTimeNano() {
|
|
- return this.endTimeNano;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int getEndTimeTicks() {
|
|
- return this.endTimeTicks;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean saveResults(Path path) {
|
|
- Writer writer = null;
|
|
-
|
|
- boolean var4;
|
|
- try {
|
|
- Files.createDirectories(path.getParent());
|
|
- writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
|
|
- writer.write(this.getProfilerResults(this.getNanoDuration(), this.getTickDuration()));
|
|
- return true;
|
|
- } catch (Throwable var8) {
|
|
- LOGGER.error("Could not save profiler results to {}", path, var8);
|
|
- var4 = false;
|
|
- } finally {
|
|
- IOUtils.closeQuietly(writer);
|
|
- }
|
|
-
|
|
- return var4;
|
|
- }
|
|
-
|
|
- protected String getProfilerResults(long timeSpan, int tickSpan) {
|
|
- StringBuilder stringBuilder = new StringBuilder();
|
|
- ReportType.PROFILE.appendHeader(stringBuilder, List.of());
|
|
- stringBuilder.append("Version: ").append(SharedConstants.getCurrentVersion().id()).append('\n');
|
|
- stringBuilder.append("Time span: ").append(timeSpan / 1000000L).append(" ms\n");
|
|
- stringBuilder.append("Tick span: ").append(tickSpan).append(" ticks\n");
|
|
- stringBuilder.append("// This is approximately ")
|
|
- .append(String.format(Locale.ROOT, "%.2f", tickSpan / ((float)timeSpan / 1.0E9F)))
|
|
- .append(" ticks per second. It should be ")
|
|
- .append(20)
|
|
- .append(" ticks per second\n\n");
|
|
- stringBuilder.append("--- BEGIN PROFILE DUMP ---\n\n");
|
|
- this.appendProfilerResults(0, "root", stringBuilder);
|
|
- stringBuilder.append("--- END PROFILE DUMP ---\n\n");
|
|
- Map<String, FilledProfileResults.CounterCollector> counterValues = this.getCounterValues();
|
|
- if (!counterValues.isEmpty()) {
|
|
- stringBuilder.append("--- BEGIN COUNTER DUMP ---\n\n");
|
|
- this.appendCounters(counterValues, stringBuilder, tickSpan);
|
|
- stringBuilder.append("--- END COUNTER DUMP ---\n\n");
|
|
- }
|
|
-
|
|
- return stringBuilder.toString();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public String getProfilerResults() {
|
|
- StringBuilder stringBuilder = new StringBuilder();
|
|
- this.appendProfilerResults(0, "root", stringBuilder);
|
|
- return stringBuilder.toString();
|
|
- }
|
|
-
|
|
- private static StringBuilder indentLine(StringBuilder builder, int indents) {
|
|
- builder.append(String.format(Locale.ROOT, "[%02d] ", indents));
|
|
-
|
|
- for (int i = 0; i < indents; i++) {
|
|
- builder.append("| ");
|
|
- }
|
|
-
|
|
- return builder;
|
|
- }
|
|
-
|
|
- private void appendProfilerResults(int depth, String sectionPath, StringBuilder builder) {
|
|
- List<ResultField> times = this.getTimes(sectionPath);
|
|
- Object2LongMap<String> counters = ObjectUtils.firstNonNull(this.entries.get(sectionPath), EMPTY).getCounters();
|
|
- counters.forEach(
|
|
- (string, _long) -> indentLine(builder, depth)
|
|
- .append('#')
|
|
- .append(string)
|
|
- .append(' ')
|
|
- .append(_long)
|
|
- .append('/')
|
|
- .append(_long / this.tickDuration)
|
|
- .append('\n')
|
|
- );
|
|
- if (times.size() >= 3) {
|
|
- for (int i = 1; i < times.size(); i++) {
|
|
- ResultField resultField = times.get(i);
|
|
- indentLine(builder, depth)
|
|
- .append(resultField.name)
|
|
- .append('(')
|
|
- .append(resultField.count)
|
|
- .append('/')
|
|
- .append(String.format(Locale.ROOT, "%.0f", (float)resultField.count / this.tickDuration))
|
|
- .append(')')
|
|
- .append(" - ")
|
|
- .append(String.format(Locale.ROOT, "%.2f", resultField.percentage))
|
|
- .append("%/")
|
|
- .append(String.format(Locale.ROOT, "%.2f", resultField.globalPercentage))
|
|
- .append("%\n");
|
|
- if (!"unspecified".equals(resultField.name)) {
|
|
- try {
|
|
- this.appendProfilerResults(depth + 1, sectionPath + "\u001e" + resultField.name, builder);
|
|
- } catch (Exception var9) {
|
|
- builder.append("[[ EXCEPTION ").append(var9).append(" ]]");
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- private void appendCounterResults(int indents, String name, FilledProfileResults.CounterCollector collector, int tickSpan, StringBuilder builder) {
|
|
- indentLine(builder, indents)
|
|
- .append(name)
|
|
- .append(" total:")
|
|
- .append(collector.selfValue)
|
|
- .append('/')
|
|
- .append(collector.totalValue)
|
|
- .append(" average: ")
|
|
- .append(collector.selfValue / tickSpan)
|
|
- .append('/')
|
|
- .append(collector.totalValue / tickSpan)
|
|
- .append('\n');
|
|
- collector.children
|
|
- .entrySet()
|
|
- .stream()
|
|
- .sorted(COUNTER_ENTRY_COMPARATOR)
|
|
- .forEach(entry -> this.appendCounterResults(indents + 1, entry.getKey(), entry.getValue(), tickSpan, builder));
|
|
- }
|
|
-
|
|
- private void appendCounters(Map<String, FilledProfileResults.CounterCollector> counters, StringBuilder builder, int tickSpan) {
|
|
- counters.forEach((string, counterCollector) -> {
|
|
- builder.append("-- Counter: ").append(string).append(" --\n");
|
|
- this.appendCounterResults(0, "root", counterCollector.children.get("root"), tickSpan, builder);
|
|
- builder.append("\n\n");
|
|
- });
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int getTickDuration() {
|
|
- return this.tickDuration;
|
|
- }
|
|
-
|
|
- static class CounterCollector {
|
|
- long selfValue;
|
|
- long totalValue;
|
|
- final Map<String, FilledProfileResults.CounterCollector> children = Maps.newHashMap();
|
|
-
|
|
- public void addValue(Iterator<String> counters, long value) {
|
|
- this.totalValue += value;
|
|
- if (!counters.hasNext()) {
|
|
- this.selfValue += value;
|
|
- } else {
|
|
- this.children.computeIfAbsent(counters.next(), string -> new FilledProfileResults.CounterCollector()).addValue(counters, value);
|
|
- }
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/InactiveProfiler.java b/net/minecraft/util/profiling/InactiveProfiler.java
|
|
deleted file mode 100644
|
|
index dbeb1117938b0f118250bc66d41676bc35a6aa1e..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/InactiveProfiler.java
|
|
+++ /dev/null
|
|
@@ -1,81 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import com.google.common.collect.ImmutableSet;
|
|
-import java.util.Set;
|
|
-import java.util.function.Supplier;
|
|
-import javax.annotation.Nullable;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import org.apache.commons.lang3.tuple.Pair;
|
|
-
|
|
-public class InactiveProfiler implements ProfileCollector {
|
|
- public static final InactiveProfiler INSTANCE = new InactiveProfiler();
|
|
-
|
|
- private InactiveProfiler() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void startTick() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void endTick() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void push(String name) {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void push(Supplier<String> nameSupplier) {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void markForCharting(MetricCategory category) {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void pop() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void popPush(String name) {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void popPush(Supplier<String> nameSupplier) {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public Zone zone(String name) {
|
|
- return Zone.INACTIVE;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public Zone zone(Supplier<String> name) {
|
|
- return Zone.INACTIVE;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void incrementCounter(String counterName, int increment) {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void incrementCounter(Supplier<String> counterNameSupplier, int increment) {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public ProfileResults getResults() {
|
|
- return EmptyProfileResults.EMPTY;
|
|
- }
|
|
-
|
|
- @Nullable
|
|
- @Override
|
|
- public ActiveProfiler.PathEntry getEntry(String entryId) {
|
|
- return null;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public Set<Pair<String, MetricCategory>> getChartedPaths() {
|
|
- return ImmutableSet.of();
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/ProfileCollector.java b/net/minecraft/util/profiling/ProfileCollector.java
|
|
deleted file mode 100644
|
|
index 7ea05ee86d9afe648a5301bdd9fcff9b91e1ba36..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/ProfileCollector.java
|
|
+++ /dev/null
|
|
@@ -1,15 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import java.util.Set;
|
|
-import javax.annotation.Nullable;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import org.apache.commons.lang3.tuple.Pair;
|
|
-
|
|
-public interface ProfileCollector extends ProfilerFiller {
|
|
- ProfileResults getResults();
|
|
-
|
|
- @Nullable
|
|
- ActiveProfiler.PathEntry getEntry(String entryId);
|
|
-
|
|
- Set<Pair<String, MetricCategory>> getChartedPaths();
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/ProfileResults.java b/net/minecraft/util/profiling/ProfileResults.java
|
|
deleted file mode 100644
|
|
index 47d68f2b8d0dbe2f0e268c3d00eec434d8964f7a..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/ProfileResults.java
|
|
+++ /dev/null
|
|
@@ -1,34 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import java.nio.file.Path;
|
|
-import java.util.List;
|
|
-
|
|
-public interface ProfileResults {
|
|
- char PATH_SEPARATOR = '\u001e';
|
|
-
|
|
- List<ResultField> getTimes(String sectionPath);
|
|
-
|
|
- boolean saveResults(Path path);
|
|
-
|
|
- long getStartTimeNano();
|
|
-
|
|
- int getStartTimeTicks();
|
|
-
|
|
- long getEndTimeNano();
|
|
-
|
|
- int getEndTimeTicks();
|
|
-
|
|
- default long getNanoDuration() {
|
|
- return this.getEndTimeNano() - this.getStartTimeNano();
|
|
- }
|
|
-
|
|
- default int getTickDuration() {
|
|
- return this.getEndTimeTicks() - this.getStartTimeTicks();
|
|
- }
|
|
-
|
|
- String getProfilerResults();
|
|
-
|
|
- static String demanglePath(String path) {
|
|
- return path.replace('\u001e', '.');
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/Profiler.java b/net/minecraft/util/profiling/Profiler.java
|
|
deleted file mode 100644
|
|
index cbd57d68e169ed044f325a776075da78b473b6f3..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/Profiler.java
|
|
+++ /dev/null
|
|
@@ -1,58 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import com.mojang.jtracy.TracyClient;
|
|
-import java.util.Objects;
|
|
-import java.util.concurrent.atomic.AtomicInteger;
|
|
-
|
|
-public final class Profiler {
|
|
- private static final ThreadLocal<TracyZoneFiller> TRACY_FILLER = ThreadLocal.withInitial(TracyZoneFiller::new);
|
|
- private static final ThreadLocal<ProfilerFiller> ACTIVE = new ThreadLocal<>();
|
|
- private static final AtomicInteger ACTIVE_COUNT = new AtomicInteger();
|
|
-
|
|
- private Profiler() {
|
|
- }
|
|
-
|
|
- public static Profiler.Scope use(ProfilerFiller profiler) {
|
|
- startUsing(profiler);
|
|
- return Profiler::stopUsing;
|
|
- }
|
|
-
|
|
- private static void startUsing(ProfilerFiller profiler) {
|
|
- if (ACTIVE.get() != null) {
|
|
- throw new IllegalStateException("Profiler is already active");
|
|
- } else {
|
|
- ProfilerFiller profilerFiller = decorateFiller(profiler);
|
|
- ACTIVE.set(profilerFiller);
|
|
- ACTIVE_COUNT.incrementAndGet();
|
|
- profilerFiller.startTick();
|
|
- }
|
|
- }
|
|
-
|
|
- private static void stopUsing() {
|
|
- ProfilerFiller profilerFiller = ACTIVE.get();
|
|
- if (profilerFiller == null) {
|
|
- throw new IllegalStateException("Profiler was not active");
|
|
- } else {
|
|
- ACTIVE.remove();
|
|
- ACTIVE_COUNT.decrementAndGet();
|
|
- profilerFiller.endTick();
|
|
- }
|
|
- }
|
|
-
|
|
- private static ProfilerFiller decorateFiller(ProfilerFiller filler) {
|
|
- return ProfilerFiller.combine(getDefaultFiller(), filler);
|
|
- }
|
|
-
|
|
- public static ProfilerFiller get() {
|
|
- return ACTIVE_COUNT.get() == 0 ? getDefaultFiller() : Objects.requireNonNullElseGet(ACTIVE.get(), Profiler::getDefaultFiller);
|
|
- }
|
|
-
|
|
- private static ProfilerFiller getDefaultFiller() {
|
|
- return (ProfilerFiller)(TracyClient.isAvailable() ? TRACY_FILLER.get() : InactiveProfiler.INSTANCE);
|
|
- }
|
|
-
|
|
- public interface Scope extends AutoCloseable {
|
|
- @Override
|
|
- void close();
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/ProfilerFiller.java b/net/minecraft/util/profiling/ProfilerFiller.java
|
|
deleted file mode 100644
|
|
index aed01a8c918361d2302ba5219117e32aac98e19d..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/ProfilerFiller.java
|
|
+++ /dev/null
|
|
@@ -1,151 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import java.util.function.Supplier;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-
|
|
-public interface ProfilerFiller {
|
|
- String ROOT = "root";
|
|
-
|
|
- void startTick();
|
|
-
|
|
- void endTick();
|
|
-
|
|
- void push(String name);
|
|
-
|
|
- void push(Supplier<String> nameSupplier);
|
|
-
|
|
- void pop();
|
|
-
|
|
- void popPush(String name);
|
|
-
|
|
- void popPush(Supplier<String> nameSupplier);
|
|
-
|
|
- default void addZoneText(String text) {
|
|
- }
|
|
-
|
|
- default void addZoneValue(long value) {
|
|
- }
|
|
-
|
|
- default void setZoneColor(int color) {
|
|
- }
|
|
-
|
|
- default Zone zone(String name) {
|
|
- this.push(name);
|
|
- return new Zone(this);
|
|
- }
|
|
-
|
|
- default Zone zone(Supplier<String> name) {
|
|
- this.push(name);
|
|
- return new Zone(this);
|
|
- }
|
|
-
|
|
- void markForCharting(MetricCategory category);
|
|
-
|
|
- default void incrementCounter(String entryId) {
|
|
- this.incrementCounter(entryId, 1);
|
|
- }
|
|
-
|
|
- void incrementCounter(String counterName, int increment);
|
|
-
|
|
- default void incrementCounter(Supplier<String> entryIdSupplier) {
|
|
- this.incrementCounter(entryIdSupplier, 1);
|
|
- }
|
|
-
|
|
- void incrementCounter(Supplier<String> counterNameSupplier, int increment);
|
|
-
|
|
- static ProfilerFiller combine(ProfilerFiller first, ProfilerFiller second) {
|
|
- if (first == InactiveProfiler.INSTANCE) {
|
|
- return second;
|
|
- } else {
|
|
- return (ProfilerFiller)(second == InactiveProfiler.INSTANCE ? first : new ProfilerFiller.CombinedProfileFiller(first, second));
|
|
- }
|
|
- }
|
|
-
|
|
- public static class CombinedProfileFiller implements ProfilerFiller {
|
|
- private final ProfilerFiller first;
|
|
- private final ProfilerFiller second;
|
|
-
|
|
- public CombinedProfileFiller(ProfilerFiller first, ProfilerFiller second) {
|
|
- this.first = first;
|
|
- this.second = second;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void startTick() {
|
|
- this.first.startTick();
|
|
- this.second.startTick();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void endTick() {
|
|
- this.first.endTick();
|
|
- this.second.endTick();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void push(String name) {
|
|
- this.first.push(name);
|
|
- this.second.push(name);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void push(Supplier<String> nameSupplier) {
|
|
- this.first.push(nameSupplier);
|
|
- this.second.push(nameSupplier);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void markForCharting(MetricCategory category) {
|
|
- this.first.markForCharting(category);
|
|
- this.second.markForCharting(category);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void pop() {
|
|
- this.first.pop();
|
|
- this.second.pop();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void popPush(String name) {
|
|
- this.first.popPush(name);
|
|
- this.second.popPush(name);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void popPush(Supplier<String> nameSupplier) {
|
|
- this.first.popPush(nameSupplier);
|
|
- this.second.popPush(nameSupplier);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void incrementCounter(String counterName, int increment) {
|
|
- this.first.incrementCounter(counterName, increment);
|
|
- this.second.incrementCounter(counterName, increment);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void incrementCounter(Supplier<String> counterNameSupplier, int increment) {
|
|
- this.first.incrementCounter(counterNameSupplier, increment);
|
|
- this.second.incrementCounter(counterNameSupplier, increment);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void addZoneText(String text) {
|
|
- this.first.addZoneText(text);
|
|
- this.second.addZoneText(text);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void addZoneValue(long value) {
|
|
- this.first.addZoneValue(value);
|
|
- this.second.addZoneValue(value);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void setZoneColor(int color) {
|
|
- this.first.setZoneColor(color);
|
|
- this.second.setZoneColor(color);
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/ProfilerPathEntry.java b/net/minecraft/util/profiling/ProfilerPathEntry.java
|
|
deleted file mode 100644
|
|
index c073262f663309e6f73e67b303927b3996ea0c16..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/ProfilerPathEntry.java
|
|
+++ /dev/null
|
|
@@ -1,13 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
|
-
|
|
-public interface ProfilerPathEntry {
|
|
- long getDuration();
|
|
-
|
|
- long getMaxDuration();
|
|
-
|
|
- long getCount();
|
|
-
|
|
- Object2LongMap<String> getCounters();
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/ResultField.java b/net/minecraft/util/profiling/ResultField.java
|
|
deleted file mode 100644
|
|
index cdb8132e70b7c6b43aaf67510fb9e509bc9de0c4..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/ResultField.java
|
|
+++ /dev/null
|
|
@@ -1,28 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-public final class ResultField implements Comparable<ResultField> {
|
|
- public final double percentage;
|
|
- public final double globalPercentage;
|
|
- public final long count;
|
|
- public final String name;
|
|
-
|
|
- public ResultField(String name, double percentage, double globalPercentage, long count) {
|
|
- this.name = name;
|
|
- this.percentage = percentage;
|
|
- this.globalPercentage = globalPercentage;
|
|
- this.count = count;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int compareTo(ResultField resultField) {
|
|
- if (resultField.percentage < this.percentage) {
|
|
- return -1;
|
|
- } else {
|
|
- return resultField.percentage > this.percentage ? 1 : resultField.name.compareTo(this.name);
|
|
- }
|
|
- }
|
|
-
|
|
- public int getColor() {
|
|
- return (this.name.hashCode() & 11184810) + -12303292;
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/SingleTickProfiler.java b/net/minecraft/util/profiling/SingleTickProfiler.java
|
|
deleted file mode 100644
|
|
index 33b323b78b8210afeac1f592d36d03bf9c907a1d..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/SingleTickProfiler.java
|
|
+++ /dev/null
|
|
@@ -1,50 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import com.mojang.logging.LogUtils;
|
|
-import java.io.File;
|
|
-import java.util.function.LongSupplier;
|
|
-import javax.annotation.Nullable;
|
|
-import net.minecraft.Util;
|
|
-import org.slf4j.Logger;
|
|
-
|
|
-public class SingleTickProfiler {
|
|
- private static final Logger LOGGER = LogUtils.getLogger();
|
|
- private final LongSupplier realTime;
|
|
- private final long saveThreshold;
|
|
- private int tick;
|
|
- private final File location;
|
|
- private ProfileCollector profiler = InactiveProfiler.INSTANCE;
|
|
-
|
|
- public SingleTickProfiler(LongSupplier realTime, String location, long saveThreshold) {
|
|
- this.realTime = realTime;
|
|
- this.location = new File("debug", location);
|
|
- this.saveThreshold = saveThreshold;
|
|
- }
|
|
-
|
|
- public ProfilerFiller startTick() {
|
|
- this.profiler = new ActiveProfiler(this.realTime, () -> this.tick, () -> true);
|
|
- this.tick++;
|
|
- return this.profiler;
|
|
- }
|
|
-
|
|
- public void endTick() {
|
|
- if (this.profiler != InactiveProfiler.INSTANCE) {
|
|
- ProfileResults results = this.profiler.getResults();
|
|
- this.profiler = InactiveProfiler.INSTANCE;
|
|
- if (results.getNanoDuration() >= this.saveThreshold) {
|
|
- File file = new File(this.location, "tick-results-" + Util.getFilenameFormattedDateTime() + ".txt");
|
|
- results.saveResults(file.toPath());
|
|
- LOGGER.info("Recorded long tick -- wrote info to: {}", file.getAbsolutePath());
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- @Nullable
|
|
- public static SingleTickProfiler createTickProfiler(String name) {
|
|
- return null;
|
|
- }
|
|
-
|
|
- public static ProfilerFiller decorateFiller(ProfilerFiller profiler, @Nullable SingleTickProfiler singleTickProfiler) {
|
|
- return singleTickProfiler != null ? ProfilerFiller.combine(singleTickProfiler.startTick(), profiler) : profiler;
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/TracyZoneFiller.java b/net/minecraft/util/profiling/TracyZoneFiller.java
|
|
deleted file mode 100644
|
|
index 4f855149f2a06379ecdc7d9218e40ef4887e1d6f..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/TracyZoneFiller.java
|
|
+++ /dev/null
|
|
@@ -1,140 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import com.mojang.jtracy.Plot;
|
|
-import com.mojang.jtracy.TracyClient;
|
|
-import com.mojang.logging.LogUtils;
|
|
-import java.lang.StackWalker.Option;
|
|
-import java.lang.StackWalker.StackFrame;
|
|
-import java.util.ArrayList;
|
|
-import java.util.HashMap;
|
|
-import java.util.List;
|
|
-import java.util.Map;
|
|
-import java.util.Optional;
|
|
-import java.util.Set;
|
|
-import java.util.function.Supplier;
|
|
-import net.minecraft.SharedConstants;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import org.slf4j.Logger;
|
|
-
|
|
-public class TracyZoneFiller implements ProfilerFiller {
|
|
- private static final Logger LOGGER = LogUtils.getLogger();
|
|
- private static final StackWalker STACK_WALKER = StackWalker.getInstance(Set.of(Option.RETAIN_CLASS_REFERENCE), 5);
|
|
- private final List<com.mojang.jtracy.Zone> activeZones = new ArrayList<>();
|
|
- private final Map<String, TracyZoneFiller.PlotAndValue> plots = new HashMap<>();
|
|
- private final String name = Thread.currentThread().getName();
|
|
-
|
|
- @Override
|
|
- public void startTick() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void endTick() {
|
|
- for (TracyZoneFiller.PlotAndValue plotAndValue : this.plots.values()) {
|
|
- plotAndValue.set(0);
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void push(String name) {
|
|
- String string = "";
|
|
- String string1 = "";
|
|
- int i = 0;
|
|
- if (SharedConstants.IS_RUNNING_IN_IDE) {
|
|
- Optional<StackFrame> optional = STACK_WALKER.walk(
|
|
- stream -> stream.filter(
|
|
- stackFrame1 -> stackFrame1.getDeclaringClass() != TracyZoneFiller.class
|
|
- && stackFrame1.getDeclaringClass() != ProfilerFiller.CombinedProfileFiller.class
|
|
- )
|
|
- .findFirst()
|
|
- );
|
|
- if (optional.isPresent()) {
|
|
- StackFrame stackFrame = optional.get();
|
|
- string = stackFrame.getMethodName();
|
|
- string1 = stackFrame.getFileName();
|
|
- i = stackFrame.getLineNumber();
|
|
- }
|
|
- }
|
|
-
|
|
- com.mojang.jtracy.Zone zone = TracyClient.beginZone(name, string, string1, i);
|
|
- this.activeZones.add(zone);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void push(Supplier<String> nameSupplier) {
|
|
- this.push(nameSupplier.get());
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void pop() {
|
|
- if (this.activeZones.isEmpty()) {
|
|
- LOGGER.error("Tried to pop one too many times! Mismatched push() and pop()?");
|
|
- } else {
|
|
- com.mojang.jtracy.Zone zone = this.activeZones.removeLast();
|
|
- zone.close();
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void popPush(String name) {
|
|
- this.pop();
|
|
- this.push(name);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void popPush(Supplier<String> nameSupplier) {
|
|
- this.pop();
|
|
- this.push(nameSupplier.get());
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void markForCharting(MetricCategory category) {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void incrementCounter(String counterName, int increment) {
|
|
- this.plots.computeIfAbsent(counterName, string -> new TracyZoneFiller.PlotAndValue(this.name + " " + counterName)).add(increment);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void incrementCounter(Supplier<String> counterNameSupplier, int increment) {
|
|
- this.incrementCounter(counterNameSupplier.get(), increment);
|
|
- }
|
|
-
|
|
- private com.mojang.jtracy.Zone activeZone() {
|
|
- return this.activeZones.getLast();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void addZoneText(String text) {
|
|
- this.activeZone().addText(text);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void addZoneValue(long value) {
|
|
- this.activeZone().addValue(value);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void setZoneColor(int color) {
|
|
- this.activeZone().setColor(color);
|
|
- }
|
|
-
|
|
- static final class PlotAndValue {
|
|
- private final Plot plot;
|
|
- private int value;
|
|
-
|
|
- PlotAndValue(String name) {
|
|
- this.plot = TracyClient.createPlot(name);
|
|
- this.value = 0;
|
|
- }
|
|
-
|
|
- void set(int value) {
|
|
- this.value = value;
|
|
- this.plot.setValue(value);
|
|
- }
|
|
-
|
|
- void add(int value) {
|
|
- this.set(this.value + value);
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/Zone.java b/net/minecraft/util/profiling/Zone.java
|
|
deleted file mode 100644
|
|
index 01bd7726e89f2e1b3c16a39b18385fcbb8716ebc..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/Zone.java
|
|
+++ /dev/null
|
|
@@ -1,53 +0,0 @@
|
|
-package net.minecraft.util.profiling;
|
|
-
|
|
-import java.util.function.Supplier;
|
|
-import javax.annotation.Nullable;
|
|
-
|
|
-public class Zone implements AutoCloseable {
|
|
- public static final Zone INACTIVE = new Zone(null);
|
|
- @Nullable
|
|
- private final ProfilerFiller profiler;
|
|
-
|
|
- Zone(@Nullable ProfilerFiller profiler) {
|
|
- this.profiler = profiler;
|
|
- }
|
|
-
|
|
- public Zone addText(String text) {
|
|
- if (this.profiler != null) {
|
|
- this.profiler.addZoneText(text);
|
|
- }
|
|
-
|
|
- return this;
|
|
- }
|
|
-
|
|
- public Zone addText(Supplier<String> text) {
|
|
- if (this.profiler != null) {
|
|
- this.profiler.addZoneText(text.get());
|
|
- }
|
|
-
|
|
- return this;
|
|
- }
|
|
-
|
|
- public Zone addValue(long value) {
|
|
- if (this.profiler != null) {
|
|
- this.profiler.addZoneValue(value);
|
|
- }
|
|
-
|
|
- return this;
|
|
- }
|
|
-
|
|
- public Zone setColor(int color) {
|
|
- if (this.profiler != null) {
|
|
- this.profiler.setZoneColor(color);
|
|
- }
|
|
-
|
|
- return this;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void close() {
|
|
- if (this.profiler != null) {
|
|
- this.profiler.pop();
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/MetricCategory.java b/net/minecraft/util/profiling/metrics/MetricCategory.java
|
|
deleted file mode 100644
|
|
index 6bf739dc8f427bd4368431aa060a06845141fedb..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/MetricCategory.java
|
|
+++ /dev/null
|
|
@@ -1,23 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics;
|
|
-
|
|
-public enum MetricCategory {
|
|
- PATH_FINDING("pathfinding"),
|
|
- EVENT_LOOPS("event-loops"),
|
|
- CONSECUTIVE_EXECUTORS("consecutive-executors"),
|
|
- TICK_LOOP("ticking"),
|
|
- JVM("jvm"),
|
|
- CHUNK_RENDERING("chunk rendering"),
|
|
- CHUNK_RENDERING_DISPATCHING("chunk rendering dispatching"),
|
|
- CPU("cpu"),
|
|
- GPU("gpu");
|
|
-
|
|
- private final String description;
|
|
-
|
|
- private MetricCategory(final String description) {
|
|
- this.description = description;
|
|
- }
|
|
-
|
|
- public String getDescription() {
|
|
- return this.description;
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/MetricSampler.java b/net/minecraft/util/profiling/metrics/MetricSampler.java
|
|
deleted file mode 100644
|
|
index 5fa1d836bc9326a461331ff19e234e4dd3b15df5..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/MetricSampler.java
|
|
+++ /dev/null
|
|
@@ -1,213 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics;
|
|
-
|
|
-import io.netty.buffer.ByteBuf;
|
|
-import io.netty.buffer.ByteBufAllocator;
|
|
-import it.unimi.dsi.fastutil.ints.Int2DoubleMap;
|
|
-import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
|
|
-import java.util.Locale;
|
|
-import java.util.function.Consumer;
|
|
-import java.util.function.DoubleSupplier;
|
|
-import java.util.function.ToDoubleFunction;
|
|
-import javax.annotation.Nullable;
|
|
-
|
|
-public class MetricSampler {
|
|
- private final String name;
|
|
- private final MetricCategory category;
|
|
- private final DoubleSupplier sampler;
|
|
- private final ByteBuf ticks;
|
|
- private final ByteBuf values;
|
|
- private volatile boolean isRunning;
|
|
- @Nullable
|
|
- private final Runnable beforeTick;
|
|
- @Nullable
|
|
- final MetricSampler.ThresholdTest thresholdTest;
|
|
- private double currentValue;
|
|
-
|
|
- protected MetricSampler(
|
|
- String name, MetricCategory category, DoubleSupplier sampler, @Nullable Runnable beforeTick, @Nullable MetricSampler.ThresholdTest thresholdTest
|
|
- ) {
|
|
- this.name = name;
|
|
- this.category = category;
|
|
- this.beforeTick = beforeTick;
|
|
- this.sampler = sampler;
|
|
- this.thresholdTest = thresholdTest;
|
|
- this.values = ByteBufAllocator.DEFAULT.buffer();
|
|
- this.ticks = ByteBufAllocator.DEFAULT.buffer();
|
|
- this.isRunning = true;
|
|
- }
|
|
-
|
|
- public static MetricSampler create(String name, MetricCategory category, DoubleSupplier sampler) {
|
|
- return new MetricSampler(name, category, sampler, null, null);
|
|
- }
|
|
-
|
|
- public static <T> MetricSampler create(String name, MetricCategory category, T context, ToDoubleFunction<T> sampler) {
|
|
- return builder(name, category, sampler, context).build();
|
|
- }
|
|
-
|
|
- public static <T> MetricSampler.MetricSamplerBuilder<T> builder(String name, MetricCategory category, ToDoubleFunction<T> sampler, T context) {
|
|
- return new MetricSampler.MetricSamplerBuilder<>(name, category, sampler, context);
|
|
- }
|
|
-
|
|
- public void onStartTick() {
|
|
- if (!this.isRunning) {
|
|
- throw new IllegalStateException("Not running");
|
|
- } else {
|
|
- if (this.beforeTick != null) {
|
|
- this.beforeTick.run();
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- public void onEndTick(int tickTime) {
|
|
- this.verifyRunning();
|
|
- this.currentValue = this.sampler.getAsDouble();
|
|
- this.values.writeDouble(this.currentValue);
|
|
- this.ticks.writeInt(tickTime);
|
|
- }
|
|
-
|
|
- public void onFinished() {
|
|
- this.verifyRunning();
|
|
- this.values.release();
|
|
- this.ticks.release();
|
|
- this.isRunning = false;
|
|
- }
|
|
-
|
|
- private void verifyRunning() {
|
|
- if (!this.isRunning) {
|
|
- throw new IllegalStateException(String.format(Locale.ROOT, "Sampler for metric %s not started!", this.name));
|
|
- }
|
|
- }
|
|
-
|
|
- DoubleSupplier getSampler() {
|
|
- return this.sampler;
|
|
- }
|
|
-
|
|
- public String getName() {
|
|
- return this.name;
|
|
- }
|
|
-
|
|
- public MetricCategory getCategory() {
|
|
- return this.category;
|
|
- }
|
|
-
|
|
- public MetricSampler.SamplerResult result() {
|
|
- Int2DoubleMap map = new Int2DoubleOpenHashMap();
|
|
- int i = Integer.MIN_VALUE;
|
|
- int i1 = Integer.MIN_VALUE;
|
|
-
|
|
- while (this.values.isReadable(8)) {
|
|
- int _int = this.ticks.readInt();
|
|
- if (i == Integer.MIN_VALUE) {
|
|
- i = _int;
|
|
- }
|
|
-
|
|
- map.put(_int, this.values.readDouble());
|
|
- i1 = _int;
|
|
- }
|
|
-
|
|
- return new MetricSampler.SamplerResult(i, i1, map);
|
|
- }
|
|
-
|
|
- public boolean triggersThreshold() {
|
|
- return this.thresholdTest != null && this.thresholdTest.test(this.currentValue);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean equals(Object other) {
|
|
- if (this == other) {
|
|
- return true;
|
|
- } else if (other != null && this.getClass() == other.getClass()) {
|
|
- MetricSampler metricSampler = (MetricSampler)other;
|
|
- return this.name.equals(metricSampler.name) && this.category.equals(metricSampler.category);
|
|
- } else {
|
|
- return false;
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int hashCode() {
|
|
- return this.name.hashCode();
|
|
- }
|
|
-
|
|
- public static class MetricSamplerBuilder<T> {
|
|
- private final String name;
|
|
- private final MetricCategory category;
|
|
- private final DoubleSupplier sampler;
|
|
- private final T context;
|
|
- @Nullable
|
|
- private Runnable beforeTick;
|
|
- @Nullable
|
|
- private MetricSampler.ThresholdTest thresholdTest;
|
|
-
|
|
- public MetricSamplerBuilder(String name, MetricCategory category, ToDoubleFunction<T> sampler, T context) {
|
|
- this.name = name;
|
|
- this.category = category;
|
|
- this.sampler = () -> sampler.applyAsDouble(context);
|
|
- this.context = context;
|
|
- }
|
|
-
|
|
- public MetricSampler.MetricSamplerBuilder<T> withBeforeTick(Consumer<T> beforeTick) {
|
|
- this.beforeTick = () -> beforeTick.accept(this.context);
|
|
- return this;
|
|
- }
|
|
-
|
|
- public MetricSampler.MetricSamplerBuilder<T> withThresholdAlert(MetricSampler.ThresholdTest thresholdTest) {
|
|
- this.thresholdTest = thresholdTest;
|
|
- return this;
|
|
- }
|
|
-
|
|
- public MetricSampler build() {
|
|
- return new MetricSampler(this.name, this.category, this.sampler, this.beforeTick, this.thresholdTest);
|
|
- }
|
|
- }
|
|
-
|
|
- public static class SamplerResult {
|
|
- private final Int2DoubleMap recording;
|
|
- private final int firstTick;
|
|
- private final int lastTick;
|
|
-
|
|
- public SamplerResult(int firstTick, int lastTick, Int2DoubleMap recording) {
|
|
- this.firstTick = firstTick;
|
|
- this.lastTick = lastTick;
|
|
- this.recording = recording;
|
|
- }
|
|
-
|
|
- public double valueAtTick(int tick) {
|
|
- return this.recording.get(tick);
|
|
- }
|
|
-
|
|
- public int getFirstTick() {
|
|
- return this.firstTick;
|
|
- }
|
|
-
|
|
- public int getLastTick() {
|
|
- return this.lastTick;
|
|
- }
|
|
- }
|
|
-
|
|
- public interface ThresholdTest {
|
|
- boolean test(double value);
|
|
- }
|
|
-
|
|
- public static class ValueIncreasedByPercentage implements MetricSampler.ThresholdTest {
|
|
- private final float percentageIncreaseThreshold;
|
|
- private double previousValue = Double.MIN_VALUE;
|
|
-
|
|
- public ValueIncreasedByPercentage(float percentageIncreaseThreshold) {
|
|
- this.percentageIncreaseThreshold = percentageIncreaseThreshold;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean test(double value) {
|
|
- boolean flag;
|
|
- if (this.previousValue != Double.MIN_VALUE && !(value <= this.previousValue)) {
|
|
- flag = (value - this.previousValue) / this.previousValue >= this.percentageIncreaseThreshold;
|
|
- } else {
|
|
- flag = false;
|
|
- }
|
|
-
|
|
- this.previousValue = value;
|
|
- return flag;
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/MetricsRegistry.java b/net/minecraft/util/profiling/metrics/MetricsRegistry.java
|
|
deleted file mode 100644
|
|
index 9b6a6aa2e94ceffc014194d218a36925a54e7abc..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/MetricsRegistry.java
|
|
+++ /dev/null
|
|
@@ -1,85 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics;
|
|
-
|
|
-import java.util.List;
|
|
-import java.util.Map;
|
|
-import java.util.Objects;
|
|
-import java.util.WeakHashMap;
|
|
-import java.util.stream.Collectors;
|
|
-import javax.annotation.Nullable;
|
|
-
|
|
-public class MetricsRegistry {
|
|
- public static final MetricsRegistry INSTANCE = new MetricsRegistry();
|
|
- private final WeakHashMap<ProfilerMeasured, Void> measuredInstances = new WeakHashMap<>();
|
|
-
|
|
- private MetricsRegistry() {
|
|
- }
|
|
-
|
|
- public void add(ProfilerMeasured key) {
|
|
- this.measuredInstances.put(key, null);
|
|
- }
|
|
-
|
|
- public List<MetricSampler> getRegisteredSamplers() {
|
|
- Map<String, List<MetricSampler>> map = this.measuredInstances
|
|
- .keySet()
|
|
- .stream()
|
|
- .flatMap(profilerMeasured -> profilerMeasured.profiledMetrics().stream())
|
|
- .collect(Collectors.groupingBy(MetricSampler::getName));
|
|
- return aggregateDuplicates(map);
|
|
- }
|
|
-
|
|
- private static List<MetricSampler> aggregateDuplicates(Map<String, List<MetricSampler>> samplers) {
|
|
- return samplers.entrySet().stream().map(entry -> {
|
|
- String string = entry.getKey();
|
|
- List<MetricSampler> list = entry.getValue();
|
|
- return (MetricSampler)(list.size() > 1 ? new MetricsRegistry.AggregatedMetricSampler(string, list) : list.get(0));
|
|
- }).collect(Collectors.toList());
|
|
- }
|
|
-
|
|
- static class AggregatedMetricSampler extends MetricSampler {
|
|
- private final List<MetricSampler> delegates;
|
|
-
|
|
- AggregatedMetricSampler(String name, List<MetricSampler> delegates) {
|
|
- super(name, delegates.get(0).getCategory(), () -> averageValueFromDelegates(delegates), () -> beforeTick(delegates), thresholdTest(delegates));
|
|
- this.delegates = delegates;
|
|
- }
|
|
-
|
|
- private static MetricSampler.ThresholdTest thresholdTest(List<MetricSampler> samplers) {
|
|
- return value -> samplers.stream().anyMatch(metricSampler -> metricSampler.thresholdTest != null && metricSampler.thresholdTest.test(value));
|
|
- }
|
|
-
|
|
- private static void beforeTick(List<MetricSampler> samplers) {
|
|
- for (MetricSampler metricSampler : samplers) {
|
|
- metricSampler.onStartTick();
|
|
- }
|
|
- }
|
|
-
|
|
- private static double averageValueFromDelegates(List<MetricSampler> samplers) {
|
|
- double d = 0.0;
|
|
-
|
|
- for (MetricSampler metricSampler : samplers) {
|
|
- d += metricSampler.getSampler().getAsDouble();
|
|
- }
|
|
-
|
|
- return d / samplers.size();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean equals(@Nullable Object other) {
|
|
- if (this == other) {
|
|
- return true;
|
|
- } else if (other == null || this.getClass() != other.getClass()) {
|
|
- return false;
|
|
- } else if (!super.equals(other)) {
|
|
- return false;
|
|
- } else {
|
|
- MetricsRegistry.AggregatedMetricSampler aggregatedMetricSampler = (MetricsRegistry.AggregatedMetricSampler)other;
|
|
- return this.delegates.equals(aggregatedMetricSampler.delegates);
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public int hashCode() {
|
|
- return Objects.hash(super.hashCode(), this.delegates);
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/MetricsSamplerProvider.java b/net/minecraft/util/profiling/metrics/MetricsSamplerProvider.java
|
|
deleted file mode 100644
|
|
index a9bb6f4303e84f99d74a4285377cd9ea20ebed60..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/MetricsSamplerProvider.java
|
|
+++ /dev/null
|
|
@@ -1,9 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics;
|
|
-
|
|
-import java.util.Set;
|
|
-import java.util.function.Supplier;
|
|
-import net.minecraft.util.profiling.ProfileCollector;
|
|
-
|
|
-public interface MetricsSamplerProvider {
|
|
- Set<MetricSampler> samplers(Supplier<ProfileCollector> profiles);
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/ProfilerMeasured.java b/net/minecraft/util/profiling/metrics/ProfilerMeasured.java
|
|
deleted file mode 100644
|
|
index 3057e9caa1936d114e07b3dfbd0dffd8aca1223c..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/ProfilerMeasured.java
|
|
+++ /dev/null
|
|
@@ -1,7 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics;
|
|
-
|
|
-import java.util.List;
|
|
-
|
|
-public interface ProfilerMeasured {
|
|
- List<MetricSampler> profiledMetrics();
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/package-info.java b/net/minecraft/util/profiling/metrics/package-info.java
|
|
deleted file mode 100644
|
|
index 4cfaf358f9d7d07c8d58dc152a1c85d6c7824d57..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/package-info.java
|
|
+++ /dev/null
|
|
@@ -1,8 +0,0 @@
|
|
-@ParametersAreNonnullByDefault
|
|
-@MethodsReturnNonnullByDefault
|
|
-@FieldsAreNonnullByDefault
|
|
-package net.minecraft.util.profiling.metrics;
|
|
-
|
|
-import javax.annotation.ParametersAreNonnullByDefault;
|
|
-import net.minecraft.FieldsAreNonnullByDefault;
|
|
-import net.minecraft.MethodsReturnNonnullByDefault;
|
|
diff --git a/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java b/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java
|
|
deleted file mode 100644
|
|
index b26c1f0f07b38a3da8d81af915e8043d55d5060f..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/profiling/ActiveMetricsRecorder.java
|
|
+++ /dev/null
|
|
@@ -1,168 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics.profiling;
|
|
-
|
|
-import com.google.common.collect.ImmutableSet;
|
|
-import com.google.common.collect.Lists;
|
|
-import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
|
-import java.nio.file.Path;
|
|
-import java.time.Instant;
|
|
-import java.util.Collection;
|
|
-import java.util.HashSet;
|
|
-import java.util.List;
|
|
-import java.util.Map;
|
|
-import java.util.Set;
|
|
-import java.util.concurrent.Executor;
|
|
-import java.util.concurrent.TimeUnit;
|
|
-import java.util.function.Consumer;
|
|
-import java.util.function.LongSupplier;
|
|
-import javax.annotation.Nullable;
|
|
-import net.minecraft.util.profiling.ActiveProfiler;
|
|
-import net.minecraft.util.profiling.ContinuousProfiler;
|
|
-import net.minecraft.util.profiling.EmptyProfileResults;
|
|
-import net.minecraft.util.profiling.InactiveProfiler;
|
|
-import net.minecraft.util.profiling.ProfileCollector;
|
|
-import net.minecraft.util.profiling.ProfileResults;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
-import net.minecraft.util.profiling.metrics.MetricSampler;
|
|
-import net.minecraft.util.profiling.metrics.MetricsSamplerProvider;
|
|
-import net.minecraft.util.profiling.metrics.storage.MetricsPersister;
|
|
-import net.minecraft.util.profiling.metrics.storage.RecordedDeviation;
|
|
-
|
|
-public class ActiveMetricsRecorder implements MetricsRecorder {
|
|
- public static final int PROFILING_MAX_DURATION_SECONDS = 10;
|
|
- @Nullable
|
|
- private static Consumer<Path> globalOnReportFinished = null;
|
|
- private final Map<MetricSampler, List<RecordedDeviation>> deviationsBySampler = new Object2ObjectOpenHashMap<>();
|
|
- private final ContinuousProfiler taskProfiler;
|
|
- private final Executor ioExecutor;
|
|
- private final MetricsPersister metricsPersister;
|
|
- private final Consumer<ProfileResults> onProfilingEnd;
|
|
- private final Consumer<Path> onReportFinished;
|
|
- private final MetricsSamplerProvider metricsSamplerProvider;
|
|
- private final LongSupplier wallTimeSource;
|
|
- private final long deadlineNano;
|
|
- private int currentTick;
|
|
- private ProfileCollector singleTickProfiler;
|
|
- private volatile boolean killSwitch;
|
|
- private Set<MetricSampler> thisTickSamplers = ImmutableSet.of();
|
|
-
|
|
- private ActiveMetricsRecorder(
|
|
- MetricsSamplerProvider metricsSamplerProvider,
|
|
- LongSupplier wallTimeSource,
|
|
- Executor ioExecutor,
|
|
- MetricsPersister metricPersister,
|
|
- Consumer<ProfileResults> onProfilerEnd,
|
|
- Consumer<Path> onReportFinished
|
|
- ) {
|
|
- this.metricsSamplerProvider = metricsSamplerProvider;
|
|
- this.wallTimeSource = wallTimeSource;
|
|
- this.taskProfiler = new ContinuousProfiler(wallTimeSource, () -> this.currentTick, () -> false);
|
|
- this.ioExecutor = ioExecutor;
|
|
- this.metricsPersister = metricPersister;
|
|
- this.onProfilingEnd = onProfilerEnd;
|
|
- this.onReportFinished = globalOnReportFinished == null ? onReportFinished : onReportFinished.andThen(globalOnReportFinished);
|
|
- this.deadlineNano = wallTimeSource.getAsLong() + TimeUnit.NANOSECONDS.convert(10L, TimeUnit.SECONDS);
|
|
- this.singleTickProfiler = new ActiveProfiler(this.wallTimeSource, () -> this.currentTick, () -> true);
|
|
- this.taskProfiler.enable();
|
|
- }
|
|
-
|
|
- public static ActiveMetricsRecorder createStarted(
|
|
- MetricsSamplerProvider metricsSamplerProvider,
|
|
- LongSupplier wallTimeSource,
|
|
- Executor ioExecutor,
|
|
- MetricsPersister metricsPersister,
|
|
- Consumer<ProfileResults> onProfilerEnd,
|
|
- Consumer<Path> onReportFinished
|
|
- ) {
|
|
- return new ActiveMetricsRecorder(metricsSamplerProvider, wallTimeSource, ioExecutor, metricsPersister, onProfilerEnd, onReportFinished);
|
|
- }
|
|
-
|
|
- @Override
|
|
- public synchronized void end() {
|
|
- if (this.isRecording()) {
|
|
- this.killSwitch = true;
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public synchronized void cancel() {
|
|
- if (this.isRecording()) {
|
|
- this.singleTickProfiler = InactiveProfiler.INSTANCE;
|
|
- this.onProfilingEnd.accept(EmptyProfileResults.EMPTY);
|
|
- this.cleanup(this.thisTickSamplers);
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void startTick() {
|
|
- this.verifyStarted();
|
|
- this.thisTickSamplers = this.metricsSamplerProvider.samplers(() -> this.singleTickProfiler);
|
|
-
|
|
- for (MetricSampler metricSampler : this.thisTickSamplers) {
|
|
- metricSampler.onStartTick();
|
|
- }
|
|
-
|
|
- this.currentTick++;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void endTick() {
|
|
- this.verifyStarted();
|
|
- if (this.currentTick != 0) {
|
|
- for (MetricSampler metricSampler : this.thisTickSamplers) {
|
|
- metricSampler.onEndTick(this.currentTick);
|
|
- if (metricSampler.triggersThreshold()) {
|
|
- RecordedDeviation recordedDeviation = new RecordedDeviation(Instant.now(), this.currentTick, this.singleTickProfiler.getResults());
|
|
- this.deviationsBySampler.computeIfAbsent(metricSampler, metricSampler1 -> Lists.newArrayList()).add(recordedDeviation);
|
|
- }
|
|
- }
|
|
-
|
|
- if (!this.killSwitch && this.wallTimeSource.getAsLong() <= this.deadlineNano) {
|
|
- this.singleTickProfiler = new ActiveProfiler(this.wallTimeSource, () -> this.currentTick, () -> true);
|
|
- } else {
|
|
- this.killSwitch = false;
|
|
- ProfileResults results = this.taskProfiler.getResults();
|
|
- this.singleTickProfiler = InactiveProfiler.INSTANCE;
|
|
- this.onProfilingEnd.accept(results);
|
|
- this.scheduleSaveResults(results);
|
|
- }
|
|
- }
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean isRecording() {
|
|
- return this.taskProfiler.isEnabled();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public ProfilerFiller getProfiler() {
|
|
- return ProfilerFiller.combine(this.taskProfiler.getFiller(), this.singleTickProfiler);
|
|
- }
|
|
-
|
|
- private void verifyStarted() {
|
|
- if (!this.isRecording()) {
|
|
- throw new IllegalStateException("Not started!");
|
|
- }
|
|
- }
|
|
-
|
|
- private void scheduleSaveResults(ProfileResults results) {
|
|
- HashSet<MetricSampler> set = new HashSet<>(this.thisTickSamplers);
|
|
- this.ioExecutor.execute(() -> {
|
|
- Path path = this.metricsPersister.saveReports(set, this.deviationsBySampler, results);
|
|
- this.cleanup(set);
|
|
- this.onReportFinished.accept(path);
|
|
- });
|
|
- }
|
|
-
|
|
- private void cleanup(Collection<MetricSampler> samplers) {
|
|
- for (MetricSampler metricSampler : samplers) {
|
|
- metricSampler.onFinished();
|
|
- }
|
|
-
|
|
- this.deviationsBySampler.clear();
|
|
- this.taskProfiler.disable();
|
|
- }
|
|
-
|
|
- public static void registerGlobalCompletionCallback(Consumer<Path> globalOnReportFinished) {
|
|
- ActiveMetricsRecorder.globalOnReportFinished = globalOnReportFinished;
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/profiling/InactiveMetricsRecorder.java b/net/minecraft/util/profiling/metrics/profiling/InactiveMetricsRecorder.java
|
|
deleted file mode 100644
|
|
index 12d7b7c86115b667bd8f940206985d9ed4b837d4..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/profiling/InactiveMetricsRecorder.java
|
|
+++ /dev/null
|
|
@@ -1,34 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics.profiling;
|
|
-
|
|
-import net.minecraft.util.profiling.InactiveProfiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
-
|
|
-public class InactiveMetricsRecorder implements MetricsRecorder {
|
|
- public static final MetricsRecorder INSTANCE = new InactiveMetricsRecorder();
|
|
-
|
|
- @Override
|
|
- public void end() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void cancel() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void startTick() {
|
|
- }
|
|
-
|
|
- @Override
|
|
- public boolean isRecording() {
|
|
- return false;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public ProfilerFiller getProfiler() {
|
|
- return InactiveProfiler.INSTANCE;
|
|
- }
|
|
-
|
|
- @Override
|
|
- public void endTick() {
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java b/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java
|
|
deleted file mode 100644
|
|
index 48e7211e01691a677c52cf1f5982b0c179eaf83b..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/profiling/MetricsRecorder.java
|
|
+++ /dev/null
|
|
@@ -1,17 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics.profiling;
|
|
-
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
-
|
|
-public interface MetricsRecorder {
|
|
- void end();
|
|
-
|
|
- void cancel();
|
|
-
|
|
- void startTick();
|
|
-
|
|
- boolean isRecording();
|
|
-
|
|
- ProfilerFiller getProfiler();
|
|
-
|
|
- void endTick();
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/profiling/ProfilerSamplerAdapter.java b/net/minecraft/util/profiling/metrics/profiling/ProfilerSamplerAdapter.java
|
|
deleted file mode 100644
|
|
index 44f6dfd6efb8bd7894d6b15b45ea6cdd8babd234..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/profiling/ProfilerSamplerAdapter.java
|
|
+++ /dev/null
|
|
@@ -1,37 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics.profiling;
|
|
-
|
|
-import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
|
-import java.util.Set;
|
|
-import java.util.function.Supplier;
|
|
-import java.util.stream.Collectors;
|
|
-import net.minecraft.util.TimeUtil;
|
|
-import net.minecraft.util.profiling.ActiveProfiler;
|
|
-import net.minecraft.util.profiling.ProfileCollector;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import net.minecraft.util.profiling.metrics.MetricSampler;
|
|
-
|
|
-public class ProfilerSamplerAdapter {
|
|
- private final Set<String> previouslyFoundSamplerNames = new ObjectOpenHashSet<>();
|
|
-
|
|
- public Set<MetricSampler> newSamplersFoundInProfiler(Supplier<ProfileCollector> profiles) {
|
|
- Set<MetricSampler> set = profiles.get()
|
|
- .getChartedPaths()
|
|
- .stream()
|
|
- .filter(pair -> !this.previouslyFoundSamplerNames.contains(pair.getLeft()))
|
|
- .map(pair -> samplerForProfilingPath(profiles, pair.getLeft(), pair.getRight()))
|
|
- .collect(Collectors.toSet());
|
|
-
|
|
- for (MetricSampler metricSampler : set) {
|
|
- this.previouslyFoundSamplerNames.add(metricSampler.getName());
|
|
- }
|
|
-
|
|
- return set;
|
|
- }
|
|
-
|
|
- private static MetricSampler samplerForProfilingPath(Supplier<ProfileCollector> profiles, String name, MetricCategory category) {
|
|
- return MetricSampler.create(name, category, () -> {
|
|
- ActiveProfiler.PathEntry entry = profiles.get().getEntry(name);
|
|
- return entry == null ? 0.0 : (double)entry.getMaxDuration() / TimeUtil.NANOSECONDS_PER_MILLISECOND;
|
|
- });
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java b/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java
|
|
deleted file mode 100644
|
|
index f59e633e3dfae3f1b27f94a912b749e164213198..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/profiling/ServerMetricsSamplersProvider.java
|
|
+++ /dev/null
|
|
@@ -1,106 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics.profiling;
|
|
-
|
|
-import com.google.common.base.Stopwatch;
|
|
-import com.google.common.base.Ticker;
|
|
-import com.google.common.collect.ImmutableSet;
|
|
-import com.google.common.collect.ImmutableSet.Builder;
|
|
-import com.mojang.logging.LogUtils;
|
|
-import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
|
-import java.util.Set;
|
|
-import java.util.concurrent.TimeUnit;
|
|
-import java.util.function.LongSupplier;
|
|
-import java.util.function.Supplier;
|
|
-import java.util.function.ToDoubleFunction;
|
|
-import java.util.stream.IntStream;
|
|
-import net.minecraft.SystemReport;
|
|
-import net.minecraft.util.profiling.ProfileCollector;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import net.minecraft.util.profiling.metrics.MetricSampler;
|
|
-import net.minecraft.util.profiling.metrics.MetricsRegistry;
|
|
-import net.minecraft.util.profiling.metrics.MetricsSamplerProvider;
|
|
-import org.slf4j.Logger;
|
|
-import oshi.SystemInfo;
|
|
-import oshi.hardware.CentralProcessor;
|
|
-
|
|
-public class ServerMetricsSamplersProvider implements MetricsSamplerProvider {
|
|
- private static final Logger LOGGER = LogUtils.getLogger();
|
|
- private final Set<MetricSampler> samplers = new ObjectOpenHashSet<>();
|
|
- private final ProfilerSamplerAdapter samplerFactory = new ProfilerSamplerAdapter();
|
|
-
|
|
- public ServerMetricsSamplersProvider(LongSupplier timeSource, boolean dedicatedServer) {
|
|
- this.samplers.add(tickTimeSampler(timeSource));
|
|
- if (dedicatedServer) {
|
|
- this.samplers.addAll(runtimeIndependentSamplers());
|
|
- }
|
|
- }
|
|
-
|
|
- public static Set<MetricSampler> runtimeIndependentSamplers() {
|
|
- Builder<MetricSampler> builder = ImmutableSet.builder();
|
|
-
|
|
- try {
|
|
- ServerMetricsSamplersProvider.CpuStats cpuStats = new ServerMetricsSamplersProvider.CpuStats();
|
|
- IntStream.range(0, cpuStats.nrOfCpus)
|
|
- .mapToObj(i -> MetricSampler.create("cpu#" + i, MetricCategory.CPU, () -> cpuStats.loadForCpu(i)))
|
|
- .forEach(builder::add);
|
|
- } catch (Throwable var2) {
|
|
- LOGGER.warn("Failed to query cpu, no cpu stats will be recorded", var2);
|
|
- }
|
|
-
|
|
- builder.add(
|
|
- MetricSampler.create(
|
|
- "heap MiB", MetricCategory.JVM, () -> SystemReport.sizeInMiB(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())
|
|
- )
|
|
- );
|
|
- builder.addAll(MetricsRegistry.INSTANCE.getRegisteredSamplers());
|
|
- return builder.build();
|
|
- }
|
|
-
|
|
- @Override
|
|
- public Set<MetricSampler> samplers(Supplier<ProfileCollector> profiles) {
|
|
- this.samplers.addAll(this.samplerFactory.newSamplersFoundInProfiler(profiles));
|
|
- return this.samplers;
|
|
- }
|
|
-
|
|
- public static MetricSampler tickTimeSampler(final LongSupplier timeSource) {
|
|
- Stopwatch stopwatch = Stopwatch.createUnstarted(new Ticker() {
|
|
- @Override
|
|
- public long read() {
|
|
- return timeSource.getAsLong();
|
|
- }
|
|
- });
|
|
- ToDoubleFunction<Stopwatch> toDoubleFunction = stopwatch1 -> {
|
|
- if (stopwatch1.isRunning()) {
|
|
- stopwatch1.stop();
|
|
- }
|
|
-
|
|
- long l = stopwatch1.elapsed(TimeUnit.NANOSECONDS);
|
|
- stopwatch1.reset();
|
|
- return l;
|
|
- };
|
|
- MetricSampler.ValueIncreasedByPercentage valueIncreasedByPercentage = new MetricSampler.ValueIncreasedByPercentage(2.0F);
|
|
- return MetricSampler.builder("ticktime", MetricCategory.TICK_LOOP, toDoubleFunction, stopwatch)
|
|
- .withBeforeTick(Stopwatch::start)
|
|
- .withThresholdAlert(valueIncreasedByPercentage)
|
|
- .build();
|
|
- }
|
|
-
|
|
- static class CpuStats {
|
|
- private final SystemInfo systemInfo = new SystemInfo();
|
|
- private final CentralProcessor processor = this.systemInfo.getHardware().getProcessor();
|
|
- public final int nrOfCpus = this.processor.getLogicalProcessorCount();
|
|
- private long[][] previousCpuLoadTick = this.processor.getProcessorCpuLoadTicks();
|
|
- private double[] currentLoad = this.processor.getProcessorCpuLoadBetweenTicks(this.previousCpuLoadTick);
|
|
- private long lastPollMs;
|
|
-
|
|
- public double loadForCpu(int index) {
|
|
- long l = System.currentTimeMillis();
|
|
- if (this.lastPollMs == 0L || this.lastPollMs + 501L < l) {
|
|
- this.currentLoad = this.processor.getProcessorCpuLoadBetweenTicks(this.previousCpuLoadTick);
|
|
- this.previousCpuLoadTick = this.processor.getProcessorCpuLoadTicks();
|
|
- this.lastPollMs = l;
|
|
- }
|
|
-
|
|
- return this.currentLoad[index] * 100.0;
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/profiling/package-info.java b/net/minecraft/util/profiling/metrics/profiling/package-info.java
|
|
deleted file mode 100644
|
|
index f823bd9a9a819d7d7ca2cbf83af5b37b19fa301e..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/profiling/package-info.java
|
|
+++ /dev/null
|
|
@@ -1,8 +0,0 @@
|
|
-@ParametersAreNonnullByDefault
|
|
-@MethodsReturnNonnullByDefault
|
|
-@FieldsAreNonnullByDefault
|
|
-package net.minecraft.util.profiling.metrics.profiling;
|
|
-
|
|
-import javax.annotation.ParametersAreNonnullByDefault;
|
|
-import net.minecraft.FieldsAreNonnullByDefault;
|
|
-import net.minecraft.MethodsReturnNonnullByDefault;
|
|
diff --git a/net/minecraft/util/profiling/metrics/storage/MetricsPersister.java b/net/minecraft/util/profiling/metrics/storage/MetricsPersister.java
|
|
deleted file mode 100644
|
|
index 43d63490b8c5337b426966608085ee3de1347a96..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/storage/MetricsPersister.java
|
|
+++ /dev/null
|
|
@@ -1,125 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics.storage;
|
|
-
|
|
-import com.mojang.logging.LogUtils;
|
|
-import java.io.IOException;
|
|
-import java.io.UncheckedIOException;
|
|
-import java.io.Writer;
|
|
-import java.nio.charset.StandardCharsets;
|
|
-import java.nio.file.Files;
|
|
-import java.nio.file.Path;
|
|
-import java.nio.file.Paths;
|
|
-import java.time.ZoneId;
|
|
-import java.time.format.DateTimeFormatter;
|
|
-import java.util.List;
|
|
-import java.util.Locale;
|
|
-import java.util.Map;
|
|
-import java.util.Set;
|
|
-import java.util.stream.Collectors;
|
|
-import java.util.stream.Stream;
|
|
-import net.minecraft.Util;
|
|
-import net.minecraft.resources.ResourceLocation;
|
|
-import net.minecraft.util.CsvOutput;
|
|
-import net.minecraft.util.profiling.ProfileResults;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import net.minecraft.util.profiling.metrics.MetricSampler;
|
|
-import org.apache.commons.io.IOUtils;
|
|
-import org.slf4j.Logger;
|
|
-
|
|
-public class MetricsPersister {
|
|
- public static final Path PROFILING_RESULTS_DIR = Paths.get("debug/profiling");
|
|
- public static final String METRICS_DIR_NAME = "metrics";
|
|
- public static final String DEVIATIONS_DIR_NAME = "deviations";
|
|
- public static final String PROFILING_RESULT_FILENAME = "profiling.txt";
|
|
- private static final Logger LOGGER = LogUtils.getLogger();
|
|
- private final String rootFolderName;
|
|
-
|
|
- public MetricsPersister(String rootFolderName) {
|
|
- this.rootFolderName = rootFolderName;
|
|
- }
|
|
-
|
|
- public Path saveReports(Set<MetricSampler> samplers, Map<MetricSampler, List<RecordedDeviation>> deviations, ProfileResults results) {
|
|
- try {
|
|
- Files.createDirectories(PROFILING_RESULTS_DIR);
|
|
- } catch (IOException var8) {
|
|
- throw new UncheckedIOException(var8);
|
|
- }
|
|
-
|
|
- try {
|
|
- Path path = Files.createTempDirectory("minecraft-profiling");
|
|
- path.toFile().deleteOnExit();
|
|
- Files.createDirectories(PROFILING_RESULTS_DIR);
|
|
- Path path1 = path.resolve(this.rootFolderName);
|
|
- Path path2 = path1.resolve("metrics");
|
|
- this.saveMetrics(samplers, path2);
|
|
- if (!deviations.isEmpty()) {
|
|
- this.saveDeviations(deviations, path1.resolve("deviations"));
|
|
- }
|
|
-
|
|
- this.saveProfilingTaskExecutionResult(results, path1);
|
|
- return path;
|
|
- } catch (IOException var7) {
|
|
- throw new UncheckedIOException(var7);
|
|
- }
|
|
- }
|
|
-
|
|
- private void saveMetrics(Set<MetricSampler> samplers, Path path) {
|
|
- if (samplers.isEmpty()) {
|
|
- throw new IllegalArgumentException("Expected at least one sampler to persist");
|
|
- } else {
|
|
- Map<MetricCategory, List<MetricSampler>> map = samplers.stream().collect(Collectors.groupingBy(MetricSampler::getCategory));
|
|
- map.forEach((metricCategory, list) -> this.saveCategory(metricCategory, (List<MetricSampler>)list, path));
|
|
- }
|
|
- }
|
|
-
|
|
- private void saveCategory(MetricCategory category, List<MetricSampler> samplers, Path path) {
|
|
- Path path1 = path.resolve(Util.sanitizeName(category.getDescription(), ResourceLocation::validPathChar) + ".csv");
|
|
- Writer writer = null;
|
|
-
|
|
- try {
|
|
- Files.createDirectories(path1.getParent());
|
|
- writer = Files.newBufferedWriter(path1, StandardCharsets.UTF_8);
|
|
- CsvOutput.Builder builder = CsvOutput.builder();
|
|
- builder.addColumn("@tick");
|
|
-
|
|
- for (MetricSampler metricSampler : samplers) {
|
|
- builder.addColumn(metricSampler.getName());
|
|
- }
|
|
-
|
|
- CsvOutput csvOutput = builder.build(writer);
|
|
- List<MetricSampler.SamplerResult> list = samplers.stream().map(MetricSampler::result).collect(Collectors.toList());
|
|
- int min = list.stream().mapToInt(MetricSampler.SamplerResult::getFirstTick).summaryStatistics().getMin();
|
|
- int max = list.stream().mapToInt(MetricSampler.SamplerResult::getLastTick).summaryStatistics().getMax();
|
|
-
|
|
- for (int i = min; i <= max; i++) {
|
|
- int i1 = i;
|
|
- Stream<String> stream = list.stream().map(samplerResult -> String.valueOf(samplerResult.valueAtTick(i1)));
|
|
- Object[] objects = Stream.concat(Stream.of(String.valueOf(i)), stream).toArray(String[]::new);
|
|
- csvOutput.writeRow(objects);
|
|
- }
|
|
-
|
|
- LOGGER.info("Flushed metrics to {}", path1);
|
|
- } catch (Exception var18) {
|
|
- LOGGER.error("Could not save profiler results to {}", path1, var18);
|
|
- } finally {
|
|
- IOUtils.closeQuietly(writer);
|
|
- }
|
|
- }
|
|
-
|
|
- private void saveDeviations(Map<MetricSampler, List<RecordedDeviation>> deviations, Path path) {
|
|
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss.SSS", Locale.UK).withZone(ZoneId.systemDefault());
|
|
- deviations.forEach(
|
|
- (metricSampler, list) -> list.forEach(
|
|
- recordedDeviation -> {
|
|
- String string = dateTimeFormatter.format(recordedDeviation.timestamp);
|
|
- Path path1 = path.resolve(Util.sanitizeName(metricSampler.getName(), ResourceLocation::validPathChar))
|
|
- .resolve(String.format(Locale.ROOT, "%d@%s.txt", recordedDeviation.tick, string));
|
|
- recordedDeviation.profilerResultAtTick.saveResults(path1);
|
|
- }
|
|
- )
|
|
- );
|
|
- }
|
|
-
|
|
- private void saveProfilingTaskExecutionResult(ProfileResults results, Path outputPath) {
|
|
- results.saveResults(outputPath.resolve("profiling.txt"));
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/storage/RecordedDeviation.java b/net/minecraft/util/profiling/metrics/storage/RecordedDeviation.java
|
|
deleted file mode 100644
|
|
index 4f73764d32ddbb7142ca46f68a0291e1ac200b65..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/storage/RecordedDeviation.java
|
|
+++ /dev/null
|
|
@@ -1,16 +0,0 @@
|
|
-package net.minecraft.util.profiling.metrics.storage;
|
|
-
|
|
-import java.time.Instant;
|
|
-import net.minecraft.util.profiling.ProfileResults;
|
|
-
|
|
-public final class RecordedDeviation {
|
|
- public final Instant timestamp;
|
|
- public final int tick;
|
|
- public final ProfileResults profilerResultAtTick;
|
|
-
|
|
- public RecordedDeviation(Instant timestamp, int tick, ProfileResults profilerResultAtTick) {
|
|
- this.timestamp = timestamp;
|
|
- this.tick = tick;
|
|
- this.profilerResultAtTick = profilerResultAtTick;
|
|
- }
|
|
-}
|
|
diff --git a/net/minecraft/util/profiling/metrics/storage/package-info.java b/net/minecraft/util/profiling/metrics/storage/package-info.java
|
|
deleted file mode 100644
|
|
index a2af6177a16997835eb91de3c6f4f83ee5e7e944..0000000000000000000000000000000000000000
|
|
--- a/net/minecraft/util/profiling/metrics/storage/package-info.java
|
|
+++ /dev/null
|
|
@@ -1,8 +0,0 @@
|
|
-@ParametersAreNonnullByDefault
|
|
-@MethodsReturnNonnullByDefault
|
|
-@FieldsAreNonnullByDefault
|
|
-package net.minecraft.util.profiling.metrics.storage;
|
|
-
|
|
-import javax.annotation.ParametersAreNonnullByDefault;
|
|
-import net.minecraft.FieldsAreNonnullByDefault;
|
|
-import net.minecraft.MethodsReturnNonnullByDefault;
|
|
diff --git a/net/minecraft/util/thread/AbstractConsecutiveExecutor.java b/net/minecraft/util/thread/AbstractConsecutiveExecutor.java
|
|
index f4aa10bbd98f514f27224346b3b9332f2218602d..ff319fa2ddea43d5b3c55897b1aaaf9fe137abbc 100644
|
|
--- a/net/minecraft/util/thread/AbstractConsecutiveExecutor.java
|
|
+++ b/net/minecraft/util/thread/AbstractConsecutiveExecutor.java
|
|
@@ -7,13 +7,9 @@ import java.util.concurrent.Executor;
|
|
import java.util.concurrent.RejectedExecutionException;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import net.minecraft.Util;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import net.minecraft.util.profiling.metrics.MetricSampler;
|
|
-import net.minecraft.util.profiling.metrics.MetricsRegistry;
|
|
-import net.minecraft.util.profiling.metrics.ProfilerMeasured;
|
|
import org.slf4j.Logger;
|
|
|
|
-public abstract class AbstractConsecutiveExecutor<T extends Runnable> implements ProfilerMeasured, TaskScheduler<T>, Runnable {
|
|
+public abstract class AbstractConsecutiveExecutor<T extends Runnable> implements TaskScheduler<T>, Runnable {
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
private final AtomicReference<AbstractConsecutiveExecutor.Status> status = new AtomicReference<>(AbstractConsecutiveExecutor.Status.SLEEPING);
|
|
private final StrictQueue<T> queue;
|
|
@@ -24,7 +20,6 @@ public abstract class AbstractConsecutiveExecutor<T extends Runnable> implements
|
|
this.executor = executor;
|
|
this.queue = queue;
|
|
this.name = name;
|
|
- MetricsRegistry.INSTANCE.add(this);
|
|
}
|
|
|
|
private boolean canBeScheduled() {
|
|
@@ -108,11 +103,6 @@ public abstract class AbstractConsecutiveExecutor<T extends Runnable> implements
|
|
return this.name;
|
|
}
|
|
|
|
- @Override
|
|
- public List<MetricSampler> profiledMetrics() {
|
|
- return ImmutableList.of(MetricSampler.create(this.name + "-queue-size", MetricCategory.CONSECUTIVE_EXECUTORS, this::size));
|
|
- }
|
|
-
|
|
private boolean setRunning() {
|
|
return this.status.compareAndSet(AbstractConsecutiveExecutor.Status.SLEEPING, AbstractConsecutiveExecutor.Status.RUNNING);
|
|
}
|
|
diff --git a/net/minecraft/util/thread/BlockableEventLoop.java b/net/minecraft/util/thread/BlockableEventLoop.java
|
|
index 186c1b2e3599770385150eb7acdcd890aa5835eb..e570740d3910573694c462b0a4894349940917a8 100644
|
|
--- a/net/minecraft/util/thread/BlockableEventLoop.java
|
|
+++ b/net/minecraft/util/thread/BlockableEventLoop.java
|
|
@@ -15,13 +15,9 @@ import java.util.function.Supplier;
|
|
import javax.annotation.CheckReturnValue;
|
|
import net.minecraft.ReportedException;
|
|
import net.minecraft.SharedConstants;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
-import net.minecraft.util.profiling.metrics.MetricSampler;
|
|
-import net.minecraft.util.profiling.metrics.MetricsRegistry;
|
|
-import net.minecraft.util.profiling.metrics.ProfilerMeasured;
|
|
import org.slf4j.Logger;
|
|
|
|
-public abstract class BlockableEventLoop<R extends Runnable> implements ProfilerMeasured, TaskScheduler<R>, Executor {
|
|
+public abstract class BlockableEventLoop<R extends Runnable> implements TaskScheduler<R>, Executor {
|
|
public static final long BLOCK_TIME_NANOS = 100000L;
|
|
private final String name;
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
@@ -30,7 +26,6 @@ public abstract class BlockableEventLoop<R extends Runnable> implements Profiler
|
|
|
|
protected BlockableEventLoop(String name) {
|
|
this.name = name;
|
|
- MetricsRegistry.INSTANCE.add(this);
|
|
}
|
|
|
|
protected abstract boolean shouldRun(R runnable);
|
|
@@ -161,11 +156,6 @@ public abstract class BlockableEventLoop<R extends Runnable> implements Profiler
|
|
}
|
|
}
|
|
|
|
- @Override
|
|
- public List<MetricSampler> profiledMetrics() {
|
|
- return ImmutableList.of(MetricSampler.create(this.name + "-pending-tasks", MetricCategory.EVENT_LOOPS, this::getPendingTasksCount));
|
|
- }
|
|
-
|
|
public static boolean isNonRecoverable(Throwable error) {
|
|
return error instanceof ReportedException reportedException
|
|
? isNonRecoverable(reportedException.getCause())
|
|
diff --git a/net/minecraft/util/thread/PriorityConsecutiveExecutor.java b/net/minecraft/util/thread/PriorityConsecutiveExecutor.java
|
|
index 39a604c9a53930b53d959b1d2eb504aa964e9a58..0d0380e3955836ce125f777841477503bb6c0aae 100644
|
|
--- a/net/minecraft/util/thread/PriorityConsecutiveExecutor.java
|
|
+++ b/net/minecraft/util/thread/PriorityConsecutiveExecutor.java
|
|
@@ -3,12 +3,10 @@ package net.minecraft.util.thread;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.function.Consumer;
|
|
-import net.minecraft.util.profiling.metrics.MetricsRegistry;
|
|
|
|
public class PriorityConsecutiveExecutor extends AbstractConsecutiveExecutor<StrictQueue.RunnableWithPriority> {
|
|
public PriorityConsecutiveExecutor(int size, Executor executor, String name) {
|
|
super(new StrictQueue.FixedPriorityQueue(size), executor, name);
|
|
- MetricsRegistry.INSTANCE.add(this);
|
|
}
|
|
|
|
@Override
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index fa829d84cd47b68426bb30f662de6e05b608cc69..02f39e3dc420a5bd49cd6e247c9b1894dc49d303 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -80,8 +80,6 @@ import net.minecraft.tags.TagKey;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.ProblemReporter;
|
|
import net.minecraft.util.RandomSource;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.Nameable;
|
|
@@ -873,8 +871,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
// CraftBukkit end
|
|
|
|
public void baseTick() {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("entityBaseTick");
|
|
if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups
|
|
this.inBlockState = null;
|
|
if (this.isPassenger() && this.getVehicle().isRemoved()) {
|
|
@@ -928,8 +924,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
if (this.level() instanceof ServerLevel serverLevelx && this instanceof Leashable) {
|
|
Leashable.tickLeash(serverLevelx, (Entity & Leashable)this);
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
public void setSharedFlagOnFire(boolean isOnFire) {
|
|
@@ -1150,8 +1144,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
}
|
|
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("move");
|
|
if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7) {
|
|
movement = movement.multiply(this.stuckSpeedMultiplier);
|
|
this.stuckSpeedMultiplier = Vec3.ZERO;
|
|
@@ -1160,7 +1152,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
// Paper start - ignore movement changes while inactive.
|
|
if (isTemporarilyActive && !(this instanceof ItemEntity) && movement == getDeltaMovement() && type == MoverType.SELF) {
|
|
setDeltaMovement(Vec3.ZERO);
|
|
- profilerFiller.pop();
|
|
return;
|
|
}
|
|
// Paper end
|
|
@@ -1185,8 +1176,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
this.setPos(vec32);
|
|
}
|
|
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("rest");
|
|
boolean flag = !Mth.equal(movement.x, vec3.x);
|
|
boolean flag1 = !Mth.equal(movement.z, vec3.z);
|
|
this.horizontalCollision = flag || flag1;
|
|
@@ -1209,7 +1198,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
|
|
if (this.isRemoved()) {
|
|
- profilerFiller.pop();
|
|
+ // nothing
|
|
} else {
|
|
if (this.horizontalCollision) {
|
|
Vec3 deltaMovement = this.getDeltaMovement();
|
|
@@ -1253,7 +1242,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
|
|
float blockSpeedFactor = this.getBlockSpeedFactor();
|
|
this.setDeltaMovement(this.getDeltaMovement().multiply(blockSpeedFactor, 1.0, blockSpeedFactor));
|
|
- profilerFiller.pop();
|
|
}
|
|
}
|
|
// Paper start - detailed watchdog information
|
|
@@ -3466,8 +3454,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
this.processPortalCooldown();
|
|
if (this.portalProcess != null) {
|
|
if (this.portalProcess.processPortalTeleportation(serverLevel, this, this.canUsePortal(false))) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("portal");
|
|
this.setPortalCooldown();
|
|
TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this);
|
|
if (portalDestination != null) {
|
|
@@ -3477,8 +3463,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
this.teleport(portalDestination);
|
|
}
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
} else if (this.portalProcess.hasExpired()) {
|
|
this.portalProcess = null;
|
|
}
|
|
@@ -4045,15 +4029,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
entity.teleport(this.calculatePassengerTransition(teleportTransition, entity));
|
|
}
|
|
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("teleportSameDimension");
|
|
this.teleportSetPosition(PositionMoveRotation.of(teleportTransition), teleportTransition.relatives());
|
|
if (!teleportTransition.asPassenger()) {
|
|
this.sendTeleportTransitionToRidingPlayers(teleportTransition);
|
|
}
|
|
|
|
teleportTransition.postTeleportTransition().onTransition(this);
|
|
- profilerFiller.pop();
|
|
return this;
|
|
}
|
|
|
|
@@ -4069,11 +4050,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
}
|
|
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("teleportCrossDimension");
|
|
Entity entityx = this.getType().create(newLevel, EntitySpawnReason.DIMENSION_TRAVEL);
|
|
if (entityx == null) {
|
|
- profilerFiller.pop();
|
|
return null;
|
|
} else {
|
|
// Paper start - Fix item duplication and teleport issues
|
|
@@ -4093,7 +4071,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
newLevel.resetEmptyTime();
|
|
teleportTransition.postTeleportTransition().onTransition(entityx);
|
|
this.teleportSpectators(teleportTransition, oldLevel);
|
|
- profilerFiller.pop();
|
|
return entityx;
|
|
}
|
|
}
|
|
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
|
index ddd3acbc804cbc07eaccf578349d3f9e0e00b6fc..0c0144679c9d44d50af153c792d7e5da175365d8 100644
|
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -69,8 +69,6 @@ import net.minecraft.tags.FluidTags;
|
|
import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.tags.TagKey;
|
|
import net.minecraft.util.Mth;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.Difficulty;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.damagesource.CombatRules;
|
|
@@ -434,8 +432,6 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
}
|
|
|
|
super.baseTick();
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("livingEntityBaseTick");
|
|
if (this.fireImmune() || this.level().isClientSide) {
|
|
this.clearFire();
|
|
}
|
|
@@ -526,7 +522,6 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
this.yBodyRotO = this.yBodyRot;
|
|
this.yRotO = this.getYRot();
|
|
this.xRotO = this.getXRot();
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
@Override
|
|
@@ -3364,11 +3359,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
f1 = this.getYRot();
|
|
}
|
|
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("headTurn");
|
|
this.tickHeadTurn(f1);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("rangeChecks");
|
|
|
|
// Paper start - stop large pitch and yaw changes from crashing the server
|
|
this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F;
|
|
@@ -3380,7 +3371,6 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F;
|
|
// Paper end - stop large pitch and yaw changes from crashing the server
|
|
|
|
- profilerFiller.pop();
|
|
if (this.isFallFlying()) {
|
|
this.fallFlyTicks++;
|
|
} else {
|
|
@@ -3556,21 +3546,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
}
|
|
|
|
this.setDeltaMovement(d, d1, d2);
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("ai");
|
|
this.applyInput();
|
|
if (this.isImmobile()) {
|
|
this.jumping = false;
|
|
this.xxa = 0.0F;
|
|
this.zza = 0.0F;
|
|
} else if (this.isEffectiveAi() && !this.level().isClientSide) {
|
|
- profilerFiller.push("newAi");
|
|
this.serverAiStep();
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("jump");
|
|
if (this.jumping && this.isAffectedByFluids()) {
|
|
double fluidHeight;
|
|
if (this.isInLava()) {
|
|
@@ -3599,8 +3583,6 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
this.noJumpDelay = 0;
|
|
}
|
|
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("travel");
|
|
if (this.isFallFlying()) {
|
|
this.updateFallFlying();
|
|
}
|
|
@@ -3625,9 +3607,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
this.calculateEntityAnimation(this instanceof FlyingAnimal);
|
|
}
|
|
|
|
- profilerFiller.pop();
|
|
if (this.level() instanceof ServerLevel serverLevel) {
|
|
- profilerFiller.push("freezing");
|
|
if ((!this.isInPowderSnow || !this.canFreeze()) && !this.freezeLocked) { // Paper - Freeze Tick Lock API
|
|
this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2));
|
|
}
|
|
@@ -3637,18 +3617,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
|
if (this.tickCount % 40 == 0 && this.isFullyFrozen() && this.canFreeze()) {
|
|
this.hurtServer(serverLevel, this.damageSources().freeze(), 1.0F);
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
- profilerFiller.push("push");
|
|
if (this.autoSpinAttackTicks > 0) {
|
|
this.autoSpinAttackTicks--;
|
|
this.checkAutoSpinAttack(boundingBox, this.getBoundingBox());
|
|
}
|
|
|
|
this.pushEntities();
|
|
- profilerFiller.pop();
|
|
// Paper start - Add EntityMoveEvent
|
|
// Purpur start - Ridables
|
|
if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) {
|
|
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
|
index b0a5f79eb2c3ea84fd37eaa653a4f2c83caeab5d..e1f5a4814d051a43090bf6df2acbcd20fbbc1934 100644
|
|
--- a/net/minecraft/world/entity/Mob.java
|
|
+++ b/net/minecraft/world/entity/Mob.java
|
|
@@ -26,8 +26,6 @@ import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.tags.TagKey;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.Container;
|
|
import net.minecraft.world.Difficulty;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
@@ -321,14 +319,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
|
@Override
|
|
public void baseTick() {
|
|
super.baseTick();
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("mobBaseTick");
|
|
if (this.isAlive() && this.random.nextInt(1000) < this.ambientSoundTime++) {
|
|
this.resetAmbientSoundTime();
|
|
this.playAmbientSound();
|
|
}
|
|
|
|
- profilerFiller.pop();
|
|
incrementTicksSinceLastInteraction(); // Purpur - Entity lifespan
|
|
}
|
|
|
|
@@ -526,8 +521,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
|
@Override
|
|
public void aiStep() {
|
|
super.aiStep();
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("looting");
|
|
if (this.level() instanceof ServerLevel serverLevel
|
|
&& this.canPickUpLoot()
|
|
&& this.isAlive()
|
|
@@ -550,8 +543,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
|
}
|
|
}
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
protected Vec3i getPickupReach() {
|
|
@@ -765,42 +756,21 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
|
return;
|
|
}
|
|
// Paper end - Allow nerfed mobs to jump and float
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("sensing");
|
|
this.sensing.tick();
|
|
- profilerFiller.pop();
|
|
int i = this.tickCount + this.getId();
|
|
if (i % 2 != 0 && this.tickCount > 1) {
|
|
- profilerFiller.push("targetSelector");
|
|
this.targetSelector.tickRunningGoals(false);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("goalSelector");
|
|
this.goalSelector.tickRunningGoals(false);
|
|
- profilerFiller.pop();
|
|
} else {
|
|
- profilerFiller.push("targetSelector");
|
|
this.targetSelector.tick();
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("goalSelector");
|
|
this.goalSelector.tick();
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
- profilerFiller.push("navigation");
|
|
this.navigation.tick();
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("mob tick");
|
|
this.customServerAiStep((ServerLevel)this.level());
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("controls");
|
|
- profilerFiller.push("move");
|
|
this.moveControl.tick();
|
|
- profilerFiller.popPush("look");
|
|
this.lookControl.tick();
|
|
- profilerFiller.popPush("jump");
|
|
this.jumpControl.tick();
|
|
- profilerFiller.pop();
|
|
- profilerFiller.pop();
|
|
this.sendDebugPackets();
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/ai/goal/GoalSelector.java b/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
|
index 859b859d29b637200cf7c9a0bd52d9f712413e3d..653c58c7637c46c8b46a5082f671324a2221d431 100644
|
|
--- a/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
|
+++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
|
@@ -6,8 +6,6 @@ import java.util.EnumSet;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.function.Predicate;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
|
|
public class GoalSelector {
|
|
private static final WrappedGoal NO_GOAL = new WrappedGoal(Integer.MAX_VALUE, new Goal() {
|
|
@@ -82,9 +80,6 @@ public class GoalSelector {
|
|
}
|
|
|
|
public void tick() {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("goalCleanup");
|
|
-
|
|
for (WrappedGoal wrappedGoal : this.availableGoals) {
|
|
if (wrappedGoal.isRunning() && (goalContainsAnyFlags(wrappedGoal, this.goalTypes) || !wrappedGoal.canContinueToUse())) { // Paper - Perf: optimize goal types by removing streams
|
|
wrappedGoal.stop();
|
|
@@ -92,8 +87,6 @@ public class GoalSelector {
|
|
}
|
|
|
|
this.lockedFlags.entrySet().removeIf(entry -> !entry.getValue().isRunning());
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("goalUpdate");
|
|
|
|
for (WrappedGoal wrappedGoalx : this.availableGoals) {
|
|
// Paper start
|
|
@@ -113,21 +106,15 @@ public class GoalSelector {
|
|
}
|
|
}
|
|
|
|
- profilerFiller.pop();
|
|
this.tickRunningGoals(true);
|
|
}
|
|
|
|
public void tickRunningGoals(boolean tickAllRunning) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("goalTick");
|
|
-
|
|
for (WrappedGoal wrappedGoal : this.availableGoals) {
|
|
if (wrappedGoal.isRunning() && (tickAllRunning || wrappedGoal.requiresUpdateEveryTick())) {
|
|
wrappedGoal.tick();
|
|
}
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
public Set<WrappedGoal> getAvailableGoals() {
|
|
diff --git a/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
|
index dd1a95111d965bcd7f53be9d4224dd213e4e0705..24dd92449f70144c79f25bf24942ebd666655ed2 100644
|
|
--- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
|
+++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
|
@@ -10,8 +10,6 @@ import net.minecraft.core.Vec3i;
|
|
import net.minecraft.network.protocol.game.DebugPackets;
|
|
import net.minecraft.tags.BlockTags;
|
|
import net.minecraft.util.Mth;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.Mob;
|
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
|
@@ -189,13 +187,10 @@ public abstract class PathNavigation {
|
|
}
|
|
}
|
|
// Paper end - EntityPathfindEvent
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("pathfind");
|
|
BlockPos blockPos = offsetUpward ? this.mob.blockPosition().above() : this.mob.blockPosition();
|
|
int i = (int)(followRange + regionOffset);
|
|
PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i));
|
|
Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, targets, followRange, accuracy, this.maxVisitedNodesMultiplier);
|
|
- profilerFiller.pop();
|
|
if (path != null && path.getTarget() != null) {
|
|
this.targetPos = path.getTarget();
|
|
this.reachRange = accuracy;
|
|
diff --git a/net/minecraft/world/entity/ai/sensing/Sensing.java b/net/minecraft/world/entity/ai/sensing/Sensing.java
|
|
index c569074403b1d8b443aaa98ba9cf9bbd0e98bd2d..b1aa7294f9479f45fcde77c5ea46db9f62370abf 100644
|
|
--- a/net/minecraft/world/entity/ai/sensing/Sensing.java
|
|
+++ b/net/minecraft/world/entity/ai/sensing/Sensing.java
|
|
@@ -2,8 +2,6 @@ package net.minecraft.world.entity.ai.sensing;
|
|
|
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.Mob;
|
|
|
|
@@ -28,10 +26,7 @@ public class Sensing {
|
|
} else if (this.unseen.contains(id)) {
|
|
return false;
|
|
} else {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("hasLineOfSight");
|
|
boolean hasLineOfSight = this.mob.hasLineOfSight(entity);
|
|
- profilerFiller.pop();
|
|
if (hasLineOfSight) {
|
|
this.seen.add(id);
|
|
} else {
|
|
diff --git a/net/minecraft/world/entity/animal/HappyGhast.java b/net/minecraft/world/entity/animal/HappyGhast.java
|
|
index fb37669b4d66bb853eabf2d15a369d7ad5a2dbb9..9763a5e24e0fed9b49b6ac59911f6c9f8e893db5 100644
|
|
--- a/net/minecraft/world/entity/animal/HappyGhast.java
|
|
+++ b/net/minecraft/world/entity/animal/HappyGhast.java
|
|
@@ -14,8 +14,6 @@ import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.util.Mth;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
@@ -426,13 +424,8 @@ public class HappyGhast extends Animal {
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
if (this.isBaby()) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("happyGhastBrain");
|
|
((Brain<HappyGhast>)this.brain).tick(level, this);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("happyGhastActivityUpdate");
|
|
HappyGhastAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
this.checkRestriction();
|
|
diff --git a/net/minecraft/world/entity/animal/allay/Allay.java b/net/minecraft/world/entity/animal/allay/Allay.java
|
|
index cf6ff7b7b4a007d7ff4b3c5a25d4f5a36422c683..c5275d6069a491c3c2b2de175b76fb871b667b0c 100644
|
|
--- a/net/minecraft/world/entity/animal/allay/Allay.java
|
|
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
|
|
@@ -25,8 +25,6 @@ import net.minecraft.tags.GameEventTags;
|
|
import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.tags.TagKey;
|
|
import net.minecraft.util.Mth;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.SimpleContainer;
|
|
@@ -269,14 +267,9 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("allayBrain");
|
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("allayActivityUpdate");
|
|
AllayAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
super.customServerAiStep(level);
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
|
index e4578193f58417c7ef2776bb3d831ba55c553aec..2a7a078e05e16e73e43a24e108d207bce2e876bb 100644
|
|
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
|
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
|
@@ -23,8 +23,6 @@ import net.minecraft.util.ByIdMap;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.StringRepresentable;
|
|
import net.minecraft.util.TimeUtil;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
@@ -167,13 +165,8 @@ public class Armadillo extends Animal {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("armadilloBrain");
|
|
((Brain<Armadillo>)this.brain).tick(level, this);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("armadilloActivityUpdate");
|
|
ArmadilloAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
|
|
this.forceDrops = true; // CraftBukkit
|
|
if (this.dropFromGiftLootTable(level, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) {
|
|
diff --git a/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
|
index 05070562ee7ea23d4e2fa602466f097827ffa35b..6931bc84594362579a1832cb8ccda501e9fb0631 100644
|
|
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
|
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
|
@@ -31,8 +31,6 @@ import net.minecraft.util.ByIdMap;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.StringRepresentable;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
@@ -375,14 +373,9 @@ public class Axolotl extends Animal implements Bucketable {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("axolotlBrain");
|
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("axolotlActivityUpdate");
|
|
AxolotlAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
if (!this.isNoAi()) {
|
|
Optional<Integer> memory = this.getBrain().getMemory(MemoryModuleType.PLAY_DEAD_TICKS);
|
|
this.setPlayingDead(memory.isPresent() && memory.get() > 0);
|
|
diff --git a/net/minecraft/world/entity/animal/camel/Camel.java b/net/minecraft/world/entity/animal/camel/Camel.java
|
|
index 0c698241b10f84afb17ae10d3661a90bc62ec243..949b6c563658e6e46ac5842d6f088ecae6d4cd0c 100644
|
|
--- a/net/minecraft/world/entity/animal/camel/Camel.java
|
|
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
|
|
@@ -18,8 +18,6 @@ import net.minecraft.tags.BlockTags;
|
|
import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
@@ -173,14 +171,9 @@ public class Camel extends AbstractHorse {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("camelBrain");
|
|
Brain<?> brain = this.getBrain();
|
|
((Brain<Camel>)brain).tick(level, this);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("camelActivityUpdate");
|
|
CamelAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
super.customServerAiStep(level);
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/animal/frog/Frog.java b/net/minecraft/world/entity/animal/frog/Frog.java
|
|
index 1d5079602e7ae1042e2bb92209dded4007f703da..c6e4966d3e4fdb7c91577fc1693fb66930b4f3dc 100644
|
|
--- a/net/minecraft/world/entity/animal/frog/Frog.java
|
|
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
|
|
@@ -28,8 +28,6 @@ import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.Unit;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.entity.AgeableMob;
|
|
@@ -261,14 +259,9 @@ public class Frog extends Animal {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("frogBrain");
|
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("frogActivityUpdate");
|
|
FrogAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
super.customServerAiStep(level);
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
|
index 3bb197054f5197c0b8c4e2d4714d695255d5ecfa..f85626b690b02908fac3979d277b293ec48aa451 100644
|
|
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
|
|
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
|
@@ -12,8 +12,6 @@ import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.tags.ItemTags;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
@@ -137,14 +135,9 @@ public class Tadpole extends AbstractFish {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("tadpoleBrain");
|
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("tadpoleActivityUpdate");
|
|
TadpoleAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
super.customServerAiStep(level);
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java
|
|
index 386591ff45c45146b75d44071f54c2789db15a21..70b32e0d06f9b8b7999df5fdfd773c09394e23fb 100644
|
|
--- a/net/minecraft/world/entity/animal/goat/Goat.java
|
|
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
|
|
@@ -20,8 +20,6 @@ import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.tags.TagKey;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
@@ -228,14 +226,9 @@ public class Goat extends Animal {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("goatBrain");
|
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
- profilerFiller.push("goatActivityUpdate");
|
|
GoatAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
super.customServerAiStep(level);
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
index 9ad310cbc5fa41c949a37c1a5db6d6cd024f1483..a762fc8a4616c4e48e11accdca2129fd47f300e6 100644
|
|
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
@@ -29,8 +29,6 @@ import net.minecraft.tags.BlockTags;
|
|
import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.util.ByIdMap;
|
|
import net.minecraft.util.Mth;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
@@ -497,12 +495,8 @@ public class Sniffer extends Animal {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("snifferBrain");
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.popPush("snifferActivityUpdate");
|
|
SnifferAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
super.customServerAiStep(level);
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/monster/Zoglin.java b/net/minecraft/world/entity/monster/Zoglin.java
|
|
index e37c6dcbe62cba2cb7f33ac1792d539f9b07aa24..2a905e8cdf22f9d7f38cc41c1474e80f704d0cb1 100644
|
|
--- a/net/minecraft/world/entity/monster/Zoglin.java
|
|
+++ b/net/minecraft/world/entity/monster/Zoglin.java
|
|
@@ -14,8 +14,6 @@ import net.minecraft.network.syncher.SynchedEntityData;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.util.valueproviders.UniformInt;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
@@ -289,11 +287,8 @@ public class Zoglin extends Monster implements HoglinBase {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("zoglinBrain");
|
|
if (getRider() == null || !this.isControllable()) // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
this.updateActivity();
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/monster/breeze/Breeze.java b/net/minecraft/world/entity/monster/breeze/Breeze.java
|
|
index c12653070d62c44b97a07676f24caf7ab570cd2a..d91ce14cc39b1b6ccd558f53ed605d4c6a5acae5 100644
|
|
--- a/net/minecraft/world/entity/monster/breeze/Breeze.java
|
|
+++ b/net/minecraft/world/entity/monster/breeze/Breeze.java
|
|
@@ -12,8 +12,6 @@ import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
import net.minecraft.tags.EntityTypeTags;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.entity.AnimationState;
|
|
import net.minecraft.world.entity.Entity;
|
|
@@ -232,12 +230,8 @@ public class Breeze extends Monster {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("breezeBrain");
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.popPush("breezeActivityUpdate");
|
|
BreezeAi.updateActivity(this);
|
|
- profilerFiller.pop();
|
|
super.customServerAiStep(level);
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/monster/creaking/Creaking.java b/net/minecraft/world/entity/monster/creaking/Creaking.java
|
|
index 1b01d2b37dd221d5832cb68c072af9863aeb6868..775c11f658b81379784f7e5bdfdc8105b3410480 100644
|
|
--- a/net/minecraft/world/entity/monster/creaking/Creaking.java
|
|
+++ b/net/minecraft/world/entity/monster/creaking/Creaking.java
|
|
@@ -16,8 +16,6 @@ import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.tags.DamageTypeTags;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.entity.AnimationState;
|
|
import net.minecraft.world.entity.Entity;
|
|
@@ -236,10 +234,7 @@ public class Creaking extends Monster {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("creakingBrain");
|
|
this.getBrain().tick((ServerLevel)this.level(), this);
|
|
- profilerFiller.pop();
|
|
CreakingAi.updateActivity(this);
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
index 994f6e5cb0960d43de00d9ef6d25e81107e0774a..04244779a152a531ba148c450450d11a13d78a6c 100644
|
|
--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
+++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
@@ -15,8 +15,6 @@ import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.util.RandomSource;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
@@ -208,11 +206,8 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("hoglinBrain");
|
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
HoglinAi.updateActivity(this);
|
|
if (this.isConverting()) {
|
|
this.timeInOverworld++;
|
|
diff --git a/net/minecraft/world/entity/monster/piglin/Piglin.java b/net/minecraft/world/entity/monster/piglin/Piglin.java
|
|
index c48044ff1fd5b587935d11747d93598d0bc0c7a3..94c1e65a4d7d59e967f31c2692e9b448faf67a55 100644
|
|
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
|
|
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
|
|
@@ -16,8 +16,6 @@ import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.tags.TagKey;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.VisibleForDebug;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
@@ -359,11 +357,8 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("piglinBrain");
|
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
PiglinAi.updateActivity(this);
|
|
super.customServerAiStep(level);
|
|
}
|
|
diff --git a/net/minecraft/world/entity/monster/piglin/PiglinBrute.java b/net/minecraft/world/entity/monster/piglin/PiglinBrute.java
|
|
index 70ee15527fa6f30783d6a58bb767b18124f25c53..c4eb58d0b0c51e930f9cb72e1de0103902badba7 100644
|
|
--- a/net/minecraft/world/entity/monster/piglin/PiglinBrute.java
|
|
+++ b/net/minecraft/world/entity/monster/piglin/PiglinBrute.java
|
|
@@ -8,8 +8,6 @@ import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.sounds.SoundEvent;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.util.RandomSource;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.entity.EntitySpawnReason;
|
|
@@ -154,11 +152,8 @@ public class PiglinBrute extends AbstractPiglin {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("piglinBruteBrain");
|
|
if (getRider() == null || this.isControllable()) // Purpur - only use brain if no rider
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
PiglinBruteAi.updateActivity(this);
|
|
PiglinBruteAi.maybePlayActivitySound(this);
|
|
super.customServerAiStep(level);
|
|
diff --git a/net/minecraft/world/entity/monster/warden/Warden.java b/net/minecraft/world/entity/monster/warden/Warden.java
|
|
index f8a6aba7d6f0f357c72602f4ac6c2537b604eb6c..021aa51da04bea01b0e827390ce1690af7092b8f 100644
|
|
--- a/net/minecraft/world/entity/monster/warden/Warden.java
|
|
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
|
|
@@ -27,8 +27,6 @@ import net.minecraft.tags.TagKey;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.Unit;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.effect.MobEffectInstance;
|
|
@@ -303,10 +301,7 @@ public class Warden extends Monster implements VibrationSystem {
|
|
|
|
@Override
|
|
protected void customServerAiStep(ServerLevel level) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("wardenBrain");
|
|
this.getBrain().tick(level, this);
|
|
- profilerFiller.pop();
|
|
super.customServerAiStep(level);
|
|
if ((this.tickCount + this.getId()) % 120 == 0) {
|
|
applyDarknessAround(level, this.position(), this, 20);
|
|
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
|
|
index edef9b959200008dda8c5036319e29c5e2d92dae..65f65f712db967ce9b11deb278b9d0aa70368703 100644
|
|
--- a/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -35,8 +35,6 @@ import net.minecraft.stats.Stats;
|
|
import net.minecraft.tags.ItemTags;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.SpawnUtil;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.Difficulty;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.InteractionHand;
|
|
@@ -393,8 +391,6 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
}
|
|
protected void customServerAiStep(ServerLevel level, boolean inactive) { // Purpur - Lobotomize stuck villagers - not final
|
|
// Paper end - EAR 2
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("villagerBrain");
|
|
// Purpur start - Lobotomize stuck villagers
|
|
if (this.level().purpurConfig.villagerLobotomizeEnabled) {
|
|
// treat as inactive if lobotomized
|
|
@@ -409,7 +405,6 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
}
|
|
else if (this.isLobotomized && shouldRestock()) restock(); // Purpur - Lobotomize stuck villagers
|
|
// Pufferfish end
|
|
- profilerFiller.pop();
|
|
if (this.assignProfessionWhenSpawned) {
|
|
this.assignProfessionWhenSpawned = false;
|
|
}
|
|
diff --git a/net/minecraft/world/item/crafting/RecipeManager.java b/net/minecraft/world/item/crafting/RecipeManager.java
|
|
index 07d7c4737635f671f33b8f73001d67928fc75782..f2c82217811712625df594667330a73f8f44e261 100644
|
|
--- a/net/minecraft/world/item/crafting/RecipeManager.java
|
|
+++ b/net/minecraft/world/item/crafting/RecipeManager.java
|
|
@@ -28,7 +28,6 @@ import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.server.packs.resources.ResourceManager;
|
|
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
|
|
import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.flag.FeatureFlagSet;
|
|
import net.minecraft.world.item.crafting.display.RecipeDisplay;
|
|
import net.minecraft.world.item.crafting.display.RecipeDisplayEntry;
|
|
@@ -67,7 +66,7 @@ public class RecipeManager extends SimplePreparableReloadListener<RecipeMap> imp
|
|
}
|
|
|
|
@Override
|
|
- protected RecipeMap prepare(ResourceManager resourceManager, ProfilerFiller profiler) {
|
|
+ protected RecipeMap prepare(ResourceManager resourceManager) {
|
|
SortedMap<ResourceLocation, Recipe<?>> map = new TreeMap<>();
|
|
SimpleJsonResourceReloadListener.scanDirectory(
|
|
resourceManager, RECIPE_LISTER, this.registries.createSerializationContext(JsonOps.INSTANCE), Recipe.CODEC, map
|
|
@@ -82,7 +81,7 @@ public class RecipeManager extends SimplePreparableReloadListener<RecipeMap> imp
|
|
}
|
|
|
|
@Override
|
|
- protected void apply(RecipeMap object, ResourceManager resourceManager, ProfilerFiller profiler) {
|
|
+ protected void apply(RecipeMap object, ResourceManager resourceManager) {
|
|
this.recipes = object;
|
|
LOGGER.info("Loaded {} recipes", object.values().size());
|
|
}
|
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
|
index 1ad419b4a2ad4610a0a8d18b26665a7ec0ccc960..4c1ce7e85f9c3315635472047ffaf15a711aeffd 100644
|
|
--- a/net/minecraft/world/level/Level.java
|
|
+++ b/net/minecraft/world/level/Level.java
|
|
@@ -35,8 +35,6 @@ import net.minecraft.util.AbortableIterationConsumer;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.StringRepresentable;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.DifficultyInstance;
|
|
import net.minecraft.world.TickRateManager;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
@@ -254,7 +252,6 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
|
|
@Override
|
|
public final <T extends Entity> List<T> getEntitiesOfClass(final Class<T> entityClass, final AABB boundingBox, final Predicate<? super T> predicate) {
|
|
- Profiler.get().incrementCounter("getEntities");
|
|
final List<T> ret = new java.util.ArrayList<>();
|
|
|
|
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(entityClass, null, boundingBox, ret, predicate);
|
|
@@ -264,7 +261,6 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
|
|
@Override
|
|
public final List<Entity> moonrise$getHardCollidingEntities(final Entity entity, final AABB box, final Predicate<? super Entity> predicate) {
|
|
- Profiler.get().incrementCounter("getEntities");
|
|
final List<Entity> ret = new java.util.ArrayList<>();
|
|
|
|
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getHardCollidingEntities(entity, box, ret, predicate);
|
|
@@ -1498,8 +1494,6 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
}
|
|
|
|
protected void tickBlockEntities() {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("blockEntities");
|
|
this.tickingBlockEntities = true;
|
|
if (!this.pendingBlockEntityTickers.isEmpty()) {
|
|
this.blockEntityTickers.addAll(this.pendingBlockEntityTickers);
|
|
@@ -1529,7 +1523,6 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
|
|
|
|
this.tickingBlockEntities = false;
|
|
- profilerFiller.pop();
|
|
this.spigotConfig.currentPrimedTnt = 0; // Spigot
|
|
}
|
|
|
|
@@ -1781,7 +1774,6 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
|
|
@Override
|
|
public List<Entity> getEntities(@Nullable Entity entity, AABB boundingBox, Predicate<? super Entity> predicate) {
|
|
- Profiler.get().incrementCounter("getEntities");
|
|
List<Entity> list = Lists.newArrayList();
|
|
|
|
// Paper start - rewrite chunk system
|
|
@@ -1810,8 +1802,6 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
public <T extends Entity> void getEntities(final EntityTypeTest<Entity, T> entityTypeTest,
|
|
final AABB boundingBox, final Predicate<? super T> predicate,
|
|
final List<? super T> into, final int maxCount) {
|
|
- Profiler.get().incrementCounter("getEntities");
|
|
-
|
|
if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) {
|
|
if (maxCount != Integer.MAX_VALUE) {
|
|
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(byType, boundingBox, into, predicate, maxCount);
|
|
diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java
|
|
index fa06ecacc27f619853c8db76d909ab4ba75dc529..345d4b80bd4383e0fb66d744d87bc8ef4100fd32 100644
|
|
--- a/net/minecraft/world/level/NaturalSpawner.java
|
|
+++ b/net/minecraft/world/level/NaturalSpawner.java
|
|
@@ -23,8 +23,6 @@ import net.minecraft.tags.BlockTags;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.util.VisibleForDebug;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.util.random.WeightedList;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.EntitySpawnReason;
|
|
@@ -152,9 +150,6 @@ public final class NaturalSpawner {
|
|
}
|
|
|
|
public static void spawnForChunk(ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnState spawnState, List<MobCategory> categories) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("spawner");
|
|
-
|
|
for (MobCategory mobCategory : categories) {
|
|
// Paper start - Optional per player mob spawns
|
|
final boolean canSpawn;
|
|
@@ -189,8 +184,6 @@ public final class NaturalSpawner {
|
|
// Paper end - Optional per player mob spawns
|
|
}
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
// Paper start - Add mobcaps commands
|
|
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
|
|
index b80924fbe054b00fe5117df896358e330f41e993..1669c21534a453c9cf16b992df7a6bf276dea887 100644
|
|
--- a/net/minecraft/world/level/ServerExplosion.java
|
|
+++ b/net/minecraft/world/level/ServerExplosion.java
|
|
@@ -13,8 +13,6 @@ import net.minecraft.Util;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.util.Mth;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.EntityType;
|
|
@@ -669,10 +667,7 @@ public class ServerExplosion implements Explosion {
|
|
List<BlockPos> list = this.calculateExplodedPositions();
|
|
this.hurtEntities();
|
|
if (this.interactsWithBlocks()) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("explosion_blocks");
|
|
this.interactWithBlocks(list);
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
if (this.fire) {
|
|
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..b88254fb3c12b99684c6ede1ae8a6671ffbe9ad6 100644
|
|
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -24,8 +24,6 @@ import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
|
|
import net.minecraft.server.level.FullChunkStatus;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.util.ProblemReporter;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.level.ChunkPos;
|
|
import net.minecraft.world.level.Level;
|
|
@@ -385,12 +383,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
}
|
|
|
|
if (LightEngine.hasDifferentLightProperties(blockState, state)) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("updateSkyLightSources");
|
|
// Paper - rewrite chunk system
|
|
- profilerFiller.popPush("queueCheckLight");
|
|
this.level.getChunkSource().getLightEngine().checkBlock(pos);
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
boolean flag = !blockState.is(block);
|
|
@@ -922,8 +916,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
BlockPos blockPos = this.blockEntity.getBlockPos();
|
|
if (LevelChunk.this.isTicking(blockPos)) {
|
|
try {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push(this::getType);
|
|
BlockState blockState = LevelChunk.this.getBlockState(blockPos);
|
|
if (this.blockEntity.getType().isValid(blockState)) {
|
|
this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity);
|
|
@@ -937,8 +929,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
|
}
|
|
// Paper end - Remove the Block Entity if it's invalid
|
|
}
|
|
-
|
|
- profilerFiller.pop();
|
|
} catch (Throwable var5) {
|
|
// Paper start - Prevent block entity and entity crashes
|
|
final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", LevelChunk.this.getLevel().getWorld().getName(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
|
|
diff --git a/net/minecraft/world/level/pathfinder/PathFinder.java b/net/minecraft/world/level/pathfinder/PathFinder.java
|
|
index 81de6c1bbef1cafd3036e736dd305fbedc8368c6..c2baadcdceb1df6a881d6f73aa4eb4dd264bcdfe 100644
|
|
--- a/net/minecraft/world/level/pathfinder/PathFinder.java
|
|
+++ b/net/minecraft/world/level/pathfinder/PathFinder.java
|
|
@@ -12,9 +12,6 @@ import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.core.BlockPos;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
-import net.minecraft.util.profiling.metrics.MetricCategory;
|
|
import net.minecraft.world.entity.Mob;
|
|
import net.minecraft.world.level.PathNavigationRegion;
|
|
|
|
@@ -57,9 +54,6 @@ public class PathFinder {
|
|
|
|
@Nullable
|
|
private Path findPath(Node node, List<Map.Entry<Target, BlockPos>> positions, float maxRange, int accuracy, float searchDepthMultiplier) { // Paper - optimize collection
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("find_path");
|
|
- profilerFiller.markForCharting(MetricCategory.PATH_FINDING);
|
|
// Set<Target> set = targetPositions.keySet(); // Paper
|
|
node.g = 0.0F;
|
|
node.h = this.getBestH(node, positions); // Paper - optimize collection
|
|
@@ -129,7 +123,6 @@ public class PathFinder {
|
|
best = path;
|
|
}
|
|
}
|
|
- profilerFiller.pop();
|
|
return best;
|
|
// Paper end - Perf: remove streams and optimize collection
|
|
}
|
|
diff --git a/net/minecraft/world/ticks/LevelTicks.java b/net/minecraft/world/ticks/LevelTicks.java
|
|
index 66abc2e7adee60fa98eed1ba36e018814fd02cad..0a9805d42142678ca5213c511235daa6505ddbf3 100644
|
|
--- a/net/minecraft/world/ticks/LevelTicks.java
|
|
+++ b/net/minecraft/world/ticks/LevelTicks.java
|
|
@@ -23,8 +23,6 @@ import net.minecraft.Util;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.SectionPos;
|
|
import net.minecraft.core.Vec3i;
|
|
-import net.minecraft.util.profiling.Profiler;
|
|
-import net.minecraft.util.profiling.ProfilerFiller;
|
|
import net.minecraft.world.level.ChunkPos;
|
|
import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
|
|
|
@@ -80,20 +78,13 @@ public class LevelTicks<T> implements LevelTickAccess<T> {
|
|
}
|
|
|
|
public void tick(long gameTime, int maxAllowedTicks, BiConsumer<BlockPos, T> ticker) {
|
|
- ProfilerFiller profilerFiller = Profiler.get();
|
|
- profilerFiller.push("collect");
|
|
- this.collectTicks(gameTime, maxAllowedTicks, profilerFiller);
|
|
- profilerFiller.popPush("run");
|
|
- profilerFiller.incrementCounter("ticksToRun", this.toRunThisTick.size());
|
|
+ this.collectTicks(gameTime, maxAllowedTicks);
|
|
this.runCollectedTicks(ticker);
|
|
- profilerFiller.popPush("cleanup");
|
|
this.cleanupAfterTick();
|
|
- profilerFiller.pop();
|
|
}
|
|
|
|
- private void collectTicks(long gameTime, int maxAllowedTicks, ProfilerFiller profiler) {
|
|
+ private void collectTicks(long gameTime, int maxAllowedTicks) {
|
|
this.sortContainersToTick(gameTime);
|
|
- profiler.incrementCounter("containersToTick", this.containersToTick.size());
|
|
this.drainContainers(gameTime, maxAllowedTicks);
|
|
this.rescheduleLeftoverContainers();
|
|
}
|