mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
f835a91d15
Upstream has added the equivalent of our SentientNPC API, with exception to the EnderDragon. We've added Mob to the EnderDragon, and our SentientNPC API should behave the same. Vex#getOwner has been deprecated and a replacement Vex#getSummoner has been added using Mob. However, since 1.13 is not production ready, SentientNPC API is subject for removal in 1.13.1 since 1.13 API is not compatible with 1.12. Please move to the Mob interface ASAP. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: c5ab54d8 Expand GameRule API ab9a606c Improve entity hierarchy by adding Mob interface. CraftBukkit Changes:29e75648
Expand GameRule API50e6858b
Improve entity hierarchy by adding Mob interface.0e1d79b4
Correct error in previous patch
68 lines
3.0 KiB
Diff
68 lines
3.0 KiB
Diff
From 3f17ec5d00f8b665bd1d1ded6821d3dcc1eafde6 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Mon, 23 Jul 2018 23:40:04 -0400
|
|
Subject: [PATCH] Optimize Region File Cache
|
|
|
|
CraftBukkit added synchronization to read and write methods. This adds
|
|
much more contention on this object for accessing region files, as
|
|
the entire read and write of NBT data is now a blocking operation.
|
|
|
|
This causes issues when something then simply needs to check if a chunk exists
|
|
on the main thread, causing a block...
|
|
|
|
However, this synchronization was unnecessary, because there is already
|
|
enough synchronization done to keep things safe
|
|
|
|
1) Obtaining a Region File: Those methods are still static synchronized.
|
|
Meaning we can safely obtain a Region File concurrently.
|
|
|
|
2) RegionFile data access: Methods reading and manipulating data from
|
|
a region file are also marked synchronized, ensuring that no 2 processes
|
|
are reading or writing data at the same time.
|
|
|
|
3) Checking a region file for chunkExists: getOffset is also synchronized
|
|
ensuring that even if a chunk is currently being written, it will be safe.
|
|
|
|
By removing these synchronizations, we reduce the locking to only
|
|
when data is being write or read.
|
|
|
|
GZIP compression and NBT Buffer creation will no longer be part of the
|
|
synchronized context, reducing lock times.
|
|
|
|
Ultimately: This brings us back to Vanilla, which has had no indication of region file loss.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
index 3b8d01ea1a..609d6c3550 100644
|
|
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
|
@@ -97,7 +97,7 @@ public class RegionFileCache {
|
|
|
|
@Nullable
|
|
// CraftBukkit start - call sites hoisted for synchronization
|
|
- public static synchronized NBTTagCompound read(File file, int i, int j) throws IOException {
|
|
+ public static NBTTagCompound read(File file, int i, int j) throws IOException { // Paper - remove synchronization
|
|
RegionFile regionfile = a(file, i, j);
|
|
|
|
DataInputStream datainputstream = regionfile.a(i & 31, j & 31);
|
|
@@ -110,7 +110,7 @@ public class RegionFileCache {
|
|
}
|
|
|
|
@Nullable
|
|
- public static synchronized void write(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException {
|
|
+ public static void write(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException { // Paper - remove synchronization
|
|
RegionFile regionfile = a(file, i, j);
|
|
|
|
DataOutputStream dataoutputstream = regionfile.c(i & 31, j & 31);
|
|
@@ -119,7 +119,7 @@ public class RegionFileCache {
|
|
}
|
|
// CraftBukkit end
|
|
|
|
- public static synchronized boolean chunkExists(File file, int i, int j) {
|
|
+ public static boolean chunkExists(File file, int i, int j) { // Paper - remove synchronization
|
|
RegionFile regionfile = b(file, i, j);
|
|
|
|
return regionfile != null ? regionfile.d(i & 31, j & 31) : false;
|
|
--
|
|
2.18.0
|
|
|