Remove wall-time / unused skip tick protection (#11412)
Spigot still maintains some partial implementation of "tick skipping", a practice in which the MinecraftServer.currentTick field is updated not by an increment of one per actual tick, but instead set to System.currentTimeMillis() / 50. This behaviour means that the tracked tick may "skip" a tick value in case a previous tick took more than the expected 50ms. To compensate for this in important paths, spigot/craftbukkit implements "wall-time". Instead of incrementing/decrementing ticks on block entities/entities by one for each call to their tick() method, they instead increment/decrement important values, like an ItemEntity's age or pickupDelay, by the difference of `currentTick - lastTick`, where `lastTick` is the value of `currentTick` during the last tick() call. These "fixes" however do not play nicely with minecraft's simulation distance as entities/block entities implementing the above behaviour would "catch up" their values when moving from a non-ticking chunk to a ticking one as their `lastTick` value remains stuck on the last tick in a ticking chunk and hence lead to a large "catch up" once ticked again. Paper completely removes the "tick skipping" behaviour (See patch "Further-improve-server-tick-loop"), making the above precautions completely unnecessary, which also rids paper of the previous described incompatibility with non-ticking chunks.
This commit is contained in:
parent
5c82955733
commit
c5a10665b8
794 changed files with 402 additions and 282 deletions
63
patches/server/0809-Use-array-for-gamerule-storage.patch
Normal file
63
patches/server/0809-Use-array-for-gamerule-storage.patch
Normal file
|
@ -0,0 +1,63 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Sauve <paul@technove.co>
|
||||
Date: Sun, 9 May 2021 16:49:49 -0500
|
||||
Subject: [PATCH] Use array for gamerule storage
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
index 51e560d7856f230c5aa2dc32706c3a4996720aa5..89e327bc3a45879fe68887c7aadb077f31a770eb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
@@ -122,6 +122,7 @@ public class GameRules {
|
||||
worldserver.setDefaultSpawnPos(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle());
|
||||
}));
|
||||
private final Map<GameRules.Key<?>, GameRules.Value<?>> rules;
|
||||
+ private final GameRules.Value<?>[] gameruleArray; // Paper - Perf: Use array for gamerule storage
|
||||
|
||||
private static <T extends GameRules.Value<T>> GameRules.Key<T> register(String name, GameRules.Category category, GameRules.Type<T> type) {
|
||||
GameRules.Key<T> gamerules_gamerulekey = new GameRules.Key<>(name, category);
|
||||
@@ -140,17 +141,30 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public GameRules() {
|
||||
- this.rules = (Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> {
|
||||
+ // Paper start - Perf: Use array for gamerule storage
|
||||
+ this((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> {
|
||||
return ((GameRules.Type) entry.getValue()).createRule();
|
||||
- }));
|
||||
+ })));
|
||||
+ // Paper end - Perf: Use array for gamerule storage
|
||||
}
|
||||
|
||||
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules) {
|
||||
this.rules = rules;
|
||||
+
|
||||
+ // Paper start - Perf: Use array for gamerule storage
|
||||
+ int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1;
|
||||
+ GameRules.Value<?>[] values = new GameRules.Value[arraySize];
|
||||
+
|
||||
+ for (Entry<GameRules.Key<?>, GameRules.Value<?>> entry : rules.entrySet()) {
|
||||
+ values[entry.getKey().gameRuleIndex] = entry.getValue();
|
||||
+ }
|
||||
+
|
||||
+ this.gameruleArray = values;
|
||||
+ // Paper end - Perf: Use array for gamerule storage
|
||||
}
|
||||
|
||||
public <T extends GameRules.Value<T>> T getRule(GameRules.Key<T> key) {
|
||||
- return (T) this.rules.get(key); // CraftBukkit - decompile error
|
||||
+ return key == null ? null : (T) this.gameruleArray[key.gameRuleIndex]; // Paper - Perf: Use array for gamerule storage
|
||||
}
|
||||
|
||||
public CompoundTag createTag() {
|
||||
@@ -209,6 +223,10 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public static final class Key<T extends GameRules.Value<T>> {
|
||||
+ // Paper start - Perf: Use array for gamerule storage
|
||||
+ private static int lastGameRuleIndex = 0;
|
||||
+ public final int gameRuleIndex = lastGameRuleIndex++;
|
||||
+ // Paper end - Perf: Use array for gamerule storage
|
||||
|
||||
final String id;
|
||||
private final GameRules.Category category;
|
Loading…
Add table
Add a link
Reference in a new issue