mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
01a13871de
Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
64 lines
2.5 KiB
Diff
64 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Techcable <Techcable@outlook.com>
|
|
Date: Wed, 30 Nov 2016 20:56:58 -0600
|
|
Subject: [PATCH] Improve BlockPosition inlining
|
|
|
|
Normally the JVM can inline virtual getters by having two sets of code, one is the 'optimized' code and the other is the 'deoptimized' code.
|
|
If a single type is used 99% of the time, then its worth it to inline, and to revert to 'deoptimized' the 1% of the time we encounter other types.
|
|
But if two types are encountered commonly, then the JVM can't inline them both, and the call overhead remains.
|
|
|
|
This scenario also occurs with BlockPos and MutableBlockPos.
|
|
The variables in BlockPos are final, so MutableBlockPos can't modify them.
|
|
MutableBlockPos fixes this by adding custom mutable variables, and overriding the getters to access them.
|
|
|
|
This approach with utility methods that operate on MutableBlockPos and BlockPos.
|
|
Specific examples are BlockPosition.up(), and World.isValidLocation().
|
|
It makes these simple methods much slower than they need to be.
|
|
|
|
This should result in an across the board speedup in anything that accesses blocks or does logic with positions.
|
|
|
|
This is based upon conclusions drawn from inspecting the assenmbly generated bythe JIT compiler on my microbenchmarks.
|
|
They had 'callq' (invoke) instead of 'mov' (get from memory) instructions.
|
|
|
|
diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java
|
|
index 9f32861d791f7e4cb39d2ad01f48e1916fc2b4b1..73b3c5f5c037fbe3f588f8f4b0113bef283632a4 100644
|
|
--- a/src/main/java/net/minecraft/core/Vec3i.java
|
|
+++ b/src/main/java/net/minecraft/core/Vec3i.java
|
|
@@ -50,7 +50,7 @@ public class Vec3i implements Comparable<Vec3i> {
|
|
}
|
|
|
|
@Override
|
|
- public boolean equals(Object object) {
|
|
+ public final boolean equals(Object object) { // Paper
|
|
if (this == object) {
|
|
return true;
|
|
} else if (!(object instanceof Vec3i)) {
|
|
@@ -68,7 +68,7 @@ public class Vec3i implements Comparable<Vec3i> {
|
|
}
|
|
|
|
@Override
|
|
- public int hashCode() {
|
|
+ public final int hashCode() { // Paper
|
|
return (this.getY() + this.getZ() * 31) * 31 + this.getX();
|
|
}
|
|
|
|
@@ -81,15 +81,15 @@ public class Vec3i implements Comparable<Vec3i> {
|
|
}
|
|
}
|
|
|
|
- public int getX() {
|
|
+ public final int getX() { // Paper
|
|
return this.x;
|
|
}
|
|
|
|
- public int getY() {
|
|
+ public final int getY() { // Paper
|
|
return this.y;
|
|
}
|
|
|
|
- public int getZ() {
|
|
+ public final int getZ() { // Paper
|
|
return this.z;
|
|
}
|
|
|