Paper/patches/server/0106-Optimise-BlockState-s-hashCode-equals.patch
Spottedleaf 01a13871de
Rewrite chunk system (#8177)
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.
2022-09-26 01:02:51 -07:00

73 lines
3.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alfie Cleveland <alfeh@me.com>
Date: Fri, 19 Aug 2016 01:52:56 +0100
Subject: [PATCH] Optimise BlockState's hashCode/equals
These are singleton "single instance" objects. We can rely on
object identity checks safely.
Use a simpler optimized hashcode
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
index 6cdb0716f2a4b29f7a5ecd109bf3c4700ebd22ad..ff1a0d125edd2ea10c870cbb62ae9aa23644b6dc 100644
--- a/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
@@ -30,8 +30,7 @@ public class BooleanProperty extends Property<Boolean> {
return value.toString();
}
- @Override
- public boolean equals(Object object) {
+ public boolean equals_unused(Object object) { // Paper
if (this == object) {
return true;
} else if (object instanceof BooleanProperty && super.equals(object)) {
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
index 4d6e7b5889ecb81195c7152225ae8e3343d3408c..0bca0f971dac994bd8b6ecd87e8b33e26c0f18f9 100644
--- a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
@@ -45,8 +45,7 @@ public class EnumProperty<T extends Enum<T> & StringRepresentable> extends Prope
return value.getSerializedName();
}
- @Override
- public boolean equals(Object object) {
+ public boolean equals_unused(Object object) { // Paper
if (this == object) {
return true;
} else if (object instanceof EnumProperty && super.equals(object)) {
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
index 59b5b22a567e4e2be499a2a35aedb10218a7432a..bdbe0362e49e73c05237f9f3143230e0b03e494e 100644
--- a/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
@@ -35,8 +35,7 @@ public class IntegerProperty extends Property<Integer> {
return this.values;
}
- @Override
- public boolean equals(Object object) {
+ public boolean equals_unused(Object object) { // Paper
if (this == object) {
return true;
} else if (object instanceof IntegerProperty && super.equals(object)) {
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
index 5a973c1536291e79aa8377ca5bda8ef84127e20a..a37424bbc6bee02354abaa793aa0865c556c6bbe 100644
--- a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
@@ -68,14 +68,7 @@ public abstract class Property<T extends Comparable<T>> {
@Override
public boolean equals(Object object) {
- if (this == object) {
- return true;
- } else if (!(object instanceof Property)) {
- return false;
- } else {
- Property<?> property = (Property)object;
- return this.clazz.equals(property.clazz) && this.name.equals(property.name);
- }
+ return this == object; // Paper
}
@Override