Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Timings and bundle Spark #2117

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,472 changes: 1,234 additions & 1,238 deletions src/main/java/cn/nukkit/Player.java

Large diffs are not rendered by default.

18 changes: 4 additions & 14 deletions src/main/java/cn/nukkit/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
import cn.nukkit.resourcepacks.ResourcePackManager;
import cn.nukkit.scheduler.ServerScheduler;
import cn.nukkit.scheduler.Task;
import cn.nukkit.spark.SparkInstaller;
import cn.nukkit.utils.*;
import cn.nukkit.utils.bugreport.ExceptionHandler;
import co.aikar.timings.Timings;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -504,6 +504,8 @@ public Level remove(Object key) {

this.pluginManager.loadPlugins(this.pluginPath);

SparkInstaller.initSpark(this);

this.enablePlugins(PluginLoadOrder.STARTUP);

LevelProviderManager.addProvider(this, Anvil.class);
Expand Down Expand Up @@ -690,7 +692,6 @@ public void batchPackets(Player[] players, DataPacket[] packets, boolean forceSy
return;
}

Timings.playerNetworkSendTimer.startTiming();
byte[][] payload = new byte[packets.length * 2][];
for (int i = 0; i < packets.length; i++) {
DataPacket p = packets[i];
Expand Down Expand Up @@ -719,7 +720,6 @@ public void batchPackets(Player[] players, DataPacket[] packets, boolean forceSy
throw new RuntimeException(e);
}
}
Timings.playerNetworkSendTimer.stopTiming();
}

