mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Re-add block inlining - Closes #1229
Also reordered MC Utils to be higher up
This commit is contained in:
parent
d5a4135e98
commit
1fbc4f4d9b
@ -26,7 +26,7 @@ index a0ebc1eaa..e4c771a39 100644
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 515c9d875..53fc37088 100644
|
||||
index 3fa32228b..e65558f7a 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityPortalEvent;
|
||||
@ -88,7 +88,7 @@ index 515c9d875..53fc37088 100644
|
||||
|
||||
protected abstract void a(NBTTagCompound nbttagcompound);
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
index 557a3f97f..97cfd6695 100644
|
||||
index 9a513b4e3..fa268f354 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
@@ -0,0 +0,0 @@ public class EntityTypes<T extends Entity> {
|
||||
@ -114,7 +114,7 @@ index 000000000..61c2b993c
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
||||
index 093e7eb7f..b09325097 100644
|
||||
index 8a0453245..257dd1da9 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
||||
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
|
||||
|
@ -18,7 +18,7 @@ index c3e990bdf..e2a7b4be2 100644
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
index 121a137f3..35ec4981c 100644
|
||||
index 121a137f3..279045e49 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
|
||||
@ -26,7 +26,6 @@ index 121a137f3..35ec4981c 100644
|
||||
public class BlockPosition extends BaseBlockPosition {
|
||||
|
||||
- private static final Logger b = LogManager.getLogger();
|
||||
+ private static final Logger LOGGER = LogManager.getLogger(); // Paper - b > LOGGER - attempts to avoid /some/ stupidity
|
||||
public static final BlockPosition ZERO = new BlockPosition(0, 0, 0);
|
||||
private static final int c = 1 + MathHelper.e(MathHelper.c(30000000));
|
||||
private static final int d = BlockPosition.c;
|
||||
@ -55,7 +54,7 @@ index 121a137f3..35ec4981c 100644
|
||||
return this.c(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 0ae780c8e..3b97981bc 100644
|
||||
index 411ab6061..cd4fbee0c 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ import com.google.common.collect.Lists; // CraftBukkit
|
||||
@ -89,7 +88,7 @@ index 00a530c51..2947d9ff6 100644
|
||||
return (long) i & 4294967295L | ((long) j & 4294967295L) << 32;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
index 97cfd6695..81605b10f 100644
|
||||
index ca2a14d7a..9a513b4e3 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
@@ -0,0 +0,0 @@ package net.minecraft.server;
|
||||
@ -601,7 +600,7 @@ index b3c944d70..a8280acf9 100644
|
||||
- }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 2fb86aa19..6f21b01a8 100644
|
||||
index 2f2f4c6c6..556989f60 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
|
@ -31,7 +31,7 @@ index e2a7b4be2..58f8b4b72 100644
|
||||
public BaseBlockPosition(int i, int j, int k) {
|
||||
this.a = i;
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
index 35ec4981c..ca73ac82f 100644
|
||||
index 279045e49..7122a9aa8 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
@ -52,7 +52,7 @@ index 35ec4981c..ca73ac82f 100644
|
||||
public MutableBlockPosition() {
|
||||
this(0, 0, 0);
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 0dc05b644..94d036865 100644
|
||||
index 32c1dbd0b..5d1812ab0 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
|
@ -671,7 +671,7 @@ index 3d8ee9ed3..5ab2cf6ee 100644
|
||||
|
||||
static void readConfig(Class<?> clazz, Object instance) {
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index ac36ea08e..09100408e 100644
|
||||
index 5175e9523..676780b61 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -0,0 +0,0 @@ public class SpigotConfig
|
||||
|
198
Spigot-Server-Patches/Speedup-BlockPos-by-fixing-inlining.patch
Normal file
198
Spigot-Server-Patches/Speedup-BlockPos-by-fixing-inlining.patch
Normal file
@ -0,0 +1,198 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Wed, 30 Nov 2016 20:56:58 -0600
|
||||
Subject: [PATCH] Speedup BlockPos by fixing inlining
|
||||
|
||||
Normally the JVM can inline virtual getters by having two sets of code, one is the 'optimized' code and the other is the 'deoptimized' code.
|
||||
If a single type is used 99% of the time, then its worth it to inline, and to revert to 'deoptimized' the 1% of the time we encounter other types.
|
||||
But if two types are encountered commonly, then the JVM can't inline them both, and the call overhead remains.
|
||||
|
||||
This scenario also occurs with BlockPos and MutableBlockPos.
|
||||
The variables in BlockPos are final, so MutableBlockPos can't modify them.
|
||||
MutableBlockPos fixes this by adding custom mutable variables, and overriding the getters to access them.
|
||||
|
||||
This approach with utility methods that operate on MutableBlockPos and BlockPos.
|
||||
Specific examples are BlockPosition.up(), and World.isValidLocation().
|
||||
It makes these simple methods much slower than they need to be.
|
||||
|
||||
This should result in an across the board speedup in anything that accesses blocks or does logic with positions.
|
||||
|
||||
This is based upon conclusions drawn from inspecting the assenmbly generated bythe JIT compiler on my mircorbenchmarks.
|
||||
They had 'callq' (invoke) instead of 'mov' (get from memory) instructions.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
index 58f8b4b72..98992513d 100644
|
||||
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
|
||||
@@ -0,0 +0,0 @@ import javax.annotation.concurrent.Immutable;
|
||||
public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
||||
|
||||
public static final BaseBlockPosition ZERO = new BaseBlockPosition(0, 0, 0);
|
||||
- private final int a;
|
||||
- private final int b;
|
||||
- private final int c;
|
||||
// Paper start
|
||||
+ protected int x;
|
||||
+ protected int y;
|
||||
+ protected int z;
|
||||
public boolean isValidLocation() {
|
||||
- return a >= -30000000 && c >= -30000000 && a < 30000000 && c < 30000000 && b >= 0 && b < 256;
|
||||
+ return x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000 && y >= 0 && y < 256;
|
||||
}
|
||||
public boolean isInvalidYLocation() {
|
||||
- return b < 0 || b >= 256;
|
||||
+ return y < 0 || y >= 256;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public BaseBlockPosition(int i, int j, int k) {
|
||||
- this.a = i;
|
||||
- this.b = j;
|
||||
- this.c = k;
|
||||
+ this.x = i;
|
||||
+ this.y = j;
|
||||
+ this.z = k;
|
||||
}
|
||||
|
||||
public BaseBlockPosition(double d0, double d1, double d2) {
|
||||
@@ -0,0 +0,0 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
|
||||
return this.getY() == baseblockposition.getY() ? (this.getZ() == baseblockposition.getZ() ? this.getX() - baseblockposition.getX() : this.getZ() - baseblockposition.getZ()) : this.getY() - baseblockposition.getY();
|
||||
}
|
||||
|
||||
- public int getX() {
|
||||
- return this.a;
|
||||
+ // Paper start
|
||||
+ public final int getX() {
|
||||
+ return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
- return this.b;
|
||||
+ return this.y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
- return this.c;
|
||||
+ return this.z;
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
public BaseBlockPosition d(BaseBlockPosition baseblockposition) {
|
||||
return new BaseBlockPosition(this.getY() * baseblockposition.getZ() - this.getZ() * baseblockposition.getY(), this.getZ() * baseblockposition.getX() - this.getX() * baseblockposition.getZ(), this.getX() * baseblockposition.getY() - this.getY() * baseblockposition.getX());
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
index 7122a9aa8..2f6fc330b 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
if (this.g == null) {
|
||||
this.g = new BlockPosition.MutableBlockPosition(i, j, k);
|
||||
return this.g;
|
||||
- } else if (this.g.b == l && this.g.c == i1 && this.g.d == j1) {
|
||||
+ } else if (this.g.x == l && this.g.y == i1 && this.g.z == j1) { // Paper
|
||||
return (BlockPosition.MutableBlockPosition) this.endOfData();
|
||||
} else {
|
||||
- if (this.g.b < l) {
|
||||
- ++this.g.b;
|
||||
- } else if (this.g.c < i1) {
|
||||
- ++this.g.c;
|
||||
- } else if (this.g.d < j1) {
|
||||
- ++this.g.d;
|
||||
+ // Paper start - use xyz
|
||||
+ if (this.g.x < l) {
|
||||
+ ++this.g.x;
|
||||
+ } else if (this.g.y < i1) {
|
||||
+ ++this.g.y;
|
||||
+ } else if (this.g.z < j1) {
|
||||
+ ++this.g.z;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
return this.g;
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
|
||||
public static class MutableBlockPosition extends BlockPosition {
|
||||
|
||||
+ // Paper start - comment out
|
||||
+ /*
|
||||
protected int b;
|
||||
protected int c;
|
||||
protected int d;
|
||||
- // Paper start
|
||||
+
|
||||
@Override
|
||||
public boolean isValidLocation() {
|
||||
return b >= -30000000 && d >= -30000000 && b < 30000000 && d < 30000000 && c >= 0 && c < 256;
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
public boolean isInvalidYLocation() {
|
||||
return c < 0 || c >= 256;
|
||||
}
|
||||
+ */
|
||||
// Paper end
|
||||
|
||||
public MutableBlockPosition() {
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public MutableBlockPosition(int i, int j, int k) {
|
||||
- super(0, 0, 0);
|
||||
+ // Paper start
|
||||
+ super(i, j, k);
|
||||
+ /*
|
||||
this.b = i;
|
||||
this.c = j;
|
||||
- this.d = k;
|
||||
+ this.d = k;*/
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public BlockPosition a(double d0, double d1, double d2) {
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
return super.a(enumblockrotation).h();
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ // Paper start - use parent getters
|
||||
public int getX() {
|
||||
return this.b;
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
|
||||
public int getZ() {
|
||||
return this.d;
|
||||
- }
|
||||
+ }*/
|
||||
+ // Paper end
|
||||
|
||||
public BlockPosition.MutableBlockPosition setValues(int i, int j, int k) { return c(i, j, k);} // Paper - OBFHELPER
|
||||
public BlockPosition.MutableBlockPosition c(int i, int j, int k) {
|
||||
- this.b = i;
|
||||
- this.c = j;
|
||||
- this.d = k;
|
||||
+ // Paper start - use xyz
|
||||
+ this.x = i;
|
||||
+ this.y = j;
|
||||
+ this.z = k;
|
||||
+ // Paper end
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
}
|
||||
|
||||
public BlockPosition.MutableBlockPosition c(EnumDirection enumdirection, int i) {
|
||||
- return this.c(this.b + enumdirection.getAdjacentX() * i, this.c + enumdirection.getAdjacentY() * i, this.d + enumdirection.getAdjacentZ() * i);
|
||||
+ return this.c(x + enumdirection.getAdjacentX() * i, y + enumdirection.getAdjacentY() * i, z + enumdirection.getAdjacentZ() * i); // Paper - use xyz
|
||||
}
|
||||
|
||||
public BlockPosition.MutableBlockPosition d(int i, int j, int k) {
|
||||
- return this.c(this.b + i, this.c + j, this.d + k);
|
||||
+ return this.c(x + i, y + j, z + k); // Paper - use xyz
|
||||
}
|
||||
|
||||
public void p(int i) {
|
||||
- this.c = i;
|
||||
+ this.y = i; // Paper change to y
|
||||
}
|
||||
|
||||
public BlockPosition h() {
|
||||
--
|
@ -6,7 +6,7 @@ Subject: [PATCH] Store counts for each Entity/Block Entity Type
|
||||
Opens door for future patches to optimize performance
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 120e66c78..0ae780c8e 100644
|
||||
index 7837f1024..0a0d04cf6 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
|
@ -8,7 +8,7 @@ This enables us a fast reference to the entities current chunk instead
|
||||
of having to look it up by hashmap lookups.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 9500c456d..120e66c78 100644
|
||||
index cd4fbee0c..7837f1024 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
@ -86,7 +86,7 @@ index 9500c456d..120e66c78 100644
|
||||
|
||||
public boolean c(BlockPosition blockposition) {
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 53fc37088..1ef52cc6d 100644
|
||||
index e65558f7a..36cc0c18d 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
@ -131,7 +131,7 @@ index 53fc37088..1ef52cc6d 100644
|
||||
public final String entityKeyString;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
||||
index b09325097..b992360ac 100644
|
||||
index 257dd1da9..cffbcb8f7 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class TileEntity implements KeyedObject {
|
||||
@ -151,7 +151,7 @@ index b09325097..b992360ac 100644
|
||||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 70143c4d3..1e3675e4f 100644
|
||||
index 72164e11a..f09251eec 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -0,0 +0,0 @@ import java.util.UUID;
|
||||
|
Loading…
Reference in New Issue
Block a user