13
0
geforkt von Mirrors/Paper

Remove redundant GameProfileCache diff

Dieser Commit ist enthalten in:
Jason Penilla 2022-03-17 20:53:36 -07:00
Ursprung 57a5d8880e
Commit 535cd27411
4 geänderte Dateien mit 10 neuen und 44 gelöschten Zeilen

Datei anzeigen

@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return com.destroystokyo.paper.PaperConfig.isProxyOnlineMode(); // Paper
}
public synchronized void add(GameProfile profile) { // Paper - synchronize
public void add(GameProfile profile) {
diff --git a/src/main/java/net/minecraft/server/players/OldUsersConverter.java b/src/main/java/net/minecraft/server/players/OldUsersConverter.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/players/OldUsersConverter.java

Datei anzeigen

@ -1,15 +1,8 @@
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] Optimize UserCache / Thread Safe
Subject: [PATCH] Async GameProfileCache saving
Because Techable keeps complaining about how this isn't thread safe,
easier to do this than replace the entire thing.
Additionally, move Saving of the User cache to be done async, incase
the user never changed the default setting for Spigot's save on stop only.
1.17: TODO does this need the synchronized blocks anymore?
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -41,15 +34,6 @@ diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
@@ -0,0 +0,0 @@ public class GameProfileCache {
return GameProfileCache.usesAuthentication;
}
- public void add(GameProfile profile) {
+ public synchronized void add(GameProfile profile) { // Paper - synchronize
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
@@ -0,0 +0,0 @@ public class GameProfileCache {
GameProfileCache.GameProfileInfo usercache_usercacheentry = new GameProfileCache.GameProfileInfo(profile, date);
@ -59,14 +43,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
private long getNextOperation() {
return this.operationCount.incrementAndGet();
}
- public Optional<GameProfile> get(String name) {
+ public synchronized Optional<GameProfile> get(String name) { // Paper - synchronize
String s1 = name.toLowerCase(Locale.ROOT);
GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1);
boolean flag = false;
@@ -0,0 +0,0 @@ public class GameProfileCache {
}
@ -97,7 +73,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} catch (IOException ioexception) {
;
}
-
+ // Paper start
+ };
+ if (asyncSave) {
@ -106,6 +81,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ save.run();
+ }
+ // Paper end
}
private Stream<GameProfileCache.GameProfileInfo> getTopMRUProfiles(int limit) {

Datei anzeigen

@ -607,7 +607,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
+ // Paper start
+ @Nullable public GameProfile getProfileIfCached(String name) {
+ public @Nullable GameProfile getProfileIfCached(String name) {
+ GameProfileCache.GameProfileInfo entry = this.profilesByName.get(name.toLowerCase(Locale.ROOT));
+ if (entry == null) {
+ return null;
@ -617,7 +617,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end
+
public synchronized Optional<GameProfile> get(String name) { // Paper - synchronize
public Optional<GameProfile> get(String name) {
String s1 = name.toLowerCase(Locale.ROOT);
GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java

Datei anzeigen

@ -1,9 +1,10 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <spottedleaf@spottedleaf.dev>
Date: Sat, 11 Jul 2020 05:09:28 -0700
Subject: [PATCH] Separate lookup locking from state access in UserCache
Subject: [PATCH] Fix GameProfileCache concurrency
Prevent lookups from stalling simple state access/write calls
Separate lookup and state access locks prevent lookups
from stalling simple state access/write calls
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -37,19 +38,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
@@ -0,0 +0,0 @@ public class GameProfileCache {
return com.destroystokyo.paper.PaperConfig.isProxyOnlineMode(); // Paper
}
- public synchronized void add(GameProfile profile) { // Paper - synchronize
+ public void add(GameProfile profile) { // Paper - synchronize // Paper - allow better concurrency
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
@@ -0,0 +0,0 @@ public class GameProfileCache {
// Paper start
@Nullable public GameProfile getProfileIfCached(String name) {
public @Nullable GameProfile getProfileIfCached(String name) {
+ try { this.stateLock.lock(); // Paper - allow better concurrency
GameProfileCache.GameProfileInfo entry = this.profilesByName.get(name.toLowerCase(Locale.ROOT));
if (entry == null) {
@ -61,8 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
// Paper end
- public synchronized Optional<GameProfile> get(String name) { // Paper - synchronize
+ public Optional<GameProfile> get(String name) { // Paper - synchronize // Paper start - allow better concurrency
public Optional<GameProfile> get(String name) {
String s1 = name.toLowerCase(Locale.ROOT);
+ boolean stateLocked = true; try { this.stateLock.lock(); // Paper - allow better concurrency
GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1);