public void broadcastPacketsCallback(byte[] data, List<InetSocketAddress> targets) {
Expand Down Expand Up @@ -815,9 +815,9 @@ public void reload() {

this.pluginManager.registerInterface(JavaPluginLoader.class);
this.pluginManager.loadPlugins(this.pluginPath);
SparkInstaller.initSpark(this);
this.enablePlugins(PluginLoadOrder.STARTUP);
this.enablePlugins(PluginLoadOrder.POSTWORLD);
Timings.reset();
}

public void shutdown() {
Expand Down Expand Up @@ -874,7 +874,6 @@ public void forceShutdown() {
}

this.getLogger().debug("Disabling timings");
Timings.stopServer();
if (this.watchdog != null) {
this.watchdog.kill();
}
Expand Down Expand Up @@ -1122,7 +1121,6 @@ private void checkTickUpdates(int currentTick, long tickTime) {

public void doAutoSave() {
if (this.getAutoSave()) {
Timings.levelSaveTimer.startTiming();
for (Player player : new ArrayList<>(this.players.values())) {
if (player.isOnline()) {
player.save(true);
Expand All @@ -1134,7 +1132,6 @@ public void doAutoSave() {
for (Level level : this.levelArray) {
level.save();
}
Timings.levelSaveTimer.stopTiming();
}
}

Expand All @@ -1156,21 +1153,15 @@ private boolean tick() {
return false;
}

Timings.fullServerTickTimer.startTiming();

++this.tickCounter;

Timings.connectionTimer.startTiming();
this.network.processInterfaces();

if (this.rcon != null) {
this.rcon.check();
}
Timings.connectionTimer.stopTiming();

Timings.schedulerTimer.startTiming();
this.scheduler.mainThreadHeartbeat(this.tickCounter);
Timings.schedulerTimer.stopTiming();

this.checkTickUpdates(this.tickCounter, tickTime);

Expand Down Expand Up @@ -1214,7 +1205,6 @@ private boolean tick() {
}
}

Timings.fullServerTickTimer.stopTiming();
//long now = System.currentTimeMillis();
long nowNano = System.nanoTime();
//float tick = Math.min(20, 1000 / Math.max(1, now - tickTime));
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/cn/nukkit/blockentity/BlockEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import cn.nukkit.nbt.tag.CompoundTag;
import cn.nukkit.utils.ChunkException;
import cn.nukkit.utils.MainLogger;
import co.aikar.timings.Timing;
import co.aikar.timings.Timings;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;

Expand Down Expand Up @@ -58,14 +56,12 @@ public abstract class BlockEntity extends Position {
public CompoundTag namedTag;
protected long lastUpdate;
protected Server server;
protected Timing timing;

public BlockEntity(FullChunk chunk, CompoundTag nbt) {
if (chunk == null || chunk.getProvider() == null) {
throw new ChunkException("Invalid garbage Chunk given to Block Entity");
}

this.timing = Timings.getBlockEntityTiming(this);
this.server = chunk.getProvider().getLevel().getServer();
this.chunk = chunk;
this.setLevel(chunk.getProvider().getLevel());
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/cn/nukkit/blockentity/BlockEntityFurnace.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ public boolean onUpdate() {
return false;
}

this.timing.startTiming();

boolean ret = false;
Item fuel = this.inventory.getFuel();
Item raw = this.inventory.getSmelting();
Expand Down Expand Up @@ -304,8 +302,6 @@ public boolean onUpdate() {

this.lastUpdate = System.currentTimeMillis();

this.timing.stopTiming();

return ret;
}

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/cn/nukkit/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.permission.Permissible;
import cn.nukkit.utils.TextFormat;
import co.aikar.timings.Timing;
import co.aikar.timings.Timings;

import java.util.*;

Expand Down Expand Up @@ -44,8 +42,6 @@ public abstract class Command {

protected Map<String, CommandParameter[]> commandParameters = new HashMap<>();

public Timing timing;

public Command(String name) {
this(name, "", null, new String[0]);
}
Expand All @@ -67,7 +63,6 @@ public Command(String name, String description, String usageMessage, String[] al
this.usageMessage = usageMessage == null ? "/" + name : usageMessage;
this.aliases = aliases;
this.activeAliases = aliases;
this.timing = Timings.getCommandTiming(this);
this.commandParameters.put("default", new CommandParameter[]{CommandParameter.newType("args", true, CommandParamType.RAWTEXT)});
}

Expand Down Expand Up @@ -186,7 +181,6 @@ public boolean setLabel(String name) {
this.nextLabel = name;
if (!this.isRegistered()) {
this.label = name;
this.timing = Timings.getCommandTiming(this);
return true;
}
return false;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/cn/nukkit/command/SimpleCommandMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ private void setDefaultCommands() {
// if ((boolean) this.server.getConfig("debug.commands", false)) {
this.register("nukkit", new StatusCommand("status"));
this.register("nukkit", new GarbageCollectorCommand("gc"));
this.register("nukkit", new TimingsCommand("timings"));
this.register("nukkit", new DebugPasteCommand("debugpaste"));
//this.register("nukkit", new DumpMemoryCommand("dumpmemory"));
// }
Expand Down Expand Up @@ -252,7 +251,6 @@ public boolean dispatch(CommandSender sender, String cmdLine) {
return false;
}

target.timing.startTiming();
try {
target.execute(sender, sentCommandLabel, args);
} catch (Exception e) {
Expand All @@ -263,7 +261,6 @@ public boolean dispatch(CommandSender sender, String cmdLine) {
logger.logException(e);
}
}
target.timing.stopTiming();

return true;
}
Expand Down
74 changes: 0 additions & 74 deletions src/main/java/cn/nukkit/command/defaults/TimingsCommand.java

This file was deleted.

3 changes: 0 additions & 3 deletions src/main/java/cn/nukkit/console/NukkitConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cn.nukkit.Server;
import cn.nukkit.event.server.ServerCommandEvent;
import co.aikar.timings.Timings;
import lombok.RequiredArgsConstructor;
import net.minecrell.terminalconsole.SimpleTerminalConsole;
import org.jline.reader.LineReader;
Expand All @@ -26,15 +25,13 @@ protected boolean isRunning() {
@Override
protected void runCommand(String command) {
if (executingCommands.get()) {
Timings.serverCommandTimer.startTiming();
ServerCommandEvent event = new ServerCommandEvent(server.getConsoleSender(), command);
if (server.getPluginManager() != null) {
server.getPluginManager().callEvent(event);
}
if (!event.isCancelled()) {
Server.getInstance().getScheduler().scheduleTask(() -> server.dispatchCommand(event.getSender(), event.getCommand()));
}
Timings.serverCommandTimer.stopTiming();
} else {
consoleQueue.add(command);
}
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/cn/nukkit/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
import cn.nukkit.scheduler.Task;
import cn.nukkit.utils.ChunkException;
import cn.nukkit.utils.MainLogger;
import co.aikar.timings.Timing;
import co.aikar.timings.Timings;
import co.aikar.timings.TimingsHistory;
import com.google.common.collect.Iterables;

import java.lang.reflect.Constructor;
Expand Down Expand Up @@ -401,8 +398,6 @@ public abstract class Entity extends Location implements Metadatable {

public boolean closed = false;

protected Timing timing;

protected boolean isPlayer = this instanceof Player;

private volatile boolean initialized;
Expand Down Expand Up @@ -495,8 +490,6 @@ protected final void init(FullChunk chunk, CompoundTag nbt) {
}
this.initialized = true;

this.timing = Timings.getEntityTiming(this);

this.temporalVector = new Vector3();

this.id = Entity.entityCount++;
Expand Down Expand Up @@ -1333,8 +1326,6 @@ public boolean entityBaseTick() {
}

public boolean entityBaseTick(int tickDiff) {
Timings.entityBaseTickTimer.startTiming();

if (!this.isPlayer) {
this.blocksAround = null;
this.collisionBlocks = null;
Expand All @@ -1347,7 +1338,6 @@ public boolean entityBaseTick(int tickDiff) {
if (!this.isPlayer) {
this.close();
}
Timings.entityBaseTickTimer.stopTiming();
return false;
}
if (riding != null && !riding.isAlive() && riding instanceof EntityRideable) {
Expand Down Expand Up @@ -1442,9 +1432,7 @@ public void onRun(int currentTick) {

this.age += tickDiff;
this.ticksLived += tickDiff;
TimingsHistory.activatedEntityTicks++;

Timings.entityBaseTickTimer.stopTiming();
return hasUpdate;
}

Expand Down Expand Up @@ -1912,8 +1900,6 @@ public boolean fastMove(double dx, double dy, double dz) {
return true;
}

Timings.entityMoveTimer.startTiming();

AxisAlignedBB newBB = this.boundingBox.getOffsetBoundingBox(dx, dy, dz);

if (server.getAllowFlight() || !this.level.hasCollision(this, newBB, false)) {
Expand All @@ -1934,7 +1920,6 @@ public boolean fastMove(double dx, double dy, double dz) {
}
this.isCollided = this.onGround;
this.updateFallState(this.onGround);
Timings.entityMoveTimer.stopTiming();
return true;
}

Expand All @@ -1949,9 +1934,6 @@ public boolean move(double dx, double dy, double dz) {
this.onGround = this.isPlayer;
return true;
} else {

Timings.entityMoveTimer.startTiming();

this.ySize *= 0.4;

double movX = dx;
Expand Down Expand Up @@ -2049,7 +2031,6 @@ public boolean move(double dx, double dy, double dz) {
}

//TODO: vehicle collision events (first we need to spawn them!)
Timings.entityMoveTimer.stopTiming();
return true;
}
}
Expand Down
Loading