2020-05-06 09:48:49 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2016-01-09 06:32:38 +00:00
From: Aikar <aikar@aikar.co>
2016-03-03 09:46:26 +00:00
Date: Thu, 3 Mar 2016 04:00:11 -0600
2016-01-09 06:32:38 +00:00
Subject: [PATCH] Timings v2
2016-04-30 01:23:40 +00:00
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
2016-01-10 07:33:27 +00:00
new file mode 100644
2020-09-10 22:02:39 +00:00
index 0000000000000000000000000000000000000000..11fe3524f38f7756ebd0e3807678e8848fd2217d
2016-01-10 07:33:27 +00:00
--- /dev/null
2016-04-30 01:23:40 +00:00
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
2020-09-10 22:02:39 +00:00
@@ -0,0 +1,148 @@
2018-09-03 14:38:28 +00:00
+package co.aikar.timings;
2016-01-10 07:33:27 +00:00
+
2018-09-03 14:04:50 +00:00
+import com.google.common.collect.MapMaker;
2016-01-10 07:33:27 +00:00
+import net.minecraft.server.*;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.scheduler.BukkitTask;
+
+import org.bukkit.craftbukkit.scheduler.CraftTask;
+
2018-09-03 14:04:50 +00:00
+import java.util.Map;
+
2019-04-24 01:00:24 +00:00
+// TODO: Re-implement missing timers
2016-04-30 01:23:40 +00:00
+public final class MinecraftTimings {
2016-01-10 07:33:27 +00:00
+
2019-09-29 20:49:38 +00:00
+ public static final Timing serverOversleep = Timings.ofSafe("Server Oversleep");
2016-01-10 07:33:27 +00:00
+ public static final Timing playerListTimer = Timings.ofSafe("Player List");
2017-05-14 18:05:01 +00:00
+ public static final Timing commandFunctionsTimer = Timings.ofSafe("Command Functions");
2016-01-10 07:33:27 +00:00
+ public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
+ public static final Timing tickablesTimer = Timings.ofSafe("Tickables");
2016-02-24 04:35:34 +00:00
+ public static final Timing minecraftSchedulerTimer = Timings.ofSafe("Minecraft Scheduler");
+ public static final Timing bukkitSchedulerTimer = Timings.ofSafe("Bukkit Scheduler");
2017-02-05 05:13:16 +00:00
+ public static final Timing bukkitSchedulerPendingTimer = Timings.ofSafe("Bukkit Scheduler - Pending");
+ public static final Timing bukkitSchedulerFinishTimer = Timings.ofSafe("Bukkit Scheduler - Finishing");
2016-01-10 07:33:27 +00:00
+ public static final Timing chunkIOTickTimer = Timings.ofSafe("ChunkIOTick");
+ public static final Timing timeUpdateTimer = Timings.ofSafe("Time Update");
+ public static final Timing serverCommandTimer = Timings.ofSafe("Server Command");
2016-10-21 20:42:49 +00:00
+ public static final Timing savePlayers = Timings.ofSafe("Save Players");
2016-01-10 07:33:27 +00:00
+
+ public static final Timing tickEntityTimer = Timings.ofSafe("## tickEntity");
+ public static final Timing tickTileEntityTimer = Timings.ofSafe("## tickTileEntity");
2017-02-05 05:13:16 +00:00
+ public static final Timing packetProcessTimer = Timings.ofSafe("## Packet Processing");
+ public static final Timing scheduledBlocksTimer = Timings.ofSafe("## Scheduled Blocks");
+ public static final Timing structureGenerationTimer = Timings.ofSafe("Structure Generation");
2016-01-10 07:33:27 +00:00
+
+ public static final Timing processQueueTimer = Timings.ofSafe("processQueue");
2019-07-24 03:20:14 +00:00
+ public static final Timing processTasksTimer = Timings.ofSafe("processTasks");
2016-01-10 07:33:27 +00:00
+
+ public static final Timing playerCommandTimer = Timings.ofSafe("playerCommand");
+
+ public static final Timing entityActivationCheckTimer = Timings.ofSafe("entityActivationCheck");
+
+ public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update");
+ public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate");
+
2018-11-24 05:28:04 +00:00
+ private static final Map<Class<?>, String> taskNameCache = new MapMaker().weakKeys().makeMap();
2018-09-03 14:04:50 +00:00
+
2016-04-30 01:23:40 +00:00
+ private MinecraftTimings() {}
2016-01-10 07:33:27 +00:00
+
2020-06-09 07:17:25 +00:00
+ public static Timing getInternalTaskName(String taskName) {
+ return Timings.ofSafe(taskName);
+ }
+
2016-01-10 07:33:27 +00:00
+ /**
+ * Gets a timer associated with a plugins tasks.
+ * @param bukkitTask
+ * @param period
+ * @return
+ */
+ public static Timing getPluginTaskTimings(BukkitTask bukkitTask, long period) {
+ if (!bukkitTask.isSync()) {
2019-03-26 05:31:59 +00:00
+ return NullTimingHandler.NULL;
2016-01-10 07:33:27 +00:00
+ }
+ Plugin plugin;
+
2018-11-24 05:28:04 +00:00
+ CraftTask craftTask = (CraftTask) bukkitTask;
2016-01-10 07:33:27 +00:00
+
2018-11-24 05:28:04 +00:00
+ final Class<?> taskClass = craftTask.getTaskClass();
2016-01-10 07:33:27 +00:00
+ if (bukkitTask.getOwner() != null) {
+ plugin = bukkitTask.getOwner();
+ } else {
+ plugin = TimingsManager.getPluginByClassloader(taskClass);
+ }
+
2019-12-15 22:39:25 +00:00
+ final String taskname = taskNameCache.computeIfAbsent(taskClass, clazz -> {
+ try {
2020-06-08 16:22:40 +00:00
+ String clsName = !clazz.isMemberClass()
2020-06-03 03:26:29 +00:00
+ ? clazz.getName()
+ : clazz.getCanonicalName();
2020-06-08 16:22:40 +00:00
+ if (clsName != null && clsName.contains("$Lambda$")) {
2020-06-03 03:26:29 +00:00
+ clsName = clsName.replaceAll("(Lambda\\$.*?)/.*", "$1");
+ }
2020-06-08 16:22:40 +00:00
+ return clsName != null ? clsName : "UnknownTask";
2019-12-15 22:39:25 +00:00
+ } catch (Throwable ex) {
+ new Exception("Error occurred detecting class name", ex).printStackTrace();
+ return "MangledClassFile";
+ }
+ });
2016-01-10 07:33:27 +00:00
+
2017-02-05 05:13:16 +00:00
+ StringBuilder name = new StringBuilder(64);
+ name.append("Task: ").append(taskname);
2016-01-10 07:33:27 +00:00
+ if (period > 0) {
2017-02-05 05:13:16 +00:00
+ name.append(" (interval:").append(period).append(")");
2016-01-10 07:33:27 +00:00
+ } else {
2017-02-05 05:13:16 +00:00
+ name.append(" (Single)");
2016-01-10 07:33:27 +00:00
+ }
+
+ if (plugin == null) {
2017-02-05 05:13:16 +00:00
+ return Timings.ofSafe(null, name.toString());
2016-01-10 07:33:27 +00:00
+ }
+
2017-02-05 05:13:16 +00:00
+ return Timings.ofSafe(plugin, name.toString());
2016-01-10 07:33:27 +00:00
+ }
+
+ /**
+ * Get a named timer for the specified entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
2020-09-10 22:02:39 +00:00
+ public static Timing getEntityTimings(String entityType, String type) {
+ return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType + " - " + type, tickEntityTimer);
2016-01-10 07:33:27 +00:00
+ }
+
+ /**
+ * Get a named timer for the specified tile entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static Timing getTileEntityTimings(TileEntity entity) {
+ String entityType = entity.getClass().getName();
+ return Timings.ofSafe("Minecraft", "## tickTileEntity - " + entityType, tickTileEntityTimer);
+ }
+ public static Timing getCancelTasksTimer() {
+ return Timings.ofSafe("Cancel Tasks");
+ }
+ public static Timing getCancelTasksTimer(Plugin plugin) {
+ return Timings.ofSafe(plugin, "Cancel Tasks");
+ }
+
+ public static void stopServer() {
+ TimingsManager.stopServer();
+ }
+
+ public static Timing getBlockTiming(Block block) {
2018-07-15 01:53:17 +00:00
+ return Timings.ofSafe("## Scheduled Block: " + block.toString(), scheduledBlocksTimer);
2016-01-10 07:33:27 +00:00
+ }
2018-07-15 01:53:17 +00:00
+/*
2016-08-28 00:36:26 +00:00
+ public static Timing getStructureTiming(StructureGenerator structureGenerator) {
2017-02-05 05:13:16 +00:00
+ return Timings.ofSafe("Structure Generator - " + structureGenerator.getName(), structureGenerationTimer);
2018-07-15 01:53:17 +00:00
+ }*/
2017-02-05 05:13:16 +00:00
+
+ public static Timing getPacketTiming(Packet packet) {
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.
Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.
This guarantees that your chunk will load with at most around 1ms delay.
Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...
Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.
Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.
This is now fixed.
Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.
Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".
This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.
It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.
We solve this by ensuring new additions do not enter the currently iterated queue.
Each depth level will have its own queue.
Fixes #3220
2020-04-26 03:47:29 +00:00
+ return Timings.ofSafe("## Packet - " + packet.getClass().getName(), packetProcessTimer);
2016-08-28 00:36:26 +00:00
+ }
2018-08-27 22:30:58 +00:00
+
+ public static Timing getCommandFunctionTiming(CustomFunction function) {
+ return Timings.ofSafe("Command Function - " + function.getMinecraftKey().toString());
+ }
2016-08-28 00:36:26 +00:00
+}
2020-06-03 03:26:29 +00:00
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
new file mode 100644
index 0000000000000000000000000000000000000000..d4ebcf8f66197299256bd6b65710a1488c90ea41
--- /dev/null
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
@@ -0,0 +1,377 @@
+/*
+ * This file is licensed under the MIT License (MIT).
+ *
+ * Copyright (c) 2014 Daniel Ennis <http://aikar.co>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package co.aikar.timings;
+
+import com.google.common.collect.Sets;
+import net.minecraft.server.MinecraftServer;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.MemorySection;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.entity.EntityType;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.management.ManagementFactory;
+import java.lang.management.OperatingSystemMXBean;
+import java.lang.management.RuntimeMXBean;
+import java.net.HttpURLConnection;
+import java.net.InetAddress;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.zip.GZIPOutputStream;
+
+import static co.aikar.timings.TimingsManager.HISTORY;
+import static co.aikar.util.JSONUtil.appendObjectData;
+import static co.aikar.util.JSONUtil.createObject;
+import static co.aikar.util.JSONUtil.pair;
+import static co.aikar.util.JSONUtil.toArray;
+import static co.aikar.util.JSONUtil.toArrayMapper;
+import static co.aikar.util.JSONUtil.toObjectMapper;
+
+@SuppressWarnings({"rawtypes", "SuppressionAnnotation"})
+public class TimingsExport extends Thread {
+
+ private final TimingsReportListener listeners;
+ private final Map out;
+ private final TimingHistory[] history;
+ private static long lastReport = 0;
+
+ private TimingsExport(TimingsReportListener listeners, Map out, TimingHistory[] history) {
+ super("Timings paste thread");
+ this.listeners = listeners;
+ this.out = out;
+ this.history = history;
+ }
+
+ /**
+ * Checks if any pending reports are being requested, and builds one if needed.
+ */
+ public static void reportTimings() {
+ if (Timings.requestingReport.isEmpty()) {
+ return;
+ }
+ TimingsReportListener listeners = new TimingsReportListener(Timings.requestingReport);
+ listeners.addConsoleIfNeeded();
+
+ Timings.requestingReport.clear();
+ long now = System.currentTimeMillis();
+ final long lastReportDiff = now - lastReport;
+ if (lastReportDiff < 60000) {
+ listeners.sendMessage(ChatColor.RED + "Please wait at least 1 minute in between Timings reports. (" + (int)((60000 - lastReportDiff) / 1000) + " seconds)");
+ listeners.done();
+ return;
+ }
+ final long lastStartDiff = now - TimingsManager.timingStart;
+ if (lastStartDiff < 180000) {
+ listeners.sendMessage(ChatColor.RED + "Please wait at least 3 minutes before generating a Timings report. Unlike Timings v1, v2 benefits from longer timings and is not as useful with short timings. (" + (int)((180000 - lastStartDiff) / 1000) + " seconds)");
+ listeners.done();
+ return;
+ }
+ listeners.sendMessage(ChatColor.GREEN + "Preparing Timings Report...");
+ lastReport = now;
+ Map parent = createObject(
+ // Get some basic system details about the server
+ pair("version", Bukkit.getVersion()),
+ pair("maxplayers", Bukkit.getMaxPlayers()),
+ pair("start", TimingsManager.timingStart / 1000),
+ pair("end", System.currentTimeMillis() / 1000),
+ pair("online-mode", Bukkit.getServer().getOnlineMode()),
+ pair("sampletime", (System.currentTimeMillis() - TimingsManager.timingStart) / 1000),
+ pair("datapacks", toArrayMapper(MinecraftServer.getServer().getResourcePackRepository().d(), pack -> {
+ // Don't feel like obf helper'ing these, non fatal if its temp missed.
+ return ChatColor.stripColor(CraftChatMessage.fromComponent(pack.a(true)));
+ }))
+ );
+ if (!TimingsManager.privacy) {
+ appendObjectData(parent,
+ pair("server", Bukkit.getUnsafe().getTimingsServerName()),
+ pair("motd", Bukkit.getServer().getMotd()),
+ pair("icon", Bukkit.getServer().getServerIcon().getData())
+ );
+ }
+
+ final Runtime runtime = Runtime.getRuntime();
+ RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
+
+ OperatingSystemMXBean osInfo = ManagementFactory.getOperatingSystemMXBean();
+
+ parent.put("system", createObject(
+ pair("timingcost", getCost()),
+ pair("loadavg", osInfo.getSystemLoadAverage()),
+ pair("name", System.getProperty("os.name")),
+ pair("version", System.getProperty("os.version")),
+ pair("jvmversion", System.getProperty("java.version")),
+ pair("arch", System.getProperty("os.arch")),
+ pair("maxmem", runtime.maxMemory()),
+ pair("memory", createObject(
+ pair("heap", ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().toString()),
+ pair("nonheap", ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().toString()),
+ pair("finalizing", ManagementFactory.getMemoryMXBean().getObjectPendingFinalizationCount())
+ )),
+ pair("cpu", runtime.availableProcessors()),
+ pair("runtime", runtimeBean.getUptime()),
+ pair("flags", StringUtils.join(runtimeBean.getInputArguments(), " ")),
+ pair("gc", toObjectMapper(ManagementFactory.getGarbageCollectorMXBeans(), input -> pair(input.getName(), toArray(input.getCollectionCount(), input.getCollectionTime()))))
+ )
+ );
+
+ parent.put("worlds", toObjectMapper(MinecraftServer.getServer().getWorlds(), world -> {
+ if (world.getWorldData().getName().equals("worldeditregentempworld")) return null;
+ return pair(world.getWorldData().getName(), createObject(
+ pair("gamerules", toObjectMapper(world.getWorld().getGameRules(), rule -> {
+ return pair(rule, world.getWorld().getGameRuleValue(rule));
+ })),
+ pair("ticking-distance", world.getChunkProvider().playerChunkMap.getEffectiveViewDistance())
+ ));
+ }));
+
+ Set<Material> tileEntityTypeSet = Sets.newHashSet();
+ Set<EntityType> entityTypeSet = Sets.newHashSet();
+
+ int size = HISTORY.size();
+ TimingHistory[] history = new TimingHistory[size + 1];
+ int i = 0;
+ for (TimingHistory timingHistory : HISTORY) {
+ tileEntityTypeSet.addAll(timingHistory.tileEntityTypeSet);
+ entityTypeSet.addAll(timingHistory.entityTypeSet);
+ history[i++] = timingHistory;
+ }
+
+ history[i] = new TimingHistory(); // Current snapshot
+ tileEntityTypeSet.addAll(history[i].tileEntityTypeSet);
+ entityTypeSet.addAll(history[i].entityTypeSet);
+
+
+ Map handlers = createObject();
+ Map groupData;
+ synchronized (TimingIdentifier.GROUP_MAP) {
+ for (TimingIdentifier.TimingGroup group : TimingIdentifier.GROUP_MAP.values()) {
+ synchronized (group.handlers) {
+ for (TimingHandler id : group.handlers) {
+
+ if (!id.isTimed() && !id.isSpecial()) {
+ continue;
+ }
+
+ String name = id.identifier.name;
+ if (name.startsWith("##")) {
+ name = name.substring(3);
+ }
+ handlers.put(id.id, toArray(
+ group.id,
+ name
+ ));
+ }
+ }
+ }
+
+ groupData = toObjectMapper(
+ TimingIdentifier.GROUP_MAP.values(), group -> pair(group.id, group.name));
+ }
+
+ parent.put("idmap", createObject(
+ pair("groups", groupData),
+ pair("handlers", handlers),
+ pair("worlds", toObjectMapper(TimingHistory.worldMap.entrySet(), input -> pair(input.getValue(), input.getKey()))),
+ pair("tileentity",
+ toObjectMapper(tileEntityTypeSet, input -> pair(input.ordinal(), input.name()))),
+ pair("entity",
+ toObjectMapper(entityTypeSet, input -> pair(input.ordinal(), input.name())))
+ ));
+
+ // Information about loaded plugins
+
+ parent.put("plugins", toObjectMapper(Bukkit.getPluginManager().getPlugins(),
+ plugin -> pair(plugin.getName(), createObject(
+ pair("version", plugin.getDescription().getVersion()),
+ pair("description", String.valueOf(plugin.getDescription().getDescription()).trim()),
+ pair("website", plugin.getDescription().getWebsite()),
+ pair("authors", StringUtils.join(plugin.getDescription().getAuthors(), ", "))
+ ))));
+
+
+
+ // Information on the users Config
+
+ parent.put("config", createObject(
+ pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
+ pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null))
+ ));
+
+ new TimingsExport(listeners, parent, history).start();
+ }
+
+ static long getCost() {
+ // Benchmark the users System.nanotime() for cost basis
+ int passes = 100;
+ TimingHandler SAMPLER1 = Timings.ofSafe("Timings Sampler 1");
+ TimingHandler SAMPLER2 = Timings.ofSafe("Timings Sampler 2");
+ TimingHandler SAMPLER3 = Timings.ofSafe("Timings Sampler 3");
+ TimingHandler SAMPLER4 = Timings.ofSafe("Timings Sampler 4");
+ TimingHandler SAMPLER5 = Timings.ofSafe("Timings Sampler 5");
+ TimingHandler SAMPLER6 = Timings.ofSafe("Timings Sampler 6");
+
+ long start = System.nanoTime();
+ for (int i = 0; i < passes; i++) {
+ SAMPLER1.startTiming();
+ SAMPLER2.startTiming();
+ SAMPLER3.startTiming();
+ SAMPLER3.stopTiming();
+ SAMPLER4.startTiming();
+ SAMPLER5.startTiming();
+ SAMPLER6.startTiming();
+ SAMPLER6.stopTiming();
+ SAMPLER5.stopTiming();
+ SAMPLER4.stopTiming();
+ SAMPLER2.stopTiming();
+ SAMPLER1.stopTiming();
+ }
+ long timingsCost = (System.nanoTime() - start) / passes / 6;
+ SAMPLER1.reset(true);
+ SAMPLER2.reset(true);
+ SAMPLER3.reset(true);
+ SAMPLER4.reset(true);
+ SAMPLER5.reset(true);
+ SAMPLER6.reset(true);
+ return timingsCost;
+ }
+
+ private static JSONObject mapAsJSON(ConfigurationSection config, String parentKey) {
+
+ JSONObject object = new JSONObject();
+ for (String key : config.getKeys(false)) {
+ String fullKey = (parentKey != null ? parentKey + "." + key : key);
+ if (fullKey.equals("database") || fullKey.equals("settings.bungeecord-addresses") || TimingsManager.hiddenConfigs.contains(fullKey) || key.startsWith("seed-") || key.equals("worldeditregentempworld")) {
+ continue;
+ }
+ final Object val = config.get(key);
+
+ object.put(key, valAsJSON(val, fullKey));
+ }
+ return object;
+ }
+
+ private static Object valAsJSON(Object val, final String parentKey) {
+ if (!(val instanceof MemorySection)) {
+ if (val instanceof List) {
+ Iterable<Object> v = (Iterable<Object>) val;
+ return toArrayMapper(v, input -> valAsJSON(input, parentKey));
+ } else {
+ return String.valueOf(val);
+ }
+ } else {
+ return mapAsJSON((ConfigurationSection) val, parentKey);
+ }
+ }
+
+ @Override
+ public void run() {
+ out.put("data", toArrayMapper(history, TimingHistory::export));
+
+
+ String response = null;
+ String timingsURL = null;
+ try {
+ HttpURLConnection con = (HttpURLConnection) new URL("http://timings.aikar.co/post").openConnection();
+ con.setDoOutput(true);
+ String hostName = "BrokenHost";
+ try {
+ hostName = InetAddress.getLocalHost().getHostName();
+ } catch (Exception ignored) {}
+ con.setRequestProperty("User-Agent", "Paper/" + Bukkit.getUnsafe().getTimingsServerName() + "/" + hostName);
+ con.setRequestMethod("POST");
+ con.setInstanceFollowRedirects(false);
+
+ OutputStream request = new GZIPOutputStream(con.getOutputStream()) {{
+ this.def.setLevel(7);
+ }};
+
+ request.write(JSONValue.toJSONString(out).getBytes("UTF-8"));
+ request.close();
+
+ response = getResponse(con);
+
+ if (con.getResponseCode() != 302) {
+ listeners.sendMessage(
+ ChatColor.RED + "Upload Error: " + con.getResponseCode() + ": " + con.getResponseMessage());
+ listeners.sendMessage(ChatColor.RED + "Check your logs for more information");
+ if (response != null) {
+ Bukkit.getLogger().log(Level.SEVERE, response);
+ }
+ return;
+ }
+
+ timingsURL = con.getHeaderField("Location");
+ listeners.sendMessage(ChatColor.GREEN + "View Timings Report: " + timingsURL);
+
+ if (response != null && !response.isEmpty()) {
+ Bukkit.getLogger().log(Level.INFO, "Timing Response: " + response);
+ }
+ } catch (IOException ex) {
+ listeners.sendMessage(ChatColor.RED + "Error uploading timings, check your logs for more information");
+ if (response != null) {
+ Bukkit.getLogger().log(Level.SEVERE, response);
+ }
+ Bukkit.getLogger().log(Level.SEVERE, "Could not paste timings", ex);
+ } finally {
+ this.listeners.done(timingsURL);
+ }
+ }
+
+ private String getResponse(HttpURLConnection con) throws IOException {
+ InputStream is = null;
+ try {
+ is = con.getInputStream();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+
+ byte[] b = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = is.read(b)) != -1) {
+ bos.write(b, 0, bytesRead);
+ }
+ return bos.toString();
+
+ } catch (IOException ex) {
+ listeners.sendMessage(ChatColor.RED + "Error uploading timings, check your logs for more information");
+ Bukkit.getLogger().log(Level.WARNING, con.getResponseMessage(), ex);
+ return null;
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ }
+ }
+}
2016-01-10 07:33:27 +00:00
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
new file mode 100644
2020-06-26 12:04:38 +00:00
index 0000000000000000000000000000000000000000..944fd203e9f39d6c6fc9e270940c76c98067273a
2016-01-10 07:33:27 +00:00
--- /dev/null
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
2020-06-26 12:04:38 +00:00
@@ -0,0 +1,119 @@
2016-01-10 07:33:27 +00:00
+package co.aikar.timings;
+
+import net.minecraft.server.World;
2020-06-26 12:04:38 +00:00
+import net.minecraft.server.WorldDataServer;
2018-07-15 01:53:17 +00:00
+import net.minecraft.server.WorldServer;
2016-01-10 07:33:27 +00:00
+
+/**
+ * Set of timers per world, to track world specific timings.
+ */
2019-04-24 01:00:24 +00:00
+// TODO: Re-implement missing timers
2016-01-10 07:33:27 +00:00
+public class WorldTimingsHandler {
+ public final Timing mobSpawn;
+ public final Timing doChunkUnload;
+ public final Timing doPortalForcer;
+ public final Timing scheduledBlocks;
+ public final Timing scheduledBlocksCleanup;
+ public final Timing scheduledBlocksTicking;
+ public final Timing chunkTicks;
2016-08-28 00:36:26 +00:00
+ public final Timing lightChunk;
2016-01-10 07:33:27 +00:00
+ public final Timing chunkTicksBlocks;
+ public final Timing doVillages;
+ public final Timing doChunkMap;
2016-06-05 04:10:50 +00:00
+ public final Timing doChunkMapUpdate;
+ public final Timing doChunkMapToUpdate;
+ public final Timing doChunkMapSortMissing;
+ public final Timing doChunkMapSortSendToPlayers;
+ public final Timing doChunkMapPlayersNeedingChunks;
+ public final Timing doChunkMapPendingSendToPlayers;
+ public final Timing doChunkMapUnloadChunks;
2016-01-10 07:33:27 +00:00
+ public final Timing doChunkGC;
+ public final Timing doSounds;
+ public final Timing entityRemoval;
+ public final Timing entityTick;
+ public final Timing tileEntityTick;
+ public final Timing tileEntityPending;
2016-04-30 01:23:40 +00:00
+ public final Timing tracker1;
+ public final Timing tracker2;
2016-01-10 07:33:27 +00:00
+ public final Timing doTick;
+ public final Timing tickEntities;
2019-07-24 03:20:14 +00:00
+ public final Timing chunks;
+ public final Timing newEntities;
+ public final Timing raids;
+ public final Timing chunkProviderTick;
+ public final Timing broadcastChunkUpdates;
+ public final Timing countNaturalMobs;
2016-01-10 07:33:27 +00:00
+
2020-04-26 06:05:41 +00:00
+ public final Timing chunkLoad;
+ public final Timing chunkLoadPopulate;
+ public final Timing syncChunkLoad;
2018-07-15 01:53:17 +00:00
+ public final Timing chunkLoadLevelTimer;
2020-04-26 06:05:41 +00:00
+ public final Timing chunkIO;
+ public final Timing chunkPostLoad;
2016-10-21 20:42:49 +00:00
+ public final Timing worldSave;
+ public final Timing worldSaveChunks;
+ public final Timing worldSaveLevel;
+ public final Timing chunkSaveData;
2016-01-10 07:33:27 +00:00
+
2019-09-29 21:06:03 +00:00
+
+ public final Timing miscMobSpawning;
+
2016-01-10 07:33:27 +00:00
+ public WorldTimingsHandler(World server) {
2020-06-26 12:04:38 +00:00
+ String name = ((WorldDataServer) server.getWorldData()).getName() + " - ";
2016-01-10 07:33:27 +00:00
+
+ mobSpawn = Timings.ofSafe(name + "mobSpawn");
+ doChunkUnload = Timings.ofSafe(name + "doChunkUnload");
+ scheduledBlocks = Timings.ofSafe(name + "Scheduled Blocks");
+ scheduledBlocksCleanup = Timings.ofSafe(name + "Scheduled Blocks - Cleanup");
+ scheduledBlocksTicking = Timings.ofSafe(name + "Scheduled Blocks - Ticking");
+ chunkTicks = Timings.ofSafe(name + "Chunk Ticks");
2016-08-28 00:36:26 +00:00
+ lightChunk = Timings.ofSafe(name + "Light Chunk");
2016-01-10 07:33:27 +00:00
+ chunkTicksBlocks = Timings.ofSafe(name + "Chunk Ticks - Blocks");
+ doVillages = Timings.ofSafe(name + "doVillages");
+ doChunkMap = Timings.ofSafe(name + "doChunkMap");
2016-06-05 04:10:50 +00:00
+ doChunkMapUpdate = Timings.ofSafe(name + "doChunkMap - Update");
+ doChunkMapToUpdate = Timings.ofSafe(name + "doChunkMap - To Update");
+ doChunkMapSortMissing = Timings.ofSafe(name + "doChunkMap - Sort Missing");
+ doChunkMapSortSendToPlayers = Timings.ofSafe(name + "doChunkMap - Sort Send To Players");
+ doChunkMapPlayersNeedingChunks = Timings.ofSafe(name + "doChunkMap - Players Needing Chunks");
+ doChunkMapPendingSendToPlayers = Timings.ofSafe(name + "doChunkMap - Pending Send To Players");
+ doChunkMapUnloadChunks = Timings.ofSafe(name + "doChunkMap - Unload Chunks");
2016-01-10 07:33:27 +00:00
+ doSounds = Timings.ofSafe(name + "doSounds");
+ doChunkGC = Timings.ofSafe(name + "doChunkGC");
+ doPortalForcer = Timings.ofSafe(name + "doPortalForcer");
+ entityTick = Timings.ofSafe(name + "entityTick");
+ entityRemoval = Timings.ofSafe(name + "entityRemoval");
+ tileEntityTick = Timings.ofSafe(name + "tileEntityTick");
+ tileEntityPending = Timings.ofSafe(name + "tileEntityPending");
+
2020-04-26 06:05:41 +00:00
+ chunkLoad = Timings.ofSafe(name + "Chunk Load");
+ chunkLoadPopulate = Timings.ofSafe(name + "Chunk Load - Populate");
+ syncChunkLoad = Timings.ofSafe(name + "Sync Chunk Load");
+ chunkLoadLevelTimer = Timings.ofSafe(name + "Chunk Load - Load Level");
+ chunkIO = Timings.ofSafe(name + "Chunk Load - DiskIO");
+ chunkPostLoad = Timings.ofSafe(name + "Chunk Load - Post Load");
2016-10-21 20:42:49 +00:00
+ worldSave = Timings.ofSafe(name + "World Save");
+ worldSaveLevel = Timings.ofSafe(name + "World Save - Level");
+ worldSaveChunks = Timings.ofSafe(name + "World Save - Chunks");
+ chunkSaveData = Timings.ofSafe(name + "Chunk Save - Data");
2016-01-10 07:33:27 +00:00
+
2016-04-30 01:23:40 +00:00
+ tracker1 = Timings.ofSafe(name + "tracker stage 1");
+ tracker2 = Timings.ofSafe(name + "tracker stage 2");
2016-01-10 07:33:27 +00:00
+ doTick = Timings.ofSafe(name + "doTick");
+ tickEntities = Timings.ofSafe(name + "tickEntities");
2019-07-24 03:20:14 +00:00
+
+ chunks = Timings.ofSafe(name + "Chunks");
+ newEntities = Timings.ofSafe(name + "New entity registration");
+ raids = Timings.ofSafe(name + "Raids");
+ chunkProviderTick = Timings.ofSafe(name + "Chunk provider tick");
+ broadcastChunkUpdates = Timings.ofSafe(name + "Broadcast chunk updates");
+ countNaturalMobs = Timings.ofSafe(name + "Count natural mobs");
2019-09-29 21:06:03 +00:00
+
+
+ miscMobSpawning = Timings.ofSafe(name + "Mob spawning - Misc");
2016-01-10 07:33:27 +00:00
+ }
2018-07-15 01:53:17 +00:00
+
+ public static Timing getTickList(WorldServer worldserver, String timingsType) {
2020-06-26 12:04:38 +00:00
+ return Timings.ofSafe(((WorldDataServer) worldserver.getWorldData()).getName() + " - Scheduled " + timingsType);
2018-07-15 01:53:17 +00:00
+ }
2016-01-10 07:33:27 +00:00
+}
2016-02-29 23:09:49 +00:00
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
2021-01-02 04:59:30 +00:00
index da922f395f0fff0881ead893c900c5b2623f48f0..1d03a79e9010bc514b72a81ba0ad4a62aeff1bb7 100644
2016-02-29 23:09:49 +00:00
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
2020-06-26 06:29:44 +00:00
@@ -14,12 +14,15 @@ import java.util.concurrent.TimeUnit;
2016-02-29 23:09:49 +00:00
import java.util.logging.Level;
2016-05-02 03:54:08 +00:00
import java.util.regex.Pattern;
2016-02-29 23:09:49 +00:00
+import com.google.common.collect.Lists;
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
2020-06-26 06:29:44 +00:00
import org.bukkit.configuration.ConfigurationSection;
2016-02-29 23:09:49 +00:00
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
+import co.aikar.timings.Timings;
+import co.aikar.timings.TimingsManager;
public class PaperConfig {
2021-01-02 04:59:30 +00:00
@@ -188,4 +191,30 @@ public class PaperConfig {
2016-03-25 04:59:37 +00:00
config.addDefault(path, def);
return config.getString(path, config.getString(path));
2016-02-29 23:09:49 +00:00
}
+
2019-05-06 07:20:16 +00:00
+ public static String timingsServerName;
2016-02-29 23:09:49 +00:00
+ private static void timings() {
+ boolean timings = getBoolean("timings.enabled", true);
+ boolean verboseTimings = getBoolean("timings.verbose", true);
+ TimingsManager.privacy = getBoolean("timings.server-name-privacy", false);
2021-01-02 04:59:30 +00:00
+ TimingsManager.hiddenConfigs = getList("timings.hidden-config-entries", Lists.newArrayList("database", "settings.bungeecord-addresses", "settings.velocity-support.secret"));
+ if (!TimingsManager.hiddenConfigs.contains("settings.velocity-support.secret")) {
+ TimingsManager.hiddenConfigs.add("settings.velocity-support.secret");
+ }
2016-02-29 23:09:49 +00:00
+ int timingHistoryInterval = getInt("timings.history-interval", 300);
+ int timingHistoryLength = getInt("timings.history-length", 3600);
2019-05-06 07:20:16 +00:00
+ timingsServerName = getString("timings.server-name", "Unknown Server");
2016-02-29 23:09:49 +00:00
+
+
+ Timings.setVerboseTimingsEnabled(verboseTimings);
+ Timings.setTimingsEnabled(timings);
+ Timings.setHistoryInterval(timingHistoryInterval * 20);
+ Timings.setHistoryLength(timingHistoryLength * 20);
+
2017-03-25 03:18:58 +00:00
+ log("Timings: " + timings +
2016-02-29 23:09:49 +00:00
+ " - Verbose: " + verboseTimings +
+ " - Interval: " + timeSummary(Timings.getHistoryInterval() / 20) +
2019-05-06 07:20:16 +00:00
+ " - Length: " + timeSummary(Timings.getHistoryLength() / 20) +
+ " - Server Name: " + timingsServerName);
2016-02-29 23:09:49 +00:00
+ }
}
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
2020-08-25 02:22:08 +00:00
index 871b79cb2c63525c430c257f00b2cf70157aa476..d847326b0099a0c05a085d5d62de630491c9ac56 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
2020-08-25 02:22:08 +00:00
@@ -22,6 +22,15 @@ public class Block extends BlockBase implements IMaterial {
});
2020-06-25 09:27:25 +00:00
protected final BlockStateList<Block, IBlockData> blockStateList;
private IBlockData blockData;
2018-08-26 18:11:49 +00:00
+ // Paper start
2016-01-10 07:33:27 +00:00
+ public co.aikar.timings.Timing timing;
+ public co.aikar.timings.Timing getTiming() {
2016-01-09 06:32:38 +00:00
+ if (timing == null) {
2016-04-30 01:23:40 +00:00
+ timing = co.aikar.timings.MinecraftTimings.getBlockTiming(this);
2016-01-09 06:32:38 +00:00
+ }
+ return timing;
+ }
2016-02-29 23:09:49 +00:00
+ // Paper end
2020-06-25 09:27:25 +00:00
@Nullable
private String name;
@Nullable
2018-09-28 23:31:59 +00:00
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
2021-02-21 20:55:01 +00:00
index 853e11836b6c4eadd03feead101bf578b17b86a3..0aea16df16b55b1d4756b51d10c8c22d37aef9a3 100644
2018-09-28 23:31:59 +00:00
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
2021-02-21 20:55:01 +00:00
@@ -699,6 +699,7 @@ public class Chunk implements IChunkAccess {
2018-09-28 23:31:59 +00:00
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
if (this.needsDecoration) {
2020-04-26 06:05:41 +00:00
+ try (co.aikar.timings.Timing ignored = this.world.timings.chunkLoadPopulate.startTiming()) { // Paper
2019-05-26 01:56:30 +00:00
this.needsDecoration = false;
2018-09-28 23:31:59 +00:00
java.util.Random random = new java.util.Random();
random.setSeed(world.getSeed());
2021-02-21 20:55:01 +00:00
@@ -718,6 +719,7 @@ public class Chunk implements IChunkAccess {
2019-04-24 01:00:24 +00:00
}
2018-09-28 23:31:59 +00:00
}
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
2019-05-20 01:32:41 +00:00
+ } // Paper
2018-09-28 23:31:59 +00:00
}
}
2018-07-15 01:53:17 +00:00
}
2016-10-21 20:42:49 +00:00
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2021-02-21 20:55:01 +00:00
index 08f11f98c40221fa4ce9a4f14ee8398f8588f38a..a066026bce318683dcc022920dad39d7ec25e485 100644
2016-10-21 20:42:49 +00:00
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
2021-02-21 20:55:01 +00:00
@@ -322,11 +322,13 @@ public class ChunkProviderServer extends IChunkProvider {
2019-07-12 04:04:38 +00:00
}
2020-01-22 02:02:07 +00:00
gameprofilerfiller.c("getChunkCacheMiss");
2019-07-12 04:04:38 +00:00
- world.timings.syncChunkLoadTimer.startTiming(); // Spigot
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = this.getChunkFutureMainThread(i, j, chunkstatus, flag);
+ if (!completablefuture.isDone()) { // Paper
2020-04-26 06:05:41 +00:00
+ this.world.timings.syncChunkLoad.startTiming(); // Paper
2019-07-12 04:04:38 +00:00
this.serverThreadQueue.awaitTasks(completablefuture::isDone);
- world.timings.syncChunkLoadTimer.stopTiming(); // Spigot
2020-04-26 06:05:41 +00:00
+ this.world.timings.syncChunkLoad.stopTiming(); // Paper
2019-07-12 04:04:38 +00:00
+ } // Paper
ichunkaccess = (IChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> {
return ichunkaccess1;
}, (playerchunk_failure) -> {
2021-02-21 20:55:01 +00:00
@@ -513,7 +515,9 @@ public class ChunkProviderServer extends IChunkProvider {
2018-08-26 18:11:49 +00:00
2019-04-24 01:00:24 +00:00
public void save(boolean flag) {
2019-05-27 23:01:45 +00:00
this.tickDistanceManager();
2019-04-24 01:00:24 +00:00
+ try (co.aikar.timings.Timing timed = world.timings.chunkSaveData.startTiming()) { // Paper - Timings
this.playerChunkMap.save(flag);
+ } // Paper - Timings
}
@Override
2021-02-21 20:55:01 +00:00
@@ -550,7 +554,9 @@ public class ChunkProviderServer extends IChunkProvider {
2019-07-24 03:20:14 +00:00
this.tickDistanceManager();
this.world.timings.doChunkMap.stopTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("chunks");
+ this.world.timings.chunks.startTiming(); // Paper - timings
this.tickChunks();
+ this.world.timings.chunks.stopTiming(); // Paper - timings
this.world.timings.doChunkUnload.startTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("unload");
this.playerChunkMap.unloadChunks(booleansupplier);
2021-02-21 20:55:01 +00:00
@@ -574,8 +580,10 @@ public class ChunkProviderServer extends IChunkProvider {
2020-06-25 09:27:25 +00:00
boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit
2019-07-24 03:20:14 +00:00
this.world.getMethodProfiler().enter("naturalSpawnCount");
+ this.world.timings.countNaturalMobs.startTiming(); // Paper - timings
int l = this.chunkMapDistance.b();
2020-08-25 02:22:08 +00:00
SpawnerCreature.d spawnercreature_d = SpawnerCreature.a(l, this.world.A(), this::a);
2019-07-24 03:20:14 +00:00
+ this.world.timings.countNaturalMobs.stopTiming(); // Paper - timings
2020-06-25 09:27:25 +00:00
this.p = spawnercreature_d;
2019-07-24 03:20:14 +00:00
this.world.getMethodProfiler().exit();
2021-02-21 20:55:01 +00:00
@@ -586,7 +594,9 @@ public class ChunkProviderServer extends IChunkProvider {
2019-07-24 03:20:14 +00:00
2020-06-25 09:27:25 +00:00
if (optional.isPresent()) {
2019-07-24 03:20:14 +00:00
this.world.getMethodProfiler().enter("broadcast");
+ this.world.timings.broadcastChunkUpdates.startTiming(); // Paper - timings
2020-06-25 09:27:25 +00:00
playerchunk.a((Chunk) optional.get());
2019-07-24 03:20:14 +00:00
+ this.world.timings.broadcastChunkUpdates.stopTiming(); // Paper - timings
this.world.getMethodProfiler().exit();
2020-06-25 09:27:25 +00:00
Optional<Chunk> optional1 = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
2021-02-21 20:55:01 +00:00
@@ -600,25 +610,25 @@ public class ChunkProviderServer extends IChunkProvider {
2020-06-25 09:27:25 +00:00
SpawnerCreature.a(this.world, chunk, spawnercreature_d, this.allowAnimals, this.allowMonsters, flag2);
}
2019-05-14 02:20:58 +00:00
2020-06-25 09:27:25 +00:00
- this.world.timings.doTickTiles.startTiming(); // Spigot
+ this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
this.world.a(chunk, k);
- this.world.timings.doTickTiles.stopTiming(); // Spigot
+ this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
}
2019-04-24 01:00:24 +00:00
}
}
2019-06-25 01:47:58 +00:00
});
2019-09-29 21:06:03 +00:00
this.world.getMethodProfiler().enter("customSpawners");
if (flag1) {
+ try (co.aikar.timings.Timing ignored = this.world.timings.miscMobSpawning.startTiming()) { // Paper - timings
2020-06-25 09:27:25 +00:00
this.world.doMobSpawning(this.allowMonsters, this.allowAnimals);
2019-09-29 21:06:03 +00:00
+ } // Paper - timings
}
this.world.getMethodProfiler().exit();
2019-05-14 02:20:58 +00:00
this.world.getMethodProfiler().exit();
2018-07-22 05:27:46 +00:00
}
2019-04-24 01:00:24 +00:00
- this.world.timings.tracker.startTiming(); // Spigot
this.playerChunkMap.g();
- this.world.timings.tracker.stopTiming(); // Spigot
2016-10-21 20:42:49 +00:00
}
2020-06-25 09:27:25 +00:00
private void a(long i, Consumer<Chunk> consumer) {
2016-08-28 00:36:26 +00:00
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2020-11-03 02:22:15 +00:00
index bd47979e11d900b5b31c995751dfefbf0a2706b9..d30c4d5a4ee83e21ba9269c0b92af2b72b85d3cc 100644
2016-08-28 00:36:26 +00:00
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
2018-07-15 01:53:17 +00:00
@@ -1,5 +1,6 @@
package net.minecraft.server;
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
+import co.aikar.timings.Timings;
import com.google.common.collect.Maps;
2019-04-24 01:00:24 +00:00
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
2020-10-17 10:39:45 +00:00
@@ -404,7 +405,6 @@ public class ChunkRegionLoader {
2019-04-24 01:00:24 +00:00
private static void loadEntities(NBTTagCompound nbttagcompound, Chunk chunk) {
2018-07-15 01:53:17 +00:00
NBTTagList nbttaglist = nbttagcompound.getList("Entities", 10);
World world = chunk.getWorld();
2016-08-28 00:36:26 +00:00
- world.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
for (int i = 0; i < nbttaglist.size(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(i);
2020-10-17 10:39:45 +00:00
@@ -416,8 +416,6 @@ public class ChunkRegionLoader {
2019-04-24 01:00:24 +00:00
chunk.d(true);
2016-08-28 00:36:26 +00:00
}
2018-07-15 01:53:17 +00:00
2016-08-28 00:36:26 +00:00
- world.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot
- world.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
NBTTagList nbttaglist1 = nbttagcompound.getList("TileEntities", 10);
2016-08-28 00:36:26 +00:00
2018-07-15 01:53:17 +00:00
for (int j = 0; j < nbttaglist1.size(); ++j) {
2020-10-17 10:39:45 +00:00
@@ -435,8 +433,6 @@ public class ChunkRegionLoader {
2018-07-15 01:53:17 +00:00
}
2016-08-28 00:36:26 +00:00
}
}
- world.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot
2020-04-26 06:05:41 +00:00
-
2016-08-28 00:36:26 +00:00
}
2018-07-15 01:53:17 +00:00
2020-06-25 09:27:25 +00:00
private static NBTTagCompound a(ChunkCoordIntPair chunkcoordintpair, Map<StructureGenerator<?>, StructureStart<?>> map, Map<StructureGenerator<?>, LongSet> map1) {
2018-08-27 22:30:58 +00:00
diff --git a/src/main/java/net/minecraft/server/CustomFunction.java b/src/main/java/net/minecraft/server/CustomFunction.java
2020-08-02 05:39:36 +00:00
index 6d628c759346701c4097f36c302d1a1ab258bf9c..67e1b153a6f2ff9547dd03fcf4abcbea851e69f9 100644
2018-08-27 22:30:58 +00:00
--- a/src/main/java/net/minecraft/server/CustomFunction.java
+++ b/src/main/java/net/minecraft/server/CustomFunction.java
2019-04-24 01:00:24 +00:00
@@ -13,12 +13,22 @@ public class CustomFunction {
2018-08-27 22:30:58 +00:00
private final CustomFunction.c[] a;
private final MinecraftKey b;
+ // Paper start
+ public co.aikar.timings.Timing timing;
+ public co.aikar.timings.Timing getTiming() {
+ if (timing == null) {
+ timing = co.aikar.timings.MinecraftTimings.getCommandFunctionTiming(this);
+ }
+ return timing;
+ }
+ // Paper end
public CustomFunction(MinecraftKey minecraftkey, CustomFunction.c[] acustomfunction_c) {
this.b = minecraftkey;
this.a = acustomfunction_c;
}
2020-08-02 05:39:36 +00:00
+ public final MinecraftKey getMinecraftKey() { return this.a(); } // Paper - OBFHELPER
2018-08-27 22:30:58 +00:00
public MinecraftKey a() {
return this.b;
}
diff --git a/src/main/java/net/minecraft/server/CustomFunctionData.java b/src/main/java/net/minecraft/server/CustomFunctionData.java
2020-08-25 02:22:08 +00:00
index 11891990d90b789192d9081787c1e844646121ae..2a48d85f0490991eb323ef550cb6148d6387acaf 100644
2018-08-27 22:30:58 +00:00
--- a/src/main/java/net/minecraft/server/CustomFunctionData.java
+++ b/src/main/java/net/minecraft/server/CustomFunctionData.java
2020-06-25 09:27:25 +00:00
@@ -69,7 +69,7 @@ public class CustomFunctionData {
2018-08-27 22:30:58 +00:00
} else {
2020-01-22 02:02:07 +00:00
int j;
2018-08-27 22:30:58 +00:00
- try {
+ try (co.aikar.timings.Timing timing = customfunction.getTiming().startTiming()) { // Paper
2020-06-25 09:27:25 +00:00
this.d = true;
2020-01-22 02:02:07 +00:00
int k = 0;
2018-08-27 22:30:58 +00:00
CustomFunction.c[] acustomfunction_c = customfunction.b();
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
2020-11-03 02:22:15 +00:00
index d91b029c95b6380300db81e7c0fb172ff57958a1..218071260dec39dd4f7eb733ae6f832aacd6fd6f 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
2020-09-12 19:57:21 +00:00
@@ -26,8 +26,9 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.io.IoBuilder;
2018-07-15 01:53:17 +00:00
import org.bukkit.command.CommandSender;
2016-01-09 06:32:38 +00:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 06:32:38 +00:00
import org.bukkit.event.server.ServerCommandEvent;
2020-09-12 19:57:21 +00:00
+import org.bukkit.craftbukkit.util.Waitable;
2016-01-09 06:32:38 +00:00
import org.bukkit.event.server.RemoteServerCommandEvent;
2020-09-12 19:57:21 +00:00
// CraftBukkit end
2020-11-03 02:22:15 +00:00
@@ -382,7 +383,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2016-04-30 01:23:40 +00:00
}
2018-12-17 05:18:06 +00:00
public void handleCommandQueue() {
2016-04-30 01:23:40 +00:00
- SpigotTimings.serverCommandTimer.startTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
2020-11-03 02:22:15 +00:00
@@ -397,7 +398,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2016-04-30 01:23:40 +00:00
// CraftBukkit end
}
- SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
+ MinecraftTimings.serverCommandTimer.stopTiming(); // Spigot
}
2019-04-24 01:00:24 +00:00
@Override
2020-11-03 02:22:15 +00:00
@@ -633,6 +634,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2019-06-25 01:47:58 +00:00
@Override
public String executeRemoteCommand(String s) {
+ Waitable[] waitableArray = new Waitable[1];
this.remoteControlCommandListener.clearMessages();
this.executeSync(() -> {
// CraftBukkit start - fire RemoteServerCommandEvent
2020-11-03 02:22:15 +00:00
@@ -641,10 +643,39 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2019-06-25 01:47:58 +00:00
if (event.isCancelled()) {
return;
2017-02-05 03:47:39 +00:00
}
2019-06-25 01:47:58 +00:00
+ // Paper start
+ if (s.toLowerCase().startsWith("timings") && s.toLowerCase().matches("timings (report|paste|get|merged|seperate)")) {
+ org.bukkit.command.BufferedCommandSender sender = new org.bukkit.command.BufferedCommandSender();
+ Waitable<String> waitable = new Waitable<String>() {
+ @Override
+ protected String evaluate() {
+ return sender.getBuffer();
+ }
+ };
+ waitableArray[0] = waitable;
+ co.aikar.timings.Timings.generateReport(new co.aikar.timings.TimingsReportListener(sender, waitable));
+ } else {
+ // Paper end
2019-07-20 04:01:24 +00:00
ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener.getWrapper());
2019-06-25 01:47:58 +00:00
server.dispatchServerCommand(remoteConsole, serverCommand);
+ } // Paper
// CraftBukkit end
});
2017-02-05 03:47:39 +00:00
+ // Paper start
2019-06-25 01:47:58 +00:00
+ if (waitableArray[0] != null) {
+ //noinspection unchecked
+ Waitable<String> waitable = waitableArray[0];
+ try {
+ return waitable.get();
+ } catch (java.util.concurrent.ExecutionException e) {
+ throw new RuntimeException("Exception processing rcon command " + s, e.getCause());
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt(); // Maintain interrupted state
+ throw new RuntimeException("Interrupted processing rcon command " + s, e);
+ }
+
2017-02-05 03:47:39 +00:00
+ }
+ // Paper end
2019-06-25 01:47:58 +00:00
return this.remoteControlCommandListener.getMessages();
}
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
2021-02-21 20:55:01 +00:00
index b35ffae9f88cc14aec01482c2a3ed2e2428c2012..03933c24ed4d97e16bcebf6b89b1a8d1fc43cd0b 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2020-09-10 22:02:39 +00:00
@@ -31,7 +31,6 @@ import org.bukkit.craftbukkit.event.CraftPortalEvent;
2016-02-29 23:09:49 +00:00
import org.bukkit.entity.Hanging;
2016-01-09 06:32:38 +00:00
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Vehicle;
-import org.spigotmc.CustomTimingsHandler; // Spigot
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
2016-02-29 23:09:49 +00:00
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
2020-09-19 11:29:53 +00:00
@@ -163,7 +162,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2017-11-08 16:13:57 +00:00
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
public boolean forceExplosionKnockback; // SPIGOT-949
2020-09-19 11:29:53 +00:00
public boolean persistentInvisibility = false;
2016-01-09 06:32:38 +00:00
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
2016-02-29 23:09:49 +00:00
// Spigot start
2019-05-30 23:54:25 +00:00
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
2016-01-09 06:32:38 +00:00
public final boolean defaultActivationState;
2020-09-19 11:29:53 +00:00
@@ -532,7 +530,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2016-02-29 23:09:49 +00:00
}
2016-01-09 06:32:38 +00:00
2019-04-24 01:00:24 +00:00
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
2016-01-09 06:32:38 +00:00
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
if (this.noclip) {
2020-06-25 09:27:25 +00:00
this.a(this.getBoundingBox().c(vec3d));
2016-02-29 23:09:49 +00:00
this.recalcPosition();
2020-09-19 11:29:53 +00:00
@@ -668,7 +665,6 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2016-01-09 06:32:38 +00:00
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
2016-01-09 06:32:38 +00:00
}
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
2020-11-03 02:22:15 +00:00
protected BlockPosition ap() {
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2021-01-28 23:32:05 +00:00
index 8ad1256bcde950bc34aeb7f61ef9598f3b1cd2a3..d41638b97188ba58d2456d2f6c3c71fc79fe572a 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2020-09-02 09:12:25 +00:00
@@ -42,7 +42,7 @@ import org.bukkit.event.entity.EntityTeleportEvent;
2016-02-29 23:09:49 +00:00
import org.bukkit.event.player.PlayerItemConsumeEvent;
2016-01-09 06:32:38 +00:00
// CraftBukkit end
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 06:32:38 +00:00
public abstract class EntityLiving extends Entity {
2021-01-28 23:32:05 +00:00
@@ -2365,7 +2365,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 06:32:38 +00:00
2019-04-24 01:00:24 +00:00
@Override
2018-07-15 01:53:17 +00:00
public void tick() {
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
super.tick();
2020-08-25 02:22:08 +00:00
this.t();
this.v();
2021-01-28 23:32:05 +00:00
@@ -2414,9 +2413,7 @@ public abstract class EntityLiving extends Entity {
2016-01-09 06:32:38 +00:00
}
}
- SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
2018-12-17 05:18:06 +00:00
this.movementTick();
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
2019-12-11 00:56:03 +00:00
double d0 = this.locX() - this.lastX;
double d1 = this.locZ() - this.lastZ;
2016-01-09 06:32:38 +00:00
float f = (float) (d0 * d0 + d1 * d1);
2021-01-28 23:32:05 +00:00
@@ -2496,8 +2493,6 @@ public abstract class EntityLiving extends Entity {
2019-04-24 01:00:24 +00:00
if (this.isSleeping()) {
this.pitch = 0.0F;
2016-02-29 23:09:49 +00:00
}
-
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
2021-01-27 04:22:32 +00:00
public void updateEquipment() { // PAIL private->public; updateEquipment
2021-01-28 23:32:05 +00:00
@@ -2679,7 +2674,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 06:32:38 +00:00
2019-04-24 01:00:24 +00:00
this.setMot(d4, d5, d6);
this.world.getMethodProfiler().enter("ai");
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityAI.startTiming(); // Spigot
2016-11-17 02:23:38 +00:00
if (this.isFrozen()) {
2019-04-24 01:00:24 +00:00
this.jumping = false;
2020-08-25 02:22:08 +00:00
this.aR = 0.0F;
2021-01-28 23:32:05 +00:00
@@ -2689,7 +2683,6 @@ public abstract class EntityLiving extends Entity {
2016-01-09 06:32:38 +00:00
this.doTick();
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
2016-01-09 06:32:38 +00:00
}
- SpigotTimings.timerEntityAI.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().enter("jump");
2021-01-28 23:32:05 +00:00
@@ -2724,9 +2717,9 @@ public abstract class EntityLiving extends Entity {
2020-08-25 02:22:08 +00:00
this.r();
2018-07-15 01:53:17 +00:00
AxisAlignedBB axisalignedbb = this.getBoundingBox();
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
2020-08-25 02:22:08 +00:00
+ // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper
this.g(new Vec3D((double) this.aR, (double) this.aS, (double) this.aT));
2016-01-09 06:32:38 +00:00
- SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
2020-08-25 02:22:08 +00:00
+ // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
this.world.getMethodProfiler().enter("push");
2020-08-25 02:22:08 +00:00
if (this.bf > 0) {
2021-01-28 23:32:05 +00:00
@@ -2734,9 +2727,7 @@ public abstract class EntityLiving extends Entity {
2018-07-15 01:53:17 +00:00
this.a(axisalignedbb, this.getBoundingBox());
}
2016-02-29 23:09:49 +00:00
- SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
this.collideNearby();
2016-02-29 23:09:49 +00:00
- SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
this.world.getMethodProfiler().exit();
2020-11-03 02:22:15 +00:00
if (!this.world.isClientSide && this.dO() && this.aG()) {
2020-06-25 09:27:25 +00:00
this.damageEntity(DamageSource.DROWN, 1.0F);
2020-09-10 22:02:39 +00:00
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
2020-11-18 03:45:18 +00:00
index 9946985407561596c6c364526d2fe7477771303a..b1fe488e41a2c9f77df091e1d14ed5c87a4358c8 100644
2020-09-10 22:02:39 +00:00
--- a/src/main/java/net/minecraft/server/EntityTypes.java
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
@@ -151,7 +151,9 @@ public class EntityTypes<T extends Entity> {
return IRegistry.ENTITY_TYPE.getOptional(MinecraftKey.a(s));
}
- public EntityTypes(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype, boolean flag, boolean flag1, boolean flag2, boolean flag3, ImmutableSet<Block> immutableset, EntitySize entitysize, int i, int j) {
+ public final String id;
+ public EntityTypes(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype, boolean flag, boolean flag1, boolean flag2, boolean flag3, ImmutableSet<Block> immutableset, EntitySize entitysize, int i, int j) { this(entitytypes_b, enumcreaturetype, flag, flag1, flag2, flag3, immutableset, entitysize, i, j, "custom"); } // Paper - old signature
+ public EntityTypes(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype, boolean flag, boolean flag1, boolean flag2, boolean flag3, ImmutableSet<Block> immutableset, EntitySize entitysize, int i, int j, String id) { // Paper - add id
this.bf = entitytypes_b;
this.bg = enumcreaturetype;
this.bl = flag3;
@@ -162,6 +164,14 @@ public class EntityTypes<T extends Entity> {
this.br = entitysize;
this.bm = i;
this.bn = j;
+
+ // Paper start - timings
+ this.id = id;
+ this.tickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "tick");
+ this.inactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "inactiveTick");
+ this.passengerTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerTick");
+ this.passengerInactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerInactiveTick");
+ // Paper end
}
@Nullable
2020-11-18 03:45:18 +00:00
@@ -382,6 +392,12 @@ public class EntityTypes<T extends Entity> {
2020-09-10 22:02:39 +00:00
return this.bn;
}
+ // Paper start - timings
+ public final co.aikar.timings.Timing tickTimer;
+ public final co.aikar.timings.Timing inactiveTickTimer;
+ public final co.aikar.timings.Timing passengerTickTimer;
+ public final co.aikar.timings.Timing passengerInactiveTickTimer;
+ // Paper end
public boolean isDeltaTracking() {
return this != EntityTypes.PLAYER && this != EntityTypes.LLAMA_SPIT && this != EntityTypes.WITHER && this != EntityTypes.BAT && this != EntityTypes.ITEM_FRAME && this != EntityTypes.LEASH_KNOT && this != EntityTypes.PAINTING && this != EntityTypes.END_CRYSTAL && this != EntityTypes.EVOKER_FANGS;
}
2020-11-18 03:45:18 +00:00
@@ -469,7 +485,7 @@ public class EntityTypes<T extends Entity> {
2020-09-10 22:02:39 +00:00
SystemUtils.a(DataConverterTypes.ENTITY_TREE, s);
}
- return new EntityTypes<>(this.a, this.b, this.d, this.e, this.f, this.g, this.c, this.j, this.h, this.i);
+ return new EntityTypes<>(this.a, this.b, this.d, this.e, this.f, this.g, this.c, this.j, this.h, this.i, s); // Paper - add id
}
}
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2021-01-27 04:22:32 +00:00
index 472803c2d9292379a36fca681c2ab92ffb01184f..89d3ff83f0e152e9747c554693af4145f0a7d07e 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2020-06-25 14:09:55 +00:00
@@ -65,7 +65,7 @@ import org.bukkit.craftbukkit.CraftServer;
2016-07-15 22:36:53 +00:00
import org.bukkit.craftbukkit.Main;
2018-09-08 03:49:37 +00:00
import org.bukkit.event.server.ServerLoadEvent;
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2016-02-29 23:09:49 +00:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2019-06-25 01:47:58 +00:00
import org.spigotmc.SlackActivityAccountant; // Spigot
2016-01-09 06:32:38 +00:00
2020-06-25 09:27:25 +00:00
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
2020-06-25 14:09:55 +00:00
@@ -119,8 +119,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2020-06-25 09:27:25 +00:00
private long T;
public final Thread serverThread;
private long nextTick;
- private long W;
- private boolean X;
2020-08-25 02:22:08 +00:00
+ private long W; final long getTickOversleepMaxTime() { return this.W; } // Paper - OBFHELPER
2020-06-25 09:27:25 +00:00
+ private boolean X; final boolean hasExecutedTask() { return this.X; } // Paper - OBFHELPER
2020-08-25 02:22:08 +00:00
private final ResourcePackRepository resourcePackRepository;
2020-06-25 09:27:25 +00:00
private final ScoreboardServer scoreboardServer;
2019-09-29 20:49:38 +00:00
@Nullable
2020-11-07 00:19:04 +00:00
@@ -711,6 +711,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-02-29 23:09:49 +00:00
}
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2016-02-29 23:09:49 +00:00
MinecraftServer.LOGGER.info("Stopping server");
2016-04-30 01:23:40 +00:00
+ MinecraftTimings.stopServer(); // Paper
2016-03-03 09:46:26 +00:00
// CraftBukkit start
if (this.server != null) {
this.server.disablePlugins();
2020-11-07 00:19:04 +00:00
@@ -908,9 +909,21 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.
Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.
This guarantees that your chunk will load with at most around 1ms delay.
Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...
Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.
Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.
This is now fixed.
Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.
Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".
This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.
It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.
We solve this by ensuring new additions do not enter the currently iterated queue.
Each depth level will have its own queue.
Fixes #3220
2020-04-26 03:47:29 +00:00
private boolean canSleepForTick() {
// CraftBukkit start
+ if (isOversleep) return canOversleep();// Paper - because of our changes, this logic is broken
2020-06-25 09:27:25 +00:00
return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick);
2019-09-29 20:49:38 +00:00
}
+ // Paper start
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.
Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.
This guarantees that your chunk will load with at most around 1ms delay.
Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...
Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.
Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.
This is now fixed.
Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.
Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".
This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.
It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.
We solve this by ensuring new additions do not enter the currently iterated queue.
Each depth level will have its own queue.
Fixes #3220
2020-04-26 03:47:29 +00:00
+ boolean isOversleep = false;
2019-09-29 20:49:38 +00:00
+ private boolean canOversleep() {
+ return this.hasExecutedTask() && SystemUtils.getMonotonicMillis() < this.getTickOversleepMaxTime();
+ }
+
+ private boolean canSleepForTickNoOversleep() {
+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < this.nextTick;
+ }
+ // Paper end
+
private void executeModerately() {
this.executeAll();
java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
2020-11-07 00:19:04 +00:00
@@ -918,9 +931,9 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-07-24 03:20:14 +00:00
// CraftBukkit end
protected void sleepForTick() {
- this.executeAll();
+ //this.executeAll(); // Paper - move this into the tick method for timings
this.awaitTasks(() -> {
2019-09-29 20:49:38 +00:00
- return !this.canSleepForTick();
+ return !this.canSleepForTickNoOversleep(); // Paper - move oversleep into full server tick
2019-07-24 03:20:14 +00:00
});
2019-09-29 20:49:38 +00:00
}
2020-11-07 00:19:04 +00:00
@@ -1003,10 +1016,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-04-24 01:00:24 +00:00
protected void exit() {}
2016-01-09 06:32:38 +00:00
2018-08-26 18:11:49 +00:00
protected void a(BooleanSupplier booleansupplier) {
2016-01-09 06:32:38 +00:00
- SpigotTimings.serverTickTimer.startTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
2020-04-16 01:48:07 +00:00
this.slackActivityAccountant.tickStarted(); // Spigot
long i = SystemUtils.getMonotonicNanos();
2019-09-29 20:49:38 +00:00
+ // Paper start - move oversleep into full server tick
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.
Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.
This guarantees that your chunk will load with at most around 1ms delay.
Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...
Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.
Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.
This is now fixed.
Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.
Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".
This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.
It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.
We solve this by ensuring new additions do not enter the currently iterated queue.
Each depth level will have its own queue.
Fixes #3220
2020-04-26 03:47:29 +00:00
+ isOversleep = true;MinecraftTimings.serverOversleep.startTiming();
2019-09-29 20:49:38 +00:00
+ this.awaitTasks(() -> {
+ return !this.canOversleep();
+ });
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.
Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.
This guarantees that your chunk will load with at most around 1ms delay.
Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...
Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.
Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.
This is now fixed.
Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.
Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".
This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.
It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.
We solve this by ensuring new additions do not enter the currently iterated queue.
Each depth level will have its own queue.
Fixes #3220
2020-04-26 03:47:29 +00:00
+ isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
2019-09-29 20:49:38 +00:00
+ // Paper end
2020-04-16 01:48:07 +00:00
+
++this.ticks;
this.b(booleansupplier);
2020-06-25 09:27:25 +00:00
if (i - this.T >= 5000000000L) {
2020-11-07 00:19:04 +00:00
@@ -1024,14 +1045,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-04-30 01:23:40 +00:00
}
if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
- SpigotTimings.worldSaveTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
MinecraftServer.LOGGER.debug("Autosave started");
2018-12-17 05:18:06 +00:00
this.methodProfiler.enter("save");
this.playerList.savePlayers();
2019-04-24 01:00:24 +00:00
this.saveChunks(true, false, false);
2018-12-17 05:18:06 +00:00
this.methodProfiler.exit();
2019-04-24 01:00:24 +00:00
MinecraftServer.LOGGER.debug("Autosave finished");
2016-04-30 01:23:40 +00:00
- SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
2018-12-17 05:18:06 +00:00
this.methodProfiler.enter("snooper");
2020-11-07 00:19:04 +00:00
@@ -1044,6 +1063,13 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2020-04-16 01:48:07 +00:00
}
2018-12-17 05:18:06 +00:00
this.methodProfiler.exit();
2020-04-16 01:48:07 +00:00
+
2019-07-24 03:20:14 +00:00
+ // Paper start - move executeAll() into full server tick timing
+ try (co.aikar.timings.Timing ignored = MinecraftTimings.processTasksTimer.startTiming()) {
+ this.executeAll();
+ }
+ // Paper end
2020-04-16 01:48:07 +00:00
+
this.methodProfiler.enter("tallying");
2020-06-25 09:27:25 +00:00
long l = this.h[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i;
2020-04-16 01:48:07 +00:00
2020-11-07 00:19:04 +00:00
@@ -1054,30 +1080,29 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2020-04-16 01:48:07 +00:00
this.methodProfiler.exit();
org.spigotmc.WatchdogThread.tick(); // Spigot
this.slackActivityAccountant.tickEnded(l); // Spigot
- SpigotTimings.serverTickTimer.stopTiming(); // Spigot
- org.spigotmc.CustomTimingsHandler.tick(); // Spigot
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
}
2019-04-24 01:00:24 +00:00
protected void b(BooleanSupplier booleansupplier) {
2016-06-30 05:38:53 +00:00
- SpigotTimings.schedulerTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.bukkitSchedulerTimer.startTiming(); // Spigot // Paper
2016-06-30 05:38:53 +00:00
this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
- SpigotTimings.schedulerTimer.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Spigot // Paper
this.methodProfiler.enter("commandFunctions");
2018-07-15 01:53:17 +00:00
- SpigotTimings.commandFunctionsTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.commandFunctionsTimer.startTiming(); // Spigot // Paper
2018-12-17 05:18:06 +00:00
this.getFunctionData().tick();
2018-07-15 01:53:17 +00:00
- SpigotTimings.commandFunctionsTimer.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.commandFunctionsTimer.stopTiming(); // Spigot // Paper
2018-12-17 05:18:06 +00:00
this.methodProfiler.exitEnter("levels");
2019-06-25 01:47:58 +00:00
Iterator iterator = this.getWorlds().iterator();
2016-02-24 04:35:34 +00:00
// CraftBukkit start
// Run tasks that are waiting on processing
2016-04-30 01:23:40 +00:00
- SpigotTimings.processQueueTimer.startTiming(); // Spigot
+ MinecraftTimings.processQueueTimer.startTiming(); // Spigot
while (!processQueue.isEmpty()) {
processQueue.remove().run();
}
- SpigotTimings.processQueueTimer.stopTiming(); // Spigot
+ MinecraftTimings.processQueueTimer.stopTiming(); // Spigot
- SpigotTimings.timeUpdateTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper
2016-04-30 01:23:40 +00:00
// Send time updates to everyone, it will get the right time from the world the player is in.
if (this.ticks % 20 == 0) {
for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
2020-11-07 00:19:04 +00:00
@@ -1085,7 +1110,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-06-25 01:47:58 +00:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); // Add support for per player time
2016-04-30 01:23:40 +00:00
}
}
- SpigotTimings.timeUpdateTimer.stopTiming(); // Spigot
2019-04-24 01:00:24 +00:00
+ MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper
2016-04-30 01:23:40 +00:00
2019-06-25 01:47:58 +00:00
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
2020-11-07 00:19:04 +00:00
@@ -1126,24 +1151,24 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2016-04-30 01:23:40 +00:00
}
2018-12-17 05:18:06 +00:00
this.methodProfiler.exitEnter("connection");
2016-04-30 01:23:40 +00:00
- SpigotTimings.connectionTimer.startTiming(); // Spigot
+ MinecraftTimings.connectionTimer.startTiming(); // Spigot
2018-07-15 01:53:17 +00:00
this.getServerConnection().c();
2016-04-30 01:23:40 +00:00
- SpigotTimings.connectionTimer.stopTiming(); // Spigot
+ MinecraftTimings.connectionTimer.stopTiming(); // Spigot
2018-12-17 05:18:06 +00:00
this.methodProfiler.exitEnter("players");
2016-04-30 01:23:40 +00:00
- SpigotTimings.playerListTimer.startTiming(); // Spigot
2019-06-25 01:47:58 +00:00
+ MinecraftTimings.playerListTimer.startTiming(); // Spigot // Paper
2018-12-17 05:18:06 +00:00
this.playerList.tick();
2016-04-30 01:23:40 +00:00
- SpigotTimings.playerListTimer.stopTiming(); // Spigot
2019-06-25 01:47:58 +00:00
+ MinecraftTimings.playerListTimer.stopTiming(); // Spigot // Paper
2020-06-25 09:27:25 +00:00
if (SharedConstants.d) {
2019-12-11 00:56:03 +00:00
GameTestHarnessTicker.a.b();
}
2019-04-24 01:00:24 +00:00
this.methodProfiler.exitEnter("server gui refresh");
2018-08-26 18:11:49 +00:00
2016-04-30 01:23:40 +00:00
- SpigotTimings.tickablesTimer.startTiming(); // Spigot
2019-06-25 01:47:58 +00:00
+ MinecraftTimings.tickablesTimer.startTiming(); // Spigot // Paper
for (int i = 0; i < this.tickables.size(); ++i) {
((Runnable) this.tickables.get(i)).run();
2016-04-30 01:23:40 +00:00
}
- SpigotTimings.tickablesTimer.stopTiming(); // Spigot
2019-06-25 01:47:58 +00:00
+ MinecraftTimings.tickablesTimer.stopTiming(); // Spigot // Paper
2016-04-30 01:23:40 +00:00
2018-12-17 05:18:06 +00:00
this.methodProfiler.exit();
2016-04-30 01:23:40 +00:00
}
2016-06-05 04:10:50 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
2020-08-25 02:22:08 +00:00
index 127c03c321e1414e0d174c8d81a7851c9da03574..d98b6ef44e1836920956754dfcb6654fec23b673 100644
2016-06-05 04:10:50 +00:00
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
2019-06-25 01:47:58 +00:00
@@ -1,7 +1,9 @@
2016-06-05 04:10:50 +00:00
package net.minecraft.server;
2019-06-25 01:47:58 +00:00
+import co.aikar.timings.Timing; // Paper
2019-04-24 01:00:24 +00:00
import com.google.common.collect.ImmutableList;
2019-06-25 01:47:58 +00:00
import com.google.common.collect.Iterables;
+import com.google.common.collect.ComparisonChain; // Paper
2018-07-15 01:53:17 +00:00
import com.google.common.collect.Lists;
2019-05-27 23:01:45 +00:00
import com.google.common.collect.Queues;
2019-04-24 01:00:24 +00:00
import com.google.common.collect.Sets;
2020-06-25 09:27:25 +00:00
@@ -508,11 +510,14 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2019-07-12 04:04:38 +00:00
private CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> f(ChunkCoordIntPair chunkcoordintpair) {
return CompletableFuture.supplyAsync(() -> {
- try {
2020-04-26 06:05:41 +00:00
+ try (Timing ignored = this.world.timings.chunkLoad.startTimingIfSync()) { // Paper
2020-01-22 02:02:07 +00:00
this.world.getMethodProfiler().c("chunkLoad");
- NBTTagCompound nbttagcompound = this.readChunkData(chunkcoordintpair);
2019-07-12 04:04:38 +00:00
+ NBTTagCompound nbttagcompound; // Paper
2020-04-26 06:05:41 +00:00
+ try (Timing ignored2 = this.world.timings.chunkIO.startTimingIfSync()) { // Paper start - timings
2020-01-22 02:02:07 +00:00
+ nbttagcompound = this.readChunkData(chunkcoordintpair);
+ } // Paper end
2019-07-12 04:04:38 +00:00
2020-04-26 06:05:41 +00:00
- if (nbttagcompound != null) {
+ if (nbttagcompound != null) {try (Timing ignored2 = this.world.timings.chunkLoadLevelTimer.startTimingIfSync()) { // Paper start - timings
2019-07-12 04:04:38 +00:00
boolean flag = nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8);
2020-04-26 06:05:41 +00:00
if (flag) {
2020-06-25 09:27:25 +00:00
@@ -524,7 +529,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2020-04-26 06:05:41 +00:00
}
PlayerChunkMap.LOGGER.error("Chunk file at {} is missing level data, skipping", chunkcoordintpair);
- }
+ }} // Paper
} catch (ReportedException reportedexception) {
Throwable throwable = reportedexception.getCause();
2020-06-25 09:27:25 +00:00
@@ -561,7 +566,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2020-01-22 02:02:07 +00:00
return "chunkGenerate " + chunkstatus.d();
2019-05-27 23:01:45 +00:00
});
return completablefuture.thenComposeAsync((either) -> {
- return (CompletableFuture) either.map((list) -> {
+ return either.map((list) -> { // Paper - Shut up.
try {
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture1 = chunkstatus.a(this.world, this.chunkGenerator, this.definedStructureManager, this.lightEngine, (ichunkaccess) -> {
return this.c(playerchunk);
2020-06-25 09:27:25 +00:00
@@ -614,6 +619,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2019-07-12 04:04:38 +00:00
ChunkStatus chunkstatus = PlayerChunk.getChunkStatus(playerchunk.getTicketLevel());
return !chunkstatus.b(ChunkStatus.FULL) ? PlayerChunk.UNLOADED_CHUNK_ACCESS : either.mapLeft((ichunkaccess) -> {
2020-04-26 06:05:41 +00:00
+ try (Timing ignored = world.timings.chunkPostLoad.startTimingIfSync()) { // Paper
2019-07-12 04:04:38 +00:00
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
Chunk chunk;
2020-06-25 09:27:25 +00:00
@@ -665,6 +671,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2019-07-12 04:04:38 +00:00
}
return chunk;
+ } // Paper
});
}, (runnable) -> {
Mailbox mailbox = this.mailboxMain;
2020-06-25 09:27:25 +00:00
@@ -1123,6 +1130,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2016-06-05 04:10:50 +00:00
2019-04-24 01:00:24 +00:00
PlayerChunkMap.EntityTracker playerchunkmap_entitytracker;
ObjectIterator objectiterator;
+ world.timings.tracker1.startTiming(); // Paper
2016-06-05 04:10:50 +00:00
2019-04-24 01:00:24 +00:00
for (objectiterator = this.trackedEntities.values().iterator(); objectiterator.hasNext(); playerchunkmap_entitytracker.trackerEntry.a()) {
playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next();
2020-06-25 09:27:25 +00:00
@@ -1140,16 +1148,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
2019-04-24 01:00:24 +00:00
playerchunkmap_entitytracker.e = sectionposition1;
2016-06-05 04:10:50 +00:00
}
}
2019-04-24 01:00:24 +00:00
+ world.timings.tracker1.stopTiming(); // Paper
2016-06-05 04:10:50 +00:00
2019-12-11 00:56:03 +00:00
if (!list.isEmpty()) {
objectiterator = this.trackedEntities.values().iterator();
2016-06-05 04:10:50 +00:00
2019-12-11 00:56:03 +00:00
+ world.timings.tracker2.startTiming(); // Paper
while (objectiterator.hasNext()) {
playerchunkmap_entitytracker = (PlayerChunkMap.EntityTracker) objectiterator.next();
playerchunkmap_entitytracker.track(list);
}
+ world.timings.tracker2.stopTiming(); // Paper
2019-05-06 20:45:02 +00:00
}
2019-12-11 00:56:03 +00:00
+
2019-05-06 20:45:02 +00:00
}
2019-12-11 00:56:03 +00:00
protected void broadcast(Entity entity, Packet<?> packet) {
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
2020-11-04 08:57:07 +00:00
index b37b791cd66b2e88dd0ecf52beea1844c97cdb94..d34e91887cd73009bf852fb849e495a8affed7a9 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2020-11-03 02:22:15 +00:00
@@ -64,6 +64,7 @@ import org.bukkit.inventory.CraftingInventory;
2016-03-04 21:20:13 +00:00
import org.bukkit.inventory.EquipmentSlot;
2016-01-09 06:32:38 +00:00
import org.bukkit.inventory.InventoryView;
import org.bukkit.util.NumberConversions;
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2019-04-24 01:00:24 +00:00
public class PlayerConnection implements PacketListenerPlayIn {
2020-11-03 02:22:15 +00:00
@@ -146,7 +147,6 @@ public class PlayerConnection implements PacketListenerPlayIn {
2018-10-28 22:08:08 +00:00
// CraftBukkit end
2018-12-17 05:18:06 +00:00
public void tick() {
2018-10-28 22:08:08 +00:00
- org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.startTiming(); // Spigot
this.syncPosition();
2019-12-11 00:56:03 +00:00
this.player.lastX = this.player.locX();
this.player.lastY = this.player.locY();
2020-11-03 02:22:15 +00:00
@@ -222,7 +222,6 @@ public class PlayerConnection implements PacketListenerPlayIn {
2018-10-28 22:08:08 +00:00
this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854
2020-06-25 09:27:25 +00:00
this.disconnect(new ChatMessage("multiplayer.disconnect.idling"));
2018-10-28 22:08:08 +00:00
}
- org.bukkit.craftbukkit.SpigotTimings.playerConnectionTimer.stopTiming(); // Spigot
}
2020-11-04 08:57:07 +00:00
@@ -1769,7 +1768,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2017-05-14 18:05:01 +00:00
private void handleCommand(String s) {
2016-01-09 06:32:38 +00:00
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
2017-05-14 18:05:01 +00:00
+ MinecraftTimings.playerCommandTimer.startTiming(); // Paper
2018-07-15 01:53:17 +00:00
// CraftBukkit start - whole method
2016-01-09 06:32:38 +00:00
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
2016-02-29 23:09:49 +00:00
this.LOGGER.info(this.player.getName() + " issued server command: " + s);
2020-11-04 08:57:07 +00:00
@@ -1780,7 +1779,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2016-01-09 06:32:38 +00:00
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2016-04-30 01:23:40 +00:00
+ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
return;
}
2020-11-04 08:57:07 +00:00
@@ -1793,7 +1792,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2016-01-09 06:32:38 +00:00
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
2018-07-15 01:53:17 +00:00
return;
} finally {
2016-01-09 06:32:38 +00:00
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
2016-04-30 01:23:40 +00:00
+ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper
2016-01-09 06:32:38 +00:00
}
2018-07-15 01:53:17 +00:00
// this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s);
2016-01-09 06:32:38 +00:00
// CraftBukkit end
2017-02-05 05:13:16 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
2021-02-21 20:55:01 +00:00
index 8c534c2f06fe72287364536b8767bd774b94c027..9c810b5aa21ca714ccf355d5648b7612f99b6884 100644
2017-02-05 05:13:16 +00:00
--- a/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
+++ b/src/main/java/net/minecraft/server/PlayerConnectionUtils.java
2019-07-20 04:01:24 +00:00
@@ -2,6 +2,8 @@ package net.minecraft.server;
2017-02-05 05:13:16 +00:00
2019-07-20 04:01:24 +00:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
2017-02-05 05:13:16 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
+import co.aikar.timings.Timing; // Paper
2019-07-20 04:01:24 +00:00
2017-02-05 05:13:16 +00:00
public class PlayerConnectionUtils {
2019-01-01 03:15:55 +00:00
2019-07-20 04:01:24 +00:00
@@ -13,10 +15,13 @@ public class PlayerConnectionUtils {
2019-04-24 01:00:24 +00:00
public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
2017-02-05 05:13:16 +00:00
if (!iasynctaskhandler.isMainThread()) {
2019-07-20 04:01:24 +00:00
+ Timing timing = MinecraftTimings.getPacketTiming(packet); // Paper - timings
2019-04-24 01:00:24 +00:00
iasynctaskhandler.execute(() -> {
2019-05-06 02:58:04 +00:00
if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
2019-07-20 04:01:24 +00:00
if (t0.a().isConnected()) {
+ try (Timing ignored = timing.startTiming()) { // Paper - timings
packet.a(t0);
+ } // Paper - timings
} else {
PlayerConnectionUtils.LOGGER.debug("Ignoring packet due to disconnection: " + packet);
}
2016-10-21 20:42:49 +00:00
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
2020-11-18 03:45:18 +00:00
index 8206523e78176f485605c35d5ff9ae63ab363a65..5b49047b820dbe1f326320b71445ac216bf688b5 100644
2016-10-21 20:42:49 +00:00
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -1,5 +1,6 @@
package net.minecraft.server;
+import co.aikar.timings.MinecraftTimings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
2020-10-01 13:16:32 +00:00
@@ -955,10 +956,11 @@ public abstract class PlayerList {
2016-10-21 20:42:49 +00:00
}
public void savePlayers() {
+ MinecraftTimings.savePlayers.startTiming(); // Paper
for (int i = 0; i < this.players.size(); ++i) {
this.savePlayerFile((EntityPlayer) this.players.get(i));
}
-
+ MinecraftTimings.savePlayers.stopTiming(); // Paper
}
2018-07-15 01:53:17 +00:00
public WhiteList getWhitelist() {
diff --git a/src/main/java/net/minecraft/server/TickListServer.java b/src/main/java/net/minecraft/server/TickListServer.java
2020-06-25 09:27:25 +00:00
index e8ff43662b8397229cb19ea26342b66c88807379..3b8f56c0f0507ebdd9ac20be70688b4c0cfe4cf8 100644
2018-07-15 01:53:17 +00:00
--- a/src/main/java/net/minecraft/server/TickListServer.java
+++ b/src/main/java/net/minecraft/server/TickListServer.java
2020-06-25 09:27:25 +00:00
@@ -26,12 +26,17 @@ public class TickListServer<T> implements TickList<T> {
private final List<NextTickListEntry<T>> g = Lists.newArrayList();
private final Consumer<NextTickListEntry<T>> h;
2018-07-15 01:53:17 +00:00
2020-06-25 09:27:25 +00:00
- public TickListServer(WorldServer worldserver, Predicate<T> predicate, Function<T, MinecraftKey> function, Consumer<NextTickListEntry<T>> consumer) {
+ public TickListServer(WorldServer worldserver, Predicate<T> predicate, Function<T, MinecraftKey> function, Consumer<NextTickListEntry<T>> consumer, String timingsType) { // Paper
2018-07-15 01:53:17 +00:00
this.a = predicate;
this.b = function;
2020-06-25 09:27:25 +00:00
this.e = worldserver;
this.h = consumer;
2019-05-27 23:01:45 +00:00
+ this.timingCleanup = co.aikar.timings.WorldTimingsHandler.getTickList(worldserver, timingsType + " - Cleanup");
+ this.timingTicking = co.aikar.timings.WorldTimingsHandler.getTickList(worldserver, timingsType + " - Ticking");
2018-07-15 01:53:17 +00:00
}
+ private final co.aikar.timings.Timing timingCleanup; // Paper
+ private final co.aikar.timings.Timing timingTicking; // Paper
+ // Paper end
2016-08-28 00:36:26 +00:00
2019-07-20 04:01:24 +00:00
public void b() {
2019-05-27 23:01:45 +00:00
int i = this.nextTickList.size();
2020-06-25 09:27:25 +00:00
@@ -54,6 +59,7 @@ public class TickListServer<T> implements TickList<T> {
2016-08-28 00:36:26 +00:00
2020-06-25 09:27:25 +00:00
this.e.getMethodProfiler().enter("cleaning");
2019-05-27 23:01:45 +00:00
+ this.timingCleanup.startTiming(); // Paper
2019-05-14 02:20:58 +00:00
NextTickListEntry nextticklistentry;
2016-08-28 00:36:26 +00:00
2019-05-27 23:01:45 +00:00
while (i > 0 && iterator.hasNext()) {
2020-06-25 09:27:25 +00:00
@@ -69,7 +75,9 @@ public class TickListServer<T> implements TickList<T> {
2019-05-14 02:20:58 +00:00
--i;
}
2018-07-15 01:53:17 +00:00
}
2019-05-27 23:01:45 +00:00
+ this.timingCleanup.stopTiming(); // Paper
+ this.timingTicking.startTiming(); // Paper
2020-06-25 09:27:25 +00:00
this.e.getMethodProfiler().exitEnter("ticking");
2016-08-28 00:36:26 +00:00
2020-06-25 09:27:25 +00:00
while ((nextticklistentry = (NextTickListEntry) this.f.poll()) != null) {
@@ -89,6 +97,7 @@ public class TickListServer<T> implements TickList<T> {
}
2019-05-27 23:01:45 +00:00
}
2016-08-28 00:36:26 +00:00
2019-05-27 23:01:45 +00:00
+ this.timingTicking.stopTiming(); // Paper
2020-06-25 09:27:25 +00:00
this.e.getMethodProfiler().exit();
2018-07-15 01:53:17 +00:00
this.g.clear();
2020-06-25 09:27:25 +00:00
this.f.clear();
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
2020-11-03 02:22:15 +00:00
index b9ffd000c97111678d45fd55dc9c207ebadc140e..f1d0e2faffb3ef27f5a41d06d0ff7d787f1098f5 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
2019-05-14 02:20:58 +00:00
@@ -9,11 +9,12 @@ import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
2019-05-06 02:58:04 +00:00
import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
import org.bukkit.inventory.InventoryHolder;
// CraftBukkit end
2016-01-09 06:32:38 +00:00
-import org.spigotmc.CustomTimingsHandler; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-02-29 23:09:49 +00:00
+import co.aikar.timings.Timing; // Paper
2016-01-09 06:32:38 +00:00
2018-07-27 04:44:53 +00:00
public abstract class TileEntity implements KeyedObject { // Paper
2016-01-09 06:32:38 +00:00
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
2016-04-30 01:23:40 +00:00
+ public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper
2019-05-06 02:58:04 +00:00
// CraftBukkit start - data containers
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
2019-07-05 02:13:38 +00:00
public CraftPersistentDataContainer persistentDataContainer;
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2021-02-21 20:55:01 +00:00
index 6df28adb17d78a7f5189787a979a44fad677f05c..09577ddcb3c2432a0af6047b287a387de5d2920a 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2020-06-25 09:27:25 +00:00
@@ -18,7 +18,6 @@ import org.apache.logging.log4j.Logger;
2020-01-28 19:43:57 +00:00
import java.util.HashMap;
2016-02-29 23:09:49 +00:00
import java.util.Map;
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
2016-01-09 06:32:38 +00:00
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
2020-01-28 19:43:57 +00:00
import org.bukkit.craftbukkit.block.CapturedBlockState;
2020-06-26 16:20:03 +00:00
@@ -80,7 +79,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
2016-01-09 06:32:38 +00:00
2016-02-29 23:09:49 +00:00
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
2016-01-09 06:32:38 +00:00
- public final SpigotTimings.WorldTimingsHandler timings; // Spigot
2016-02-29 23:09:49 +00:00
+ public final co.aikar.timings.WorldTimingsHandler timings; // Paper
2019-02-03 15:34:04 +00:00
public static BlockPosition lastPhysicsProblem; // Spigot
private org.spigotmc.TickLimiter entityLimiter;
2019-04-24 01:00:24 +00:00
private org.spigotmc.TickLimiter tileLimiter;
2020-08-25 02:22:08 +00:00
@@ -165,7 +164,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
2019-04-24 01:00:24 +00:00
public void c(WorldBorder worldborder, double d0) {}
2016-03-25 04:59:37 +00:00
});
2016-03-03 09:46:26 +00:00
// CraftBukkit end
2016-02-29 23:09:49 +00:00
- timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
+ timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings
2019-04-24 01:00:24 +00:00
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
2016-01-09 06:32:38 +00:00
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
}
2021-02-21 20:55:01 +00:00
@@ -745,15 +744,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
2016-01-09 06:32:38 +00:00
}
timings.tileEntityPending.stopTiming(); // Spigot
2016-02-29 23:09:49 +00:00
+ co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityListTick.size(); // Paper
2019-04-24 01:00:24 +00:00
gameprofilerfiller.exit();
spigotConfig.currentPrimedTnt = 0; // Spigot
2016-01-09 06:32:38 +00:00
}
2018-04-22 14:40:36 +00:00
2019-04-24 01:00:24 +00:00
public void a(Consumer<Entity> consumer, Entity entity) {
try {
2019-05-14 02:20:58 +00:00
- SpigotTimings.tickEntityTimer.startTiming(); // Spigot
2019-04-24 01:00:24 +00:00
consumer.accept(entity);
2019-05-14 02:20:58 +00:00
- SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking entity");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being ticked");
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
2021-02-21 20:55:01 +00:00
index 592af06de1fc02d94273363c2ede1175a39997f0..3d915105b277a7cbf330ba2cb3c2f1451ee868e4 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
2020-08-25 02:22:08 +00:00
@@ -2,6 +2,8 @@ package net.minecraft.server;
2019-12-11 00:56:03 +00:00
import com.google.common.annotations.VisibleForTesting;
2020-06-25 09:27:25 +00:00
import com.google.common.collect.Iterables;
2019-12-11 00:56:03 +00:00
+import co.aikar.timings.TimingHistory; // Paper
+import co.aikar.timings.Timings; // Paper
2018-07-15 01:53:17 +00:00
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
2019-04-24 01:00:24 +00:00
import com.google.common.collect.Queues;
2020-11-03 02:22:15 +00:00
@@ -44,7 +46,6 @@ import org.apache.logging.log4j.Logger;
2019-10-18 16:31:01 +00:00
import java.util.logging.Level;
2019-05-14 02:20:58 +00:00
import org.bukkit.Bukkit;
2019-04-24 01:00:24 +00:00
import org.bukkit.WeatherType;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.craftbukkit.event.CraftEventFactory;
2020-06-25 09:27:25 +00:00
import org.bukkit.craftbukkit.util.WorldUUID;
2019-05-14 02:20:58 +00:00
import org.bukkit.event.entity.CreatureSpawnEvent;
2020-11-03 02:22:15 +00:00
@@ -100,10 +101,10 @@ public class WorldServer extends World implements GeneratorAccessSeed {
2019-01-01 03:15:55 +00:00
// CraftBukkit end
this.nextTickListBlock = new TickListServer<>(this, (block) -> {
return block == null || block.getBlockData().isAir();
2020-06-25 09:27:25 +00:00
- }, IRegistry.BLOCK::getKey, this::b);
+ }, IRegistry.BLOCK::getKey, this::b, "Blocks"); // Paper - Timings
2019-01-01 03:15:55 +00:00
this.nextTickListFluid = new TickListServer<>(this, (fluidtype) -> {
return fluidtype == null || fluidtype == FluidTypes.EMPTY;
2020-06-25 09:27:25 +00:00
- }, IRegistry.FLUID::getKey, this::a);
+ }, IRegistry.FLUID::getKey, this::a, "Fluids"); // Paper - Timings
2019-12-12 03:06:23 +00:00
this.navigators = Sets.newHashSet();
2020-06-25 09:27:25 +00:00
this.L = new ObjectLinkedOpenHashSet();
this.Q = flag1;
2020-11-03 02:22:15 +00:00
@@ -331,17 +332,21 @@ public class WorldServer extends World implements GeneratorAccessSeed {
this.Q();
2020-06-25 09:27:25 +00:00
this.b();
2019-05-06 07:20:16 +00:00
gameprofilerfiller.exitEnter("chunkSource");
2019-07-24 03:20:14 +00:00
+ this.timings.chunkProviderTick.startTiming(); // Paper - timings
2019-05-06 07:20:16 +00:00
this.getChunkProvider().tick(booleansupplier);
2019-07-24 03:20:14 +00:00
+ this.timings.chunkProviderTick.stopTiming(); // Paper - timings
2019-05-06 07:20:16 +00:00
gameprofilerfiller.exitEnter("tickPending");
- timings.doTickPending.startTiming(); // Spigot
2020-06-25 09:27:25 +00:00
+ timings.scheduledBlocks.startTiming(); // Paper
if (!this.isDebugWorld()) {
2019-07-20 04:01:24 +00:00
this.nextTickListBlock.b();
this.nextTickListFluid.b();
2019-05-06 07:20:16 +00:00
}
- timings.doTickPending.stopTiming(); // Spigot
2020-06-25 09:27:25 +00:00
+ timings.scheduledBlocks.stopTiming(); // Paper
2019-05-06 07:20:16 +00:00
2019-07-24 03:20:14 +00:00
gameprofilerfiller.exitEnter("raid");
+ this.timings.raids.startTiming(); // Paper - timings
2019-12-12 03:06:23 +00:00
this.persistentRaid.a();
2019-07-24 03:20:14 +00:00
+ this.timings.raids.stopTiming(); // Paper - timings
gameprofilerfiller.exitEnter("blockEvents");
timings.doSounds.startTiming(); // Spigot
2020-11-03 02:22:15 +00:00
this.ak();
@@ -513,6 +518,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
2019-04-24 01:00:24 +00:00
}
2016-01-09 06:32:38 +00:00
2019-04-24 01:00:24 +00:00
gameprofilerfiller.exitEnter("tickBlocks");
+ timings.chunkTicksBlocks.startTiming(); // Paper
if (i > 0) {
ChunkSection[] achunksection = chunk.getSections();
int l = achunksection.length;
2020-11-03 02:22:15 +00:00
@@ -544,7 +550,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
2016-01-09 06:32:38 +00:00
}
}
2019-04-24 01:00:24 +00:00
}
-
+ timings.chunkTicksBlocks.stopTiming(); // Paper
gameprofilerfiller.exit();
}
2016-01-09 06:32:38 +00:00
2020-11-03 02:22:15 +00:00
@@ -642,14 +648,22 @@ public class WorldServer extends World implements GeneratorAccessSeed {
2020-06-25 09:27:25 +00:00
if (!(entity instanceof EntityHuman) && !this.getChunkProvider().a(entity)) {
this.chunkCheck(entity);
} else {
2020-03-19 06:03:32 +00:00
+ ++TimingHistory.entityTicks; // Paper - timings
// Spigot start
2020-09-10 22:02:39 +00:00
+ co.aikar.timings.Timing timer; // Paper
2020-03-19 06:03:32 +00:00
if (!org.spigotmc.ActivationRange.checkIfActive(entity)) {
entity.ticksLived++;
2020-09-10 22:02:39 +00:00
+ timer = entity.getEntityType().inactiveTickTimer.startTiming(); try { // Paper - timings
entity.inactiveTick();
+ } finally { timer.stopTiming(); } // Paper
2020-06-25 09:27:25 +00:00
return;
2020-03-19 06:03:32 +00:00
}
// Spigot end
2020-09-10 22:02:39 +00:00
- entity.tickTimer.startTiming(); // Spigot
+ // Paper start- timings
+ TimingHistory.activatedEntityTicks++;
+ timer = entity.getVehicle() != null ? entity.getEntityType().passengerTickTimer.startTiming() : entity.getEntityType().tickTimer.startTiming();
+ try {
+ // Paper end - timings
2020-08-25 02:22:08 +00:00
entity.g(entity.locX(), entity.locY(), entity.locZ());
2020-03-19 06:03:32 +00:00
entity.lastYaw = entity.yaw;
entity.lastPitch = entity.pitch;
2020-11-03 02:22:15 +00:00
@@ -676,7 +690,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
2020-03-19 06:03:32 +00:00
this.a(entity, entity1);
}
}
2020-09-10 22:02:39 +00:00
- entity.tickTimer.stopTiming(); // Spigot
+ } finally { timer.stopTiming(); } // Paper - timings
2020-03-19 06:03:32 +00:00
}
}
2020-11-18 03:45:18 +00:00
@@ -754,6 +768,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
2016-10-21 20:42:49 +00:00
2019-04-24 01:00:24 +00:00
if (!flag1) {
2016-10-21 20:42:49 +00:00
org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
2019-05-06 07:20:16 +00:00
+ try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper
2016-10-21 20:42:49 +00:00
if (iprogressupdate != null) {
2020-06-25 09:27:25 +00:00
iprogressupdate.a(new ChatMessage("menu.savingLevel"));
2016-10-21 20:42:49 +00:00
}
2020-11-18 03:45:18 +00:00
@@ -763,7 +778,10 @@ public class WorldServer extends World implements GeneratorAccessSeed {
2020-06-25 09:27:25 +00:00
iprogressupdate.c(new ChatMessage("menu.savingChunks"));
2016-10-21 20:42:49 +00:00
}
+ timings.worldSaveChunks.startTiming(); // Paper
2019-04-24 01:00:24 +00:00
chunkproviderserver.save(flag);
2016-10-21 20:42:49 +00:00
+ timings.worldSaveChunks.stopTiming(); // Paper
2019-04-24 01:00:24 +00:00
+ } // Paper
2016-10-21 20:42:49 +00:00
}
2019-06-25 13:55:44 +00:00
// CraftBukkit start - moved from MinecraftServer.saveChunks
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2021-02-21 20:55:01 +00:00
index a19242d717f7f9c254e6127fb2cb2f202be2d78a..351440f534653c9d315ccaf1e923e03ca6ba01f6 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2020-12-13 00:42:05 +00:00
@@ -2069,12 +2069,31 @@ public final class CraftServer implements Server {
2016-02-29 23:09:49 +00:00
private final Spigot spigot = new Spigot()
{
2016-01-09 06:32:38 +00:00
+ @Deprecated
@Override
public YamlConfiguration getConfig()
{
2018-03-10 13:07:40 +00:00
return org.spigotmc.SpigotConfig.config;
2016-02-29 23:09:49 +00:00
}
2018-03-10 13:07:40 +00:00
+ @Override
2016-01-09 06:32:38 +00:00
+ public YamlConfiguration getBukkitConfig()
+ {
+ return configuration;
+ }
+
+ @Override
+ public YamlConfiguration getSpigotConfig()
+ {
2016-02-29 23:09:49 +00:00
+ return org.spigotmc.SpigotConfig.config;
+ }
+
+ @Override
+ public YamlConfiguration getPaperConfig()
2016-01-09 06:32:38 +00:00
+ {
2016-02-29 23:09:49 +00:00
+ return com.destroystokyo.paper.PaperConfig.config;
2016-01-09 06:32:38 +00:00
+ }
+
2018-03-10 13:07:40 +00:00
@Override
2016-01-09 06:32:38 +00:00
public void restart() {
org.spigotmc.RestartCommand.restart();
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
2021-02-21 20:55:01 +00:00
index 66523c21c49b8a019a82fdeb84a187c3b627ab73..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
2021-02-21 20:55:01 +00:00
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
2020-06-25 09:27:25 +00:00
@@ -1,163 +0,0 @@
2016-01-09 06:32:38 +00:00
-package org.bukkit.craftbukkit;
-
-import java.util.HashMap;
2019-04-24 01:00:24 +00:00
-import net.minecraft.server.Entity;
-import net.minecraft.server.TileEntity;
-import net.minecraft.server.World;
2020-06-25 09:27:25 +00:00
-import net.minecraft.server.WorldDataServer;
2016-01-09 06:32:38 +00:00
-import org.bukkit.craftbukkit.scheduler.CraftTask;
2019-04-24 01:00:24 +00:00
-import org.bukkit.plugin.java.JavaPluginLoader;
-import org.bukkit.scheduler.BukkitTask;
-import org.spigotmc.CustomTimingsHandler;
2016-01-09 06:32:38 +00:00
-
-public class SpigotTimings {
-
- public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick");
- public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List");
2017-05-14 18:05:01 +00:00
- public static final CustomTimingsHandler commandFunctionsTimer = new CustomTimingsHandler("Command Functions");
2016-01-09 06:32:38 +00:00
- public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Connection Handler");
2018-10-28 22:08:08 +00:00
- public static final CustomTimingsHandler playerConnectionTimer = new CustomTimingsHandler("** PlayerConnection");
2016-01-09 06:32:38 +00:00
- public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
- public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
- public static final CustomTimingsHandler timeUpdateTimer = new CustomTimingsHandler("Time Update");
- public static final CustomTimingsHandler serverCommandTimer = new CustomTimingsHandler("Server Command");
- public static final CustomTimingsHandler worldSaveTimer = new CustomTimingsHandler("World Save");
-
- public static final CustomTimingsHandler entityMoveTimer = new CustomTimingsHandler("** entityMove");
- public static final CustomTimingsHandler tickEntityTimer = new CustomTimingsHandler("** tickEntity");
- public static final CustomTimingsHandler activatedEntityTimer = new CustomTimingsHandler("** activatedTickEntity");
- public static final CustomTimingsHandler tickTileEntityTimer = new CustomTimingsHandler("** tickTileEntity");
-
- public static final CustomTimingsHandler timerEntityBaseTick = new CustomTimingsHandler("** livingEntityBaseTick");
- public static final CustomTimingsHandler timerEntityAI = new CustomTimingsHandler("** livingEntityAI");
- public static final CustomTimingsHandler timerEntityAICollision = new CustomTimingsHandler("** livingEntityAICollision");
- public static final CustomTimingsHandler timerEntityAIMove = new CustomTimingsHandler("** livingEntityAIMove");
- public static final CustomTimingsHandler timerEntityTickRest = new CustomTimingsHandler("** livingEntityTickRest");
-
- public static final CustomTimingsHandler processQueueTimer = new CustomTimingsHandler("processQueue");
- public static final CustomTimingsHandler schedulerSyncTimer = new CustomTimingsHandler("** Scheduler - Sync Tasks", JavaPluginLoader.pluginParentTimer);
-
- public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
-
- public static final CustomTimingsHandler entityActivationCheckTimer = new CustomTimingsHandler("entityActivationCheck");
- public static final CustomTimingsHandler checkIfActiveTimer = new CustomTimingsHandler("** checkIfActive");
-
- public static final HashMap<String, CustomTimingsHandler> entityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
- public static final HashMap<String, CustomTimingsHandler> tileEntityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
- public static final HashMap<String, CustomTimingsHandler> pluginTaskTimingMap = new HashMap<String, CustomTimingsHandler>();
-
- /**
- * Gets a timer associated with a plugins tasks.
- * @param task
- * @param period
- * @return
- */
- public static CustomTimingsHandler getPluginTaskTimings(BukkitTask task, long period) {
- if (!task.isSync()) {
- return null;
- }
- String plugin;
- final CraftTask ctask = (CraftTask) task;
-
- if (task.getOwner() != null) {
- plugin = task.getOwner().getDescription().getFullName();
- } else {
- plugin = "Unknown";
- }
- String taskname = ctask.getTaskName();
-
- String name = "Task: " + plugin + " Runnable: " + taskname;
- if (period > 0) {
2021-02-21 20:55:01 +00:00
- name += "(interval:" + period + ")";
2016-01-09 06:32:38 +00:00
- } else {
- name += "(Single)";
- }
- CustomTimingsHandler result = pluginTaskTimingMap.get(name);
- if (result == null) {
- result = new CustomTimingsHandler(name, SpigotTimings.schedulerSyncTimer);
- pluginTaskTimingMap.put(name, result);
- }
- return result;
- }
-
- /**
- * Get a named timer for the specified entity type to track type specific timings.
- * @param entity
- * @return
- */
- public static CustomTimingsHandler getEntityTimings(Entity entity) {
2017-10-29 15:19:21 +00:00
- String entityType = entity.getClass().getName();
2016-01-09 06:32:38 +00:00
- CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
- if (result == null) {
2017-10-29 15:19:21 +00:00
- result = new CustomTimingsHandler("** tickEntity - " + entity.getClass().getSimpleName(), activatedEntityTimer);
2016-01-09 06:32:38 +00:00
- entityTypeTimingMap.put(entityType, result);
- }
- return result;
- }
-
- /**
- * Get a named timer for the specified tile entity type to track type specific timings.
- * @param entity
- * @return
- */
- public static CustomTimingsHandler getTileEntityTimings(TileEntity entity) {
2017-10-29 15:19:21 +00:00
- String entityType = entity.getClass().getName();
2016-01-09 06:32:38 +00:00
- CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
- if (result == null) {
2017-10-29 15:19:21 +00:00
- result = new CustomTimingsHandler("** tickTileEntity - " + entity.getClass().getSimpleName(), tickTileEntityTimer);
2016-01-09 06:32:38 +00:00
- tileEntityTypeTimingMap.put(entityType, result);
- }
- return result;
- }
-
- /**
- * Set of timers per world, to track world specific timings.
- */
- public static class WorldTimingsHandler {
- public final CustomTimingsHandler mobSpawn;
- public final CustomTimingsHandler doChunkUnload;
- public final CustomTimingsHandler doTickPending;
- public final CustomTimingsHandler doTickTiles;
- public final CustomTimingsHandler doChunkMap;
- public final CustomTimingsHandler doSounds;
- public final CustomTimingsHandler entityTick;
- public final CustomTimingsHandler tileEntityTick;
- public final CustomTimingsHandler tileEntityPending;
- public final CustomTimingsHandler tracker;
- public final CustomTimingsHandler doTick;
- public final CustomTimingsHandler tickEntities;
-
- public final CustomTimingsHandler syncChunkLoadTimer;
- public final CustomTimingsHandler syncChunkLoadStructuresTimer;
- public final CustomTimingsHandler syncChunkLoadEntitiesTimer;
- public final CustomTimingsHandler syncChunkLoadTileEntitiesTimer;
- public final CustomTimingsHandler syncChunkLoadTileTicksTimer;
- public final CustomTimingsHandler syncChunkLoadPostTimer;
-
- public WorldTimingsHandler(World server) {
2020-06-25 09:27:25 +00:00
- String name = ((WorldDataServer) server.worldData).getName() + " - ";
2016-01-09 06:32:38 +00:00
-
- mobSpawn = new CustomTimingsHandler("** " + name + "mobSpawn");
- doChunkUnload = new CustomTimingsHandler("** " + name + "doChunkUnload");
- doTickPending = new CustomTimingsHandler("** " + name + "doTickPending");
- doTickTiles = new CustomTimingsHandler("** " + name + "doTickTiles");
- doChunkMap = new CustomTimingsHandler("** " + name + "doChunkMap");
- doSounds = new CustomTimingsHandler("** " + name + "doSounds");
- entityTick = new CustomTimingsHandler("** " + name + "entityTick");
- tileEntityTick = new CustomTimingsHandler("** " + name + "tileEntityTick");
- tileEntityPending = new CustomTimingsHandler("** " + name + "tileEntityPending");
-
- syncChunkLoadTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad");
- syncChunkLoadStructuresTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Structures");
- syncChunkLoadEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Entities");
- syncChunkLoadTileEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileEntities");
- syncChunkLoadTileTicksTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileTicks");
- syncChunkLoadPostTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Post");
-
-
- tracker = new CustomTimingsHandler(name + "tracker");
- doTick = new CustomTimingsHandler(name + "doTick");
- tickEntities = new CustomTimingsHandler(name + "tickEntities");
- }
- }
-}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2021-02-21 20:55:01 +00:00
index 6ebcf2afe78a0e0ab3ed4570b6aa416973c48fdf..8428ef53e0408c4a7f74cc03e7e238be9c2f1888 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2021-02-21 20:55:01 +00:00
@@ -1820,6 +1820,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2016-02-29 23:09:49 +00:00
packet.components = components;
getHandle().playerConnection.sendPacket(packet);
2016-01-09 06:32:38 +00:00
}
+
2018-09-28 23:31:59 +00:00
+ // Paper start
2016-01-09 06:32:38 +00:00
+ @Override
+ public int getPing()
+ {
+ return getHandle().ping;
+ }
2018-09-28 23:31:59 +00:00
+ // Paper end
2016-01-09 06:32:38 +00:00
};
public Player.Spigot spigot()
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2020-06-28 09:34:23 +00:00
index 4bf48f77f3f7cd62a91590543f5af441c8268029..ffe9cc1011226d604dc5499e7692e9a9a5132b72 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
2019-04-24 01:00:24 +00:00
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.scheduler;
2017-02-05 05:13:16 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2019-04-24 01:00:24 +00:00
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayList;
import java.util.Comparator;
2020-06-09 07:17:25 +00:00
@@ -179,7 +180,8 @@ public class CraftScheduler implements BukkitScheduler {
}
public BukkitTask scheduleInternalTask(Runnable run, int delay, String taskName) {
- final CraftTask task = new CraftTask(run, nextId(), taskName);
+ final CraftTask task = new CraftTask(run, nextId(), "Internal - " + (taskName != null ? taskName : "Unknown"));
+ task.internal = true;
return handle(task, delay);
}
@@ -260,7 +262,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 06:32:38 +00:00
}
return false;
2020-04-27 07:34:45 +00:00
}
- });
+ }){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer();}}; // Paper
2018-03-31 09:34:25 +00:00
handle(task, 0L);
2016-01-09 06:32:38 +00:00
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2020-06-09 07:17:25 +00:00
@@ -295,7 +297,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 06:32:38 +00:00
}
}
}
- });
2016-04-30 01:23:40 +00:00
+ }){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer(plugin);}}; // Paper
2018-03-31 09:34:25 +00:00
handle(task, 0L);
2016-01-09 06:32:38 +00:00
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
2020-06-09 07:17:25 +00:00
@@ -402,9 +404,7 @@ public class CraftScheduler implements BukkitScheduler {
2016-01-09 06:32:38 +00:00
if (task.isSync()) {
2018-06-21 03:29:33 +00:00
currentTask = task;
2016-01-09 06:32:38 +00:00
try {
- task.timings.startTiming(); // Spigot
task.run();
- task.timings.stopTiming(); // Spigot
} catch (final Throwable throwable) {
2020-06-28 09:34:23 +00:00
// Paper start
String msg = String.format(
@@ -438,8 +438,10 @@ public class CraftScheduler implements BukkitScheduler {
2017-02-05 05:13:16 +00:00
runners.remove(task.getTaskId());
}
}
+ MinecraftTimings.bukkitSchedulerFinishTimer.startTiming();
pending.addAll(temp);
temp.clear();
+ MinecraftTimings.bukkitSchedulerFinishTimer.stopTiming();
debugHead = debugHead.getNextHead(currentTick);
}
2020-06-28 09:34:23 +00:00
@@ -472,6 +474,7 @@ public class CraftScheduler implements BukkitScheduler {
2017-02-05 05:13:16 +00:00
}
private void parsePending() {
+ MinecraftTimings.bukkitSchedulerPendingTimer.startTiming();
CraftTask head = this.head;
CraftTask task = head.getNext();
CraftTask lastTask = head;
2020-06-28 09:34:23 +00:00
@@ -490,6 +493,7 @@ public class CraftScheduler implements BukkitScheduler {
2020-04-27 07:34:45 +00:00
task.setNext(null);
2017-02-05 05:13:16 +00:00
}
this.head = lastTask;
+ MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming();
}
private boolean isReady(final int currentTick) {
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
2021-02-21 20:55:01 +00:00
index f5f70c1fe31e5c533991e2c857fe8c10a83b94fc..90ba08993fefd975b1095dafa6304aad49c62088 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
2021-02-21 20:55:01 +00:00
@@ -1,11 +1,13 @@
2019-03-26 05:31:59 +00:00
package org.bukkit.craftbukkit.scheduler;
2016-01-09 06:32:38 +00:00
2018-11-24 05:28:04 +00:00
import java.util.function.Consumer;
2019-03-26 05:31:59 +00:00
+
+import co.aikar.timings.NullTimingHandler;
2016-01-09 06:32:38 +00:00
import org.bukkit.Bukkit;
2021-02-21 20:55:01 +00:00
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
2021-02-21 19:45:33 +00:00
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
-import org.spigotmc.CustomTimingsHandler; // Spigot
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings; // Paper
2016-02-29 23:09:49 +00:00
+import co.aikar.timings.Timing; // Paper
2016-01-09 06:32:38 +00:00
2021-02-21 20:55:01 +00:00
public class CraftTask implements BukkitTask, Runnable { // Spigot
2021-02-21 19:45:33 +00:00
@@ -26,12 +28,12 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2016-01-09 06:32:38 +00:00
*/
private volatile long period;
private long nextRun;
2018-11-24 05:28:04 +00:00
- private final Runnable rTask;
- private final Consumer<BukkitTask> cTask;
+ public final Runnable rTask; // Paper
+ public final Consumer<BukkitTask> cTask; // Paper
2016-02-29 23:09:49 +00:00
+ public Timing timings; // Paper
2016-01-09 06:32:38 +00:00
private final Plugin plugin;
private final int id;
- final CustomTimingsHandler timings; // Spigot
CraftTask() {
2018-03-31 09:34:25 +00:00
this(null, null, CraftTask.NO_REPEATING, CraftTask.NO_REPEATING);
2016-01-09 06:32:38 +00:00
}
2021-02-21 19:45:33 +00:00
@@ -51,7 +53,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2020-06-09 07:17:25 +00:00
this.id = id;
this.period = CraftTask.NO_REPEATING;
this.taskName = taskName;
- this.timings = null; // Will be changed in later patch
+ this.timings = MinecraftTimings.getInternalTaskName(taskName);
2016-01-09 06:32:38 +00:00
}
2020-06-09 07:17:25 +00:00
// Paper end
2016-01-09 06:32:38 +00:00
2021-02-21 19:45:33 +00:00
@@ -72,7 +74,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2018-11-24 05:28:04 +00:00
}
2016-01-09 06:32:38 +00:00
this.id = id;
this.period = period;
2018-11-24 05:28:04 +00:00
- this.timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null; // Spigot
2019-03-26 05:31:59 +00:00
+ timings = task != null ? MinecraftTimings.getPluginTaskTimings(this, period) : NullTimingHandler.NULL; // Paper
2016-01-09 06:32:38 +00:00
}
2018-11-24 05:28:04 +00:00
@Override
2021-02-21 19:45:33 +00:00
@@ -92,11 +94,13 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2016-01-09 06:32:38 +00:00
2018-11-24 05:28:04 +00:00
@Override
2016-01-09 06:32:38 +00:00
public void run() {
2019-03-26 04:31:34 +00:00
+ try (Timing ignored = timings.startTiming()) { // Paper
2018-11-24 05:28:04 +00:00
if (rTask != null) {
rTask.run();
} else {
cTask.accept(this);
}
2019-03-26 04:31:34 +00:00
+ } // Paper
2016-01-09 06:32:38 +00:00
}
long getPeriod() {
2021-02-21 19:45:33 +00:00
@@ -123,7 +127,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2018-11-24 05:28:04 +00:00
this.next = next;
}
- Class<?> getTaskClass() {
+ public Class<?> getTaskClass() {
return (rTask != null) ? rTask.getClass() : ((cTask != null) ? cTask.getClass() : null);
}
2021-02-21 19:45:33 +00:00
@@ -147,9 +151,4 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
2016-01-09 06:32:38 +00:00
return true;
}
2018-11-24 05:28:04 +00:00
2016-01-09 06:32:38 +00:00
- // Spigot start
- public String getTaskName() {
2018-11-24 05:28:04 +00:00
- return (getTaskClass() == null) ? "Unknown" : getTaskClass().getName();
2016-01-09 06:32:38 +00:00
- }
- // Spigot end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
2020-05-06 09:48:49 +00:00
index e52ef47b783785dc214746b678e7b549aea9a274..3d90b3426873a3528af14f7f1ab0adae0027da2e 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
@@ -5,6 +5,7 @@ import org.bukkit.util.CachedServerIcon;
public class CraftIconCache implements CachedServerIcon {
public final String value;
2016-02-29 23:09:49 +00:00
+ public String getData() { return value; } // Paper
2016-01-09 06:32:38 +00:00
public CraftIconCache(final String value) {
this.value = value;
}
2019-05-06 07:20:16 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
2021-01-27 04:22:32 +00:00
index 6194d8aac0d2e54958aad3fb8b5fe144451cf879..d63a160f1b00de8d67ae1eb4fefbd5ca06835de7 100644
2019-05-06 07:20:16 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
2020-09-14 09:57:06 +00:00
@@ -158,6 +158,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
2020-06-03 03:26:29 +00:00
return CraftNamespacedKey.toMinecraft(mat.getKey());
}
// ========================================================================
+ // Paper start
+ @Override
+ public void reportTimings() {
+ co.aikar.timings.TimingsExport.reportTimings();
+ }
+ // Paper end
public static byte toLegacyData(IBlockData data) {
return CraftLegacy.toLegacyData(data);
2020-09-14 09:57:06 +00:00
@@ -332,6 +338,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
2019-05-06 07:20:16 +00:00
return clazz;
}
+ // Paper start
+ @Override
+ public String getTimingsServerName() {
+ return com.destroystokyo.paper.PaperConfig.timingsServerName;
+ }
+ // Paper end
+
/**
* This helper class represents the different NBT Tags.
* <p>
2016-01-09 06:32:38 +00:00
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
2021-02-21 20:55:01 +00:00
index 383997d2e57a31e2ff30cf1bf34128fe477390a8..093a11b6e355f9e1236ecca921ea55488d70451d 100644
2016-01-09 06:32:38 +00:00
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
2021-02-21 20:55:01 +00:00
@@ -29,7 +29,7 @@ import net.minecraft.server.EntityWither;
2016-03-25 04:59:37 +00:00
import net.minecraft.server.MathHelper;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.World;
2016-01-09 06:32:38 +00:00
-import org.bukkit.craftbukkit.SpigotTimings;
2016-04-30 01:23:40 +00:00
+import co.aikar.timings.MinecraftTimings;
2016-01-09 06:32:38 +00:00
public class ActivationRange
{
2021-02-21 20:55:01 +00:00
@@ -73,8 +73,8 @@ public class ActivationRange
2016-04-30 01:23:40 +00:00
/**
* These entities are excluded from Activation range checks.
*
- * @param entity
2019-05-30 23:54:25 +00:00
- * @param config
2016-04-30 01:23:40 +00:00
+ * @param entity Entity to initialize
+ * @param config Spigot config to determine ranges
* @return boolean If it should always tick.
*/
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
2021-02-21 20:55:01 +00:00
@@ -109,7 +109,7 @@ public class ActivationRange
2016-04-30 01:23:40 +00:00
*/
public static void activateEntities(World world)
{
- SpigotTimings.entityActivationCheckTimer.startTiming();
+ MinecraftTimings.entityActivationCheckTimer.startTiming();
final int miscActivationRange = world.spigotConfig.miscActivationRange;
2019-05-30 23:54:25 +00:00
final int raiderActivationRange = world.spigotConfig.raiderActivationRange;
2016-04-30 01:23:40 +00:00
final int animalActivationRange = world.spigotConfig.animalActivationRange;
2021-02-21 20:55:01 +00:00
@@ -146,7 +146,7 @@ public class ActivationRange
2016-04-30 01:23:40 +00:00
}
}
}
- SpigotTimings.entityActivationCheckTimer.stopTiming();
+ MinecraftTimings.entityActivationCheckTimer.stopTiming();
}
/**
2021-02-21 20:55:01 +00:00
@@ -243,10 +243,8 @@ public class ActivationRange
2016-03-18 21:11:53 +00:00
*/
public static boolean checkIfActive(Entity entity)
{
- SpigotTimings.checkIfActiveTimer.startTiming();
// Never safe to skip fireworks or entities not yet added to chunk
2018-07-15 01:53:17 +00:00
if ( !entity.inChunk || entity instanceof EntityFireworks ) {
2016-03-18 21:11:53 +00:00
- SpigotTimings.checkIfActiveTimer.stopTiming();
return true;
}
2021-02-21 20:55:01 +00:00
@@ -270,7 +268,6 @@ public class ActivationRange
2016-03-18 21:11:53 +00:00
{
isActive = false;
}
- SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
}