Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 11:30:06 +01:00
4d38ee111f
I believe this brings us back to stable. A lot of complexity was learned about juggling priorities. We were essentially promoting more chunks to urgent than really needed to be urgent. So this commit adds a lot more logic to juggle neighbor priorities and demote their priority once they meet the requirements needed of them. This greatly improves the performance of "urgent" chunks". Fixes #3410 Fixes #3426 Fixes #3425 Fixes #3416
63 Zeilen
3.2 KiB
Diff
63 Zeilen
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Thu, 16 Apr 2020 16:13:59 -0700
|
|
Subject: [PATCH] Optimize ChunkProviderServer's chunk level checking helper
|
|
methods
|
|
|
|
These can be hot functions (i.e entity ticking and block ticking),
|
|
so inline where possible, and avoid the abstraction of the
|
|
Either class.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
index 2ef8506f10426b8a5877e30986c105c0d95be774..722db939971fe395d8250c388fbd7f3b5e87804d 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
@@ -607,27 +607,37 @@ public class ChunkProviderServer extends IChunkProvider {
|
|
|
|
public final boolean isInEntityTickingChunk(Entity entity) { return this.a(entity); } // Paper - OBFHELPER
|
|
@Override public boolean a(Entity entity) {
|
|
- long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
|
|
-
|
|
- return this.a(i, PlayerChunk::b);
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
+ // entity ticking
|
|
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(entity));
|
|
+ return playerChunk != null && playerChunk.isEntityTickingReady();
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
}
|
|
|
|
public final boolean isEntityTickingChunk(ChunkCoordIntPair chunkcoordintpair) { return this.a(chunkcoordintpair); } // Paper - OBFHELPER
|
|
@Override public boolean a(ChunkCoordIntPair chunkcoordintpair) {
|
|
- return this.a(chunkcoordintpair.pair(), PlayerChunk::b);
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
+ // is entity ticking ready
|
|
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(chunkcoordintpair));
|
|
+ return playerChunk != null && playerChunk.isEntityTickingReady();
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
}
|
|
|
|
@Override
|
|
public boolean a(BlockPosition blockposition) {
|
|
- long i = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
-
|
|
- return this.a(i, PlayerChunk::a);
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
+ // is ticking ready
|
|
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(blockposition));
|
|
+ return playerChunk != null && playerChunk.isTickingReady();
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
}
|
|
|
|
public boolean b(Entity entity) {
|
|
- long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
|
|
-
|
|
- return this.a(i, PlayerChunk::c);
|
|
+ // Paper start - optimize is ticking ready type functions
|
|
+ // is full chunk ready
|
|
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(entity));
|
|
+ return playerChunk != null && playerChunk.isFullChunkReady();
|
|
+ // Paper end - optimize is ticking ready type functions
|
|
}
|
|
|
|
private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) {
|