mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-28 03:01:31 +01:00
Disable Vanilla last chunk access cache, use ours
Also fixes some bugs in ours Ultimately they both are near the same, but ours is behind the synchronized gate. Mojangs is mixed behind 2 different synchronization contexts (chunks can lock 2 different objects) Mojang also blindly unsets the ref on any chunk unload, not just if its the one being pointed to.
This commit is contained in:
parent
998d00b523
commit
09d1dd17a0
@ -96,7 +96,7 @@ index 2efb870dd6..6c766f2bf7 100644
|
||||
|
||||
public boolean isEmpty() {
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 53dc1322e8..90840e4709 100644
|
||||
index 7417660e4d..7a972f4187 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
|
@ -8,7 +8,7 @@ Adds a command line flag to enable stats on how chunk saves are processing.
|
||||
Stats on current queue, how many was processed and how many were queued.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 87960344f1..6b8d4c79e8 100644
|
||||
index 87744dcbfc..355186c111 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
|
@ -52,7 +52,7 @@ index 0ef1a8c7d3..2efb870dd6 100644
|
||||
public final int locZ;
|
||||
private boolean l;
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 6b041f06e4..53dc1322e8 100644
|
||||
index 1a1daf36b7..7417660e4d 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Make targetSize more aggressive in the chunk unload queue
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 6b8d4c79e8..5e8a20fdd6 100644
|
||||
index 355186c111..0ca071b879 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
|
@ -9,9 +9,17 @@ getChunkAt is called for the same chunk multiple times in a row, often from getT
|
||||
Optimize this look up by using a Last Access cache.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkMap.java b/src/main/java/net/minecraft/server/ChunkMap.java
|
||||
index 4e51bd301a..7100ec7747 100644
|
||||
index fbebd4591c..b941676829 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkMap.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
||||
|
||||
public Chunk a(long i, Chunk chunk) {
|
||||
chunk.world.timings.syncChunkLoadPostTimer.startTiming(); // Paper
|
||||
+ lastChunkByPos = chunk; // Paper
|
||||
Chunk chunk1 = (Chunk) super.put(i, chunk);
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i);
|
||||
|
||||
@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
||||
}
|
||||
}
|
||||
@ -22,17 +30,59 @@ index 4e51bd301a..7100ec7747 100644
|
||||
+ }
|
||||
return chunk;
|
||||
}
|
||||
+ private Chunk lastChunkByPos = null; // Paper
|
||||
+ private Chunk lastChunkByPos = null;
|
||||
+
|
||||
+ @Override
|
||||
+ public Chunk get(long l) {
|
||||
+ if (lastChunkByPos != null && l == lastChunkByPos.chunkKey) {
|
||||
+ return lastChunkByPos;
|
||||
+ }
|
||||
+ return super.get(l);
|
||||
+ return lastChunkByPos = super.get(l);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public Chunk a(Object object) {
|
||||
return this.a(((Long) object).longValue());
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 6b041f06e4..1a1daf36b7 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
Chunk chunk;
|
||||
|
||||
synchronized (this.chunkLoader) {
|
||||
- if (this.lastChunk != null && this.lastChunk.getPos().x == i && this.lastChunk.getPos().z == j) {
|
||||
+ // Paper start - remove vanilla lastChunk, we do it more accurately
|
||||
+ /* if (this.lastChunk != null && this.lastChunk.locX == i && this.lastChunk.locZ == j) {
|
||||
return this.lastChunk;
|
||||
- }
|
||||
+ }*/ // Paper end
|
||||
|
||||
long k = ChunkCoordIntPair.a(i, j);
|
||||
|
||||
chunk = (Chunk) this.chunks.get(k);
|
||||
if (chunk != null) {
|
||||
- this.lastChunk = chunk;
|
||||
+ //this.lastChunk = chunk; // Paper remove vanilla lastChunk
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
}
|
||||
|
||||
this.chunks.put(k, chunk);
|
||||
- this.lastChunk = chunk;
|
||||
+ //this.lastChunk = chunk; // Paper
|
||||
}
|
||||
|
||||
this.asyncTaskHandler.postToMainThread(chunk::addEntities);
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
this.saveChunk(chunk, true); // Spigot
|
||||
}
|
||||
this.chunks.remove(chunk.chunkKey);
|
||||
- this.lastChunk = null;
|
||||
+ //this.lastChunk = null; // Paper
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
--
|
@ -23,7 +23,7 @@ index 79260172d9..381edf3e7d 100644
|
||||
private void removeCorruptTEs() {
|
||||
removeCorruptTEs = getBoolean("remove-corrupt-tile-entities", false);
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 90840e4709..87960344f1 100644
|
||||
index 7a972f4187..87744dcbfc 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
@ -41,7 +41,7 @@ index 90840e4709..87960344f1 100644
|
||||
Chunk chunk = (Chunk) objectiterator.next();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index c85a8dac3e..0fc50ce60c 100644
|
||||
index fde80d1fd3..3283b5047d 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
||||
|
Loading…
Reference in New Issue
Block a user