diff options
Diffstat (limited to 'patches/server/0324-Optimise-getChunkAt-calls-for-loaded-chunks.patch')
-rw-r--r-- | patches/server/0324-Optimise-getChunkAt-calls-for-loaded-chunks.patch | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/patches/server/0324-Optimise-getChunkAt-calls-for-loaded-chunks.patch b/patches/server/0324-Optimise-getChunkAt-calls-for-loaded-chunks.patch new file mode 100644 index 0000000000..bb08aebe5a --- /dev/null +++ b/patches/server/0324-Optimise-getChunkAt-calls-for-loaded-chunks.patch @@ -0,0 +1,66 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Sat, 25 Jan 2020 17:04:35 -0800 +Subject: [PATCH] Optimise getChunkAt calls for loaded chunks + +bypass the need to get a player chunk, then get the either, +then unwrap it... + +diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +index 369e4bf5ff52cb774f1acaf760b8bd276a0745f5..326b67c15ee3df162bf4468729c49dd98b582f02 100644 +--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java ++++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +@@ -254,6 +254,12 @@ public class ServerChunkCache extends ChunkSource { + return this.getChunk(x, z, leastStatus, create); + }, this.mainThreadProcessor).join(); + } else { ++ // Paper start - Perf: Optimise getChunkAt calls for loaded chunks ++ LevelChunk ifLoaded = this.getChunkAtIfLoadedMainThread(x, z); ++ if (ifLoaded != null) { ++ return ifLoaded; ++ } ++ // Paper end - Perf: Optimise getChunkAt calls for loaded chunks + ProfilerFiller gameprofilerfiller = this.level.getProfiler(); + + gameprofilerfiller.incrementCounter("getChunk"); +@@ -300,39 +306,7 @@ public class ServerChunkCache extends ChunkSource { + if (Thread.currentThread() != this.mainThread) { + return null; + } else { +- this.level.getProfiler().incrementCounter("getChunkNow"); +- long k = ChunkPos.asLong(chunkX, chunkZ); +- +- for (int l = 0; l < 4; ++l) { +- if (k == this.lastChunkPos[l] && this.lastChunkStatus[l] == ChunkStatus.FULL) { +- ChunkAccess ichunkaccess = this.lastChunk[l]; +- +- return ichunkaccess instanceof LevelChunk ? (LevelChunk) ichunkaccess : null; +- } +- } +- +- ChunkHolder playerchunk = this.getVisibleChunkIfPresent(k); +- +- if (playerchunk == null) { +- return null; +- } else { +- Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = (Either) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error +- +- if (either == null) { +- return null; +- } else { +- ChunkAccess ichunkaccess1 = (ChunkAccess) either.left().orElse(null); // CraftBukkit - decompile error +- +- if (ichunkaccess1 != null) { +- this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL); +- if (ichunkaccess1 instanceof LevelChunk) { +- return (LevelChunk) ichunkaccess1; +- } +- } +- +- return null; +- } +- } ++ return this.getChunkAtIfLoadedMainThread(chunkX, chunkZ); // Paper - Perf: Optimise getChunkAt calls for loaded chunks + } + } + |