526795bacd
* Update patches to handle vineflower decompiler * update patches again to handle inlined simple lambdas * update vf again and re-apply/rebuild patches * update patches after removal of verify-merges flag * fix compile issue * remove maven local * fix some issues * address more issues * fix collision patch * use paperweight release * more fixes * update fineflower and fix patches again * add missing comment descriptor --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
87 Zeilen
4.1 KiB
Diff
87 Zeilen
4.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Mon, 16 May 2016 20:47:41 -0400
|
|
Subject: [PATCH] Async GameProfileCache saving
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 20ee0fd8f5a808436fae60b64fc3e8966146ba71..b9c006bef0491c401ae3a447a3f67742a75cb74f 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -980,7 +980,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
} catch (java.lang.InterruptedException ignored) {} // Paper
|
|
if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) {
|
|
MinecraftServer.LOGGER.info("Saving usercache.json");
|
|
- this.getProfileCache().save();
|
|
+ this.getProfileCache().save(false); // Paper - Perf: Async GameProfileCache saving
|
|
}
|
|
// Spigot end
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index 88d45e52bc1105c4351ec5be39e3829ecfa8c1b6..590da3a7acef406589e665652ccc46e01cc28e1b 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -242,7 +242,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
}
|
|
|
|
if (this.convertOldUsers()) {
|
|
- this.getProfileCache().save();
|
|
+ this.getProfileCache().save(false); // Paper - Perf: Async GameProfileCache saving
|
|
}
|
|
|
|
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
|
|
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
|
index f5ac34923eb29a4d8df59d35f3381cdf08f74cf6..370cf30a6411577ec8ed7a32e473217e2f64782b 100644
|
|
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
|
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
|
@@ -117,7 +117,7 @@ public class GameProfileCache {
|
|
GameProfileCache.GameProfileInfo usercache_usercacheentry = new GameProfileCache.GameProfileInfo(profile, date);
|
|
|
|
this.safeAdd(usercache_usercacheentry);
|
|
- if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.save(); // Spigot - skip saving if disabled
|
|
+ if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.save(true); // Spigot - skip saving if disabled // Paper - Perf: Async GameProfileCache saving
|
|
}
|
|
|
|
private long getNextOperation() {
|
|
@@ -150,7 +150,7 @@ public class GameProfileCache {
|
|
}
|
|
|
|
if (flag && !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { // Spigot - skip saving if disabled
|
|
- this.save();
|
|
+ this.save(true); // Paper - Perf: Async GameProfileCache saving
|
|
}
|
|
|
|
return optional;
|
|
@@ -262,7 +262,7 @@ public class GameProfileCache {
|
|
return arraylist;
|
|
}
|
|
|
|
- public void save() {
|
|
+ public void save(boolean asyncSave) { // Paper - Perf: Async GameProfileCache saving
|
|
JsonArray jsonarray = new JsonArray();
|
|
DateFormat dateformat = GameProfileCache.createDateFormat();
|
|
|
|
@@ -270,6 +270,7 @@ public class GameProfileCache {
|
|
jsonarray.add(GameProfileCache.writeGameProfile(usercache_usercacheentry, dateformat));
|
|
});
|
|
String s = this.gson.toJson(jsonarray);
|
|
+ Runnable save = () -> { // Paper - Perf: Async GameProfileCache saving
|
|
|
|
try {
|
|
BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8);
|
|
@@ -294,6 +295,14 @@ public class GameProfileCache {
|
|
} catch (IOException ioexception) {
|
|
;
|
|
}
|
|
+ // Paper start - Perf: Async GameProfileCache saving
|
|
+ };
|
|
+ if (asyncSave) {
|
|
+ io.papermc.paper.util.MCUtil.scheduleAsyncTask(save);
|
|
+ } else {
|
|
+ save.run();
|
|
+ }
|
|
+ // Paper end - Perf: Async GameProfileCache saving
|
|
|
|
}
|
|
|