Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/Spigot-Server-Patches/0366-Synchronize-DataPaletteBlock-instead-of-ReentrantLoc.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

102 Zeilen
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 29 May 2020 20:29:02 -0400
Subject: [PATCH] Synchronize DataPaletteBlock instead of ReentrantLock
Mojang has flaws in their logic about chunks being concurrently
wrote to. So we constantly see crashes around multiple threads writing.
Additionally, java has optimized synchronization so well that its
in many times faster than trying to manage read wrote locks for low
contention situations.
And this is extremely a low contention situation.
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
index eabc9d7b934f27c823e012f3f10fffc23b461292..f4c1b8d32b239c44e70d3fa6d094b74955f75339 100644
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
@@ -23,7 +23,7 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
private int i; private int getBitsPerObject() { return this.i; } // Paper - OBFHELPER
private final ReentrantLock j = new ReentrantLock();
- public void a() {
+ public void a() { /* // Paper start - disable this - use proper synchronization
if (this.j.isLocked() && !this.j.isHeldByCurrentThread()) {
String s = (String) Thread.getAllStackTraces().keySet().stream().filter(Objects::nonNull).map((thread) -> {
return thread.getName() + ": \n\tat " + (String) Arrays.stream(thread.getStackTrace()).map(Object::toString).collect(Collectors.joining("\n\tat "));
@@ -35,11 +35,11 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
throw new ReportedException(crashreport);
} else {
this.j.lock();
- }
+ } */ // Paper end
}
public void b() {
- this.j.unlock();
+ //this.j.unlock(); // Paper - disable this
}
public DataPaletteBlock(DataPalette<T> datapalette, RegistryBlockID<T> registryblockid, Function<NBTTagCompound, T> function, Function<T, NBTTagCompound> function1, T t0) {
@@ -75,7 +75,7 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
}
@Override
- public int onResize(int i, T t0) {
+ public synchronized int onResize(int i, T t0) { // Paper - synchronize
this.a();
DataBits databits = this.a;
DataPalette<T> datapalette = this.h;
@@ -98,18 +98,18 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
}
public T setBlock(int i, int j, int k, T t0) {
- this.a();
- T t1 = this.a(b(i, j, k), t0);
+ //this.a(); // Paper - remove to reduce ops - synchronize handled below
+ return this.a(b(i, j, k), t0); // Paper
- this.b();
- return t1;
+ //this.b(); // Paper
+ //return t1; // PAper
}
public T b(int i, int j, int k, T t0) {
return this.a(b(i, j, k), t0);
}
- protected T a(int i, T t0) {
+ protected synchronized T a(int i, T t0) { // Paper - synchronize - writes
int j = this.h.a(t0);
int k = this.a.a(i, j);
T t1 = this.h.a(k);
@@ -134,7 +134,7 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
}
public void writeDataPaletteBlock(PacketDataSerializer packetDataSerializer) { this.b(packetDataSerializer); } // Paper - OBFHELPER
- public void b(PacketDataSerializer packetdataserializer) {
+ public synchronized void b(PacketDataSerializer packetdataserializer) { // Paper - synchronize
this.a();
packetdataserializer.writeByte(this.i);
this.h.b(packetdataserializer);
@@ -142,7 +142,7 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
this.b();
}
- public void a(NBTTagList nbttaglist, long[] along) {
+ public synchronized void a(NBTTagList nbttaglist, long[] along) { // Paper - synchronize
this.a();
int i = Math.max(4, MathHelper.e(nbttaglist.size()));
@@ -175,7 +175,7 @@ public class DataPaletteBlock<T> implements DataPaletteExpandable<T> {
this.b();
}
- public void a(NBTTagCompound nbttagcompound, String s, String s1) {
+ public synchronized void a(NBTTagCompound nbttagcompound, String s, String s1) { // Paper - synchronize
this.a();
DataPaletteHash<T> datapalettehash = new DataPaletteHash<>(this.d, this.i, this.c, this.e, this.f);
T t0 = this.g;