Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 02:50:09 +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.
Dieser Commit ist enthalten in:
Ursprung
c2c61055b6
Commit
2d7e5dce25
@ -1,4 +1,4 @@
|
|||||||
From 4849096581eda2911fc4f3dd36f58e4678e5dc29 Mon Sep 17 00:00:00 2001
|
From e732d1184f1686864d9d9bd11bb409fa18c64709 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Thu, 27 Aug 2015 01:15:02 -0400
|
Date: Thu, 27 Aug 2015 01:15:02 -0400
|
||||||
Subject: [PATCH] Optimize Chunk Access
|
Subject: [PATCH] Optimize Chunk Access
|
||||||
@ -9,10 +9,18 @@ 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.
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/ChunkMap.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ChunkMap.java
|
+++ b/src/main/java/net/minecraft/server/ChunkMap.java
|
||||||
@@ -98,8 +98,22 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
@@ -15,6 +15,7 @@ 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);
|
||||||
|
|
||||||
|
@@ -98,8 +99,22 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,19 +30,61 @@ index 4e51bd301a..7100ec7747 100644
|
|||||||
+ }
|
+ }
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
+ private Chunk lastChunkByPos = null; // Paper
|
+ private Chunk lastChunkByPos = null;
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Chunk get(long l) {
|
+ public Chunk get(long l) {
|
||||||
+ if (lastChunkByPos != null && l == lastChunkByPos.chunkKey) {
|
+ if (lastChunkByPos != null && l == lastChunkByPos.chunkKey) {
|
||||||
+ return lastChunkByPos;
|
+ return lastChunkByPos;
|
||||||
+ }
|
+ }
|
||||||
+ return super.get(l);
|
+ return lastChunkByPos = super.get(l);
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
public Chunk a(Object object) {
|
public Chunk a(Object object) {
|
||||||
return this.a(((Long) object).longValue());
|
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
|
||||||
|
@@ -78,15 +78,16 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -198,7 +199,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||||
|
}
|
||||||
|
|
||||||
|
this.chunks.put(k, chunk);
|
||||||
|
- this.lastChunk = chunk;
|
||||||
|
+ //this.lastChunk = chunk; // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
this.asyncTaskHandler.postToMainThread(chunk::addEntities);
|
||||||
|
@@ -342,7 +343,7 @@ 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
|
||||||
--
|
--
|
||||||
2.18.0
|
2.18.0
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From 23074703de62e4ed8821b5a5d70478b97c160dd1 Mon Sep 17 00:00:00 2001
|
From 633810714b9d75cdaabfc1a4d2e687046ecb2bc5 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Sat, 18 Jun 2016 23:22:12 -0400
|
Date: Sat, 18 Jun 2016 23:22:12 -0400
|
||||||
Subject: [PATCH] Delay Chunk Unloads based on Player Movement
|
Subject: [PATCH] Delay Chunk Unloads based on Player Movement
|
||||||
@ -52,10 +52,10 @@ index 0ef1a8c7d3..2efb870dd6 100644
|
|||||||
public final int locZ;
|
public final int locZ;
|
||||||
private boolean l;
|
private boolean l;
|
||||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
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
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
@@ -305,6 +305,19 @@ public class ChunkProviderServer implements IChunkProvider {
|
@@ -306,6 +306,19 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||||
}
|
}
|
||||||
activityAccountant.endActivity(); // Spigot
|
activityAccountant.endActivity(); // Spigot
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From 8120e628e716fa08733831f191244993f971e5b1 Mon Sep 17 00:00:00 2001
|
From e036b4c10f2ddfe4dd643eff683210b672f63c9d Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Mon, 19 Sep 2016 23:16:39 -0400
|
Date: Mon, 19 Sep 2016 23:16:39 -0400
|
||||||
Subject: [PATCH] Auto Save Improvements
|
Subject: [PATCH] Auto Save Improvements
|
||||||
@ -96,10 +96,10 @@ index 2efb870dd6..6c766f2bf7 100644
|
|||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
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
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
@@ -240,7 +240,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
@@ -241,7 +241,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||||
this.saveChunk(chunk, false); // Spigot
|
this.saveChunk(chunk, false); // Spigot
|
||||||
chunk.a(false);
|
chunk.a(false);
|
||||||
++i;
|
++i;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From bc41dd42020d4ee02972e95b3c721c52c6a0cf69 Mon Sep 17 00:00:00 2001
|
From 5022fe8950e4040dd0ee1bb63706eeec718ccee1 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Thu, 3 Nov 2016 21:52:22 -0400
|
Date: Thu, 3 Nov 2016 21:52:22 -0400
|
||||||
Subject: [PATCH] Prevent Auto Save if Save Queue is full
|
Subject: [PATCH] Prevent Auto Save if Save Queue is full
|
||||||
@ -23,10 +23,10 @@ index 79260172d9..381edf3e7d 100644
|
|||||||
private void removeCorruptTEs() {
|
private void removeCorruptTEs() {
|
||||||
removeCorruptTEs = getBoolean("remove-corrupt-tile-entities", false);
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
@@ -233,6 +233,13 @@ public class ChunkProviderServer implements IChunkProvider {
|
@@ -234,6 +234,13 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||||
synchronized (this.chunkLoader) {
|
synchronized (this.chunkLoader) {
|
||||||
ObjectIterator objectiterator = this.chunks.values().iterator();
|
ObjectIterator objectiterator = this.chunks.values().iterator();
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ index 90840e4709..87960344f1 100644
|
|||||||
Chunk chunk = (Chunk) objectiterator.next();
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||||
@@ -141,6 +141,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
@@ -141,6 +141,8 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
From fc1808562cf1dd7ff5834b4e5692394bb9dd1524 Mon Sep 17 00:00:00 2001
|
From 2ec23d4415fa7cdff14d42f5f46c1b11eea99c63 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Fri, 4 Nov 2016 02:12:10 -0400
|
Date: Fri, 4 Nov 2016 02:12:10 -0400
|
||||||
Subject: [PATCH] Chunk Save Stats Debug Option
|
Subject: [PATCH] Chunk Save Stats Debug Option
|
||||||
@ -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.
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
@@ -30,6 +30,11 @@ public class ChunkProviderServer implements IChunkProvider {
|
@@ -30,6 +30,11 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||||
@ -23,7 +23,7 @@ index 87960344f1..6b8d4c79e8 100644
|
|||||||
public final Long2ObjectMap<Chunk> chunks = Long2ObjectMaps.synchronize(new ChunkMap(8192));
|
public final Long2ObjectMap<Chunk> chunks = Long2ObjectMaps.synchronize(new ChunkMap(8192));
|
||||||
private Chunk lastChunk;
|
private Chunk lastChunk;
|
||||||
private final ChunkTaskScheduler chunkScheduler;
|
private final ChunkTaskScheduler chunkScheduler;
|
||||||
@@ -236,6 +241,29 @@ public class ChunkProviderServer implements IChunkProvider {
|
@@ -237,6 +242,29 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||||
// Paper start
|
// Paper start
|
||||||
final ChunkRegionLoader chunkLoader = (ChunkRegionLoader) world.getChunkProviderServer().chunkLoader;
|
final ChunkRegionLoader chunkLoader = (ChunkRegionLoader) world.getChunkProviderServer().chunkLoader;
|
||||||
final int queueSize = chunkLoader.getQueueSize();
|
final int queueSize = chunkLoader.getQueueSize();
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
From 4e1234fad311a8d7fc90e7c4a1c2359eaf15de60 Mon Sep 17 00:00:00 2001
|
From bf0639fd7585002f204228976110c3a83d92c79c Mon Sep 17 00:00:00 2001
|
||||||
From: Brokkonaut <hannos17@gmx.de>
|
From: Brokkonaut <hannos17@gmx.de>
|
||||||
Date: Tue, 7 Feb 2017 16:55:35 -0600
|
Date: Tue, 7 Feb 2017 16:55:35 -0600
|
||||||
Subject: [PATCH] Make targetSize more aggressive in the chunk unload queue
|
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
|
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
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
@@ -310,7 +310,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
@@ -311,7 +311,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||||
// Spigot start
|
// Spigot start
|
||||||
org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant;
|
org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant;
|
||||||
activityAccountant.startActivity(0.5);
|
activityAccountant.startActivity(0.5);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren