mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
799bd8f5e9
Massive update to light to improve performance and chunk loading/generation. 1) Massive bit packing/unpacking optimizations and inlining. A lot of performance has to do with constant packing and unpacking of bits. We now inline a most bit operations, and re-use base x/y/z bits in many places. This helps with cpu level processing to just do all the math at once instead of having to jump in and out of function calls. This much logic also is likely over the JVM Inline limit for JIT too. 2) Applied a few of JellySquid's Phosphor mod optimizations such as - ensuring we don't notify neighbor chunks when neighbor chunk doesn't need to be notified - reduce hasLight checks in initializing light, and prob some more, they are tagged JellySquid where phosphor influence was used. 3) Optimize hot path accesses to getting updating chunk to have less branching 4) Optimize getBlock accesses to have less branching, and less unpacking 5) Have a separate urgent bucket for chunk light tasks. These tasks will always cut in line over non blocking light tasks. 6) Retain chunk priority while light tasks are enqueued. So if a task comes in at high priority but the queue is full of tasks already at a lower priority, before the task was simply added to the end. Now it can cut in line to the front. this applies for both urgent and non urgent tasks. 7) Buffer non urgent tasks even if queueUpdate is called multiple times to improve efficiency. 8) Fix NPE risk that crashes server in getting nibble data Fixes #3489 Fixes #3363
50 lines
2.9 KiB
Diff
50 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
|
Date: Mon, 27 Apr 2020 02:48:06 -0700
|
|
Subject: [PATCH] Reduce MutableInt allocations from light engine
|
|
|
|
We can abuse the fact light is single threaded and share an instance
|
|
per light engine instance
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/LightEngineBlock.java b/src/main/java/net/minecraft/server/LightEngineBlock.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/LightEngineBlock.java
|
|
+++ b/src/main/java/net/minecraft/server/LightEngineBlock.java
|
|
@@ -0,0 +0,0 @@ public final class LightEngineBlock extends LightEngineLayer<LightEngineStorageB
|
|
|
|
private static final EnumDirection[] e = EnumDirection.values();
|
|
private final BlockPosition.MutableBlockPosition f = new BlockPosition.MutableBlockPosition();
|
|
+ private final MutableInt mutableint = new MutableInt(); // Paper
|
|
|
|
public LightEngineBlock(ILightAccess ilightaccess) {
|
|
super(ilightaccess, EnumSkyBlock.BLOCK, new LightEngineStorageBlock(ilightaccess));
|
|
@@ -0,0 +0,0 @@ public final class LightEngineBlock extends LightEngineLayer<LightEngineStorageB
|
|
if (enumdirection == null) {
|
|
return 15;
|
|
} else {
|
|
- MutableInt mutableint = new MutableInt();
|
|
+ //MutableInt mutableint = new MutableInt(); // Paper - share mutableint, single threaded
|
|
IBlockData iblockdata = this.a(j, mutableint);
|
|
|
|
if (mutableint.getValue() >= 15) {
|
|
diff --git a/src/main/java/net/minecraft/server/LightEngineSky.java b/src/main/java/net/minecraft/server/LightEngineSky.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/LightEngineSky.java
|
|
+++ b/src/main/java/net/minecraft/server/LightEngineSky.java
|
|
@@ -0,0 +0,0 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
|
|
|
|
private static final EnumDirection[] e = EnumDirection.values();
|
|
private static final EnumDirection[] f = new EnumDirection[]{EnumDirection.NORTH, EnumDirection.SOUTH, EnumDirection.WEST, EnumDirection.EAST};
|
|
+ private final MutableInt mutableint = new MutableInt(); // Paper
|
|
|
|
public LightEngineSky(ILightAccess ilightaccess) {
|
|
super(ilightaccess, EnumSkyBlock.SKY, new LightEngineStorageSky(ilightaccess));
|
|
@@ -0,0 +0,0 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
|
|
if (k >= 15) {
|
|
return k;
|
|
} else {
|
|
- MutableInt mutableint = new MutableInt();
|
|
+ //MutableInt mutableint = new MutableInt(); // Paper - share mutableint, single threaded
|
|
IBlockData iblockdata = this.a(j, mutableint);
|
|
|
|
if (mutableint.getValue() >= 15) {
